mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 08:07:30 +09:00
[dom] Better handling of aborted websocket workers.
Catch the case where we are in worker-shutdown but are still connecting and make filing and closing connections a bit more robust with a RefPtr.
This commit is contained in:
parent
8b5c0a9cd9
commit
bcbe73119f
1 changed files with 10 additions and 4 deletions
|
|
@ -2548,16 +2548,22 @@ WebSocket::Close(const Optional<uint16_t>& aCode,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the webSocket is not closed we MUST have a mImpl.
|
// If we don't have mImpl, we are in a shutting down worker where we are still
|
||||||
MOZ_ASSERT(mImpl);
|
// in CONNECTING state, but already disconnected internally.
|
||||||
|
if (!mImpl) {
|
||||||
|
MOZ_ASSERT(readyState == CONNECTING);
|
||||||
|
SetReadyState(CLOSING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<WebSocketImpl> impl = mImpl;
|
||||||
if (readyState == CONNECTING) {
|
if (readyState == CONNECTING) {
|
||||||
mImpl->FailConnection(closeCode, closeReason);
|
impl->FailConnection(closeCode, closeReason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(readyState == OPEN);
|
MOZ_ASSERT(readyState == OPEN);
|
||||||
mImpl->CloseConnection(closeCode, closeReason);
|
impl->CloseConnection(closeCode, closeReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue