Skip to content

Commit

Permalink
Bug 1881490 - Don't insert the same stream into TX queue, r=necko-rev…
Browse files Browse the repository at this point in the history
…iewers,jesup

Differential Revision: https://phabricator.services.mozilla.com/D202418
  • Loading branch information
KershawChang committed Feb 28, 2024
1 parent ed0eb49 commit a685a9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion netwerk/protocol/http/Http3Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ nsresult Http3Session::SendData(nsIUDPSocket* socket) {
while (CanSendData() && (stream = mReadyForWrite.PopFront())) {
LOG(("Http3Session::SendData call ReadSegments from stream=%p [this=%p]",
stream.get(), this));

stream->SetInTxQueue(false);
rv = stream->ReadSegments();

// on stream error we return earlier to let the error be handled.
Expand Down Expand Up @@ -1557,7 +1557,15 @@ nsresult Http3Session::SendData(nsIUDPSocket* socket) {

void Http3Session::StreamReadyToWrite(Http3StreamBase* aStream) {
MOZ_ASSERT(aStream);
// Http3Session::StreamReadyToWrite can be called multiple times when we get
// duplicate DataWrite events from neqo at the same time. In this case, we
// only want to insert the stream in `mReadyForWrite` once.
if (aStream->IsInTxQueue()) {
return;
}

mReadyForWrite.Push(aStream);
aStream->SetInTxQueue(true);
if (CanSendData() && mConnection) {
Unused << mConnection->ResumeSend();
}
Expand Down
4 changes: 4 additions & 0 deletions netwerk/protocol/http/Http3StreamBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class Http3StreamBase : public SupportsWeakPtr, public ARefBase {
virtual bool RecvdReset() const { return mResetRecv; }
virtual void SetRecvdReset() { mResetRecv = true; }

void SetInTxQueue(bool aValue) { mInTxQueue = aValue; }
bool IsInTxQueue() const { return mInTxQueue; }

protected:
~Http3StreamBase();

Expand All @@ -63,6 +66,7 @@ class Http3StreamBase : public SupportsWeakPtr, public ARefBase {
bool mQueued{false};
bool mFin{false};
bool mResetRecv{false};
bool mInTxQueue{false};
};

} // namespace mozilla::net
Expand Down

0 comments on commit a685a9e

Please sign in to comment.