summaryrefslogtreecommitdiff
path: root/netwerk/protocol/websocket/WebSocketChannel.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-11-19 14:06:18 +0000
committerMoonchild <moonchild@palemoon.org>2022-11-19 14:06:18 +0000
commitac9253e9871b06c91b61fd2f85f435182d490265 (patch)
treeff9494fd66e3fec61bf05d52bffb579a48cb209e /netwerk/protocol/websocket/WebSocketChannel.cpp
parent8778d482902f7e6fd2859858269b45076ea73848 (diff)
downloaduxp-ac9253e9871b06c91b61fd2f85f435182d490265.tar.gz
WebSocketChannel::CleanupConnection should run on the socket thread
Diffstat (limited to 'netwerk/protocol/websocket/WebSocketChannel.cpp')
-rw-r--r--netwerk/protocol/websocket/WebSocketChannel.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp
index f94c1d9ca9..679252500f 100644
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -2313,6 +2313,16 @@ WebSocketChannel::CleanupConnection()
{
LOG(("WebSocketChannel::CleanupConnection() %p", this));
+ // This should run on the Socket Thread to prevent potential races.
+ bool onSocketThread;
+ nsresult rv = mSocketThread->IsOnCurrentThread(&onSocketThread);
+ if (NS_SUCCEEDED(rv) && !onSocketThread) {
+ mSocketThread->Dispatch(
+ NewRunnableMethod(this, &WebSocketChannel::CleanupConnection),
+ NS_DISPATCH_NORMAL);
+ return;
+ }
+
if (mLingeringCloseTimer) {
mLingeringCloseTimer->Cancel();
mLingeringCloseTimer = nullptr;