WebSocketChannel::CleanupConnection should run on the socket thread

This commit is contained in:
Moonchild 2022-11-19 14:06:18 +00:00 committed by roytam1
commit 7fab5ebd11

View file

@ -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;