Skip to content

Commit cf7a86f

Browse files
committed
Bug 1807004 - Make WebSocketChannel::OnInputStreamReady always be called on IO thread, r=necko-reviewers,valentin
Since we passed a null target to `AsyncWait`, the [inputstream callback could be called directly](https://searchfox.org/mozilla-central/rev/7eca06dd4c5e4dfd6764a382569c841c05a0857d/xpcom/io/nsPipe3.cpp#118) on main thread. To avoid `WebSocketChannel::OnInputStreamReady` being called on main thread, we should pass `mIOThread` to `AsyncWait`. Differential Revision: https://phabricator.services.mozilla.com/D165833
1 parent 98897a9 commit cf7a86f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

netwerk/protocol/websocket/WebSocketChannel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,9 +2949,9 @@ nsresult WebSocketChannel::StartWebsocketData() {
29492949
&WebSocketChannel::NotifyOnStart),
29502950
NS_DISPATCH_NORMAL);
29512951

2952-
nsresult rv = self->mConnection
2953-
? self->mConnection->StartReading()
2954-
: self->mSocketIn->AsyncWait(self, 0, 0, nullptr);
2952+
nsresult rv = self->mConnection ? self->mConnection->StartReading()
2953+
: self->mSocketIn->AsyncWait(
2954+
self, 0, 0, self->mIOThread);
29552955
if (NS_FAILED(rv)) {
29562956
self->AbortSession(rv);
29572957
}
@@ -4080,7 +4080,7 @@ WebSocketChannel::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) {
40804080
NS_IMETHODIMP
40814081
WebSocketChannel::OnInputStreamReady(nsIAsyncInputStream* aStream) {
40824082
LOG(("WebSocketChannel::OnInputStreamReady() %p\n", this));
4083-
MOZ_ASSERT(mIOThread->IsOnCurrentThread(), "not on right thread");
4083+
MOZ_DIAGNOSTIC_ASSERT(mIOThread->IsOnCurrentThread(), "not on right thread");
40844084

40854085
if (!mSocketIn) { // did we we clean up the socket after scheduling
40864086
// InputReady?
@@ -4131,7 +4131,7 @@ WebSocketChannel::OnInputStreamReady(nsIAsyncInputStream* aStream) {
41314131
NS_IMETHODIMP
41324132
WebSocketChannel::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
41334133
LOG(("WebSocketChannel::OnOutputStreamReady() %p\n", this));
4134-
MOZ_ASSERT(mIOThread->IsOnCurrentThread(), "not on right thread");
4134+
MOZ_DIAGNOSTIC_ASSERT(mIOThread->IsOnCurrentThread(), "not on right thread");
41354135
nsresult rv;
41364136

41374137
if (!mCurrentOut) PrimeNewOutgoingMessage();

0 commit comments

Comments
 (0)