SHA256
1
0
forked from pool/seamonkey
seamonkey/seamonkey-websocketloop.patch
2021-05-18 13:16:24 +00:00

105 lines
3.7 KiB
Diff

# HG changeset patch
# User Dmitry Butskoy <dmitry@butskoy.name>
# Date 1619303931 -7200
# Parent f113610c2ced0b266dbad3626b7f43580d412d15
Bug 1633339 - Fix infinite loop when network changes and e10s is disabled. r=frg a=frg
diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -1265,52 +1265,54 @@ WebSocketChannel::Observe(nsISupports *s
if (!mSocketThread) {
// there has not been an asyncopen yet on the object and then we need
// no ping.
LOG(("WebSocket: early object, no ping needed"));
} else {
// Next we check mDataStarted, which we need to do on mTargetThread.
if (!IsOnTargetThread()) {
mTargetThread->Dispatch(
- NewRunnableMethod("net::WebSocketChannel::OnNetworkChanged",
+ NewRunnableMethod("net::WebSocketChannel::OnNetworkChangedTargetThread",
this,
- &WebSocketChannel::OnNetworkChanged),
+ &WebSocketChannel::OnNetworkChangedTargetThread),
NS_DISPATCH_NORMAL);
} else {
- nsresult rv = OnNetworkChanged();
+ nsresult rv = OnNetworkChangedTargetThread();
if (NS_FAILED(rv)) {
- LOG(("WebSocket: OnNetworkChanged failed (%08" PRIx32 ")",
+ LOG(("WebSocket: OnNetworkChangedTargetThread failed (%08" PRIx32 ")",
static_cast<uint32_t>(rv)));
}
}
}
}
}
return NS_OK;
}
nsresult
+WebSocketChannel::OnNetworkChangedTargetThread()
+{
+ LOG(("WebSocketChannel::OnNetworkChangedTargetThread() - on target thread %p", this));
+
+ if (!mDataStarted) {
+ LOG(("WebSocket: data not started yet, no ping needed"));
+ return NS_OK;
+ }
+
+ return mSocketThread->Dispatch(
+ NewRunnableMethod("net::WebSocketChannel::OnNetworkChanged",
+ this,
+ &WebSocketChannel::OnNetworkChanged),
+ NS_DISPATCH_NORMAL);
+}
+
+nsresult
WebSocketChannel::OnNetworkChanged()
{
- if (IsOnTargetThread()) {
- LOG(("WebSocketChannel::OnNetworkChanged() - on target thread %p", this));
-
- if (!mDataStarted) {
- LOG(("WebSocket: data not started yet, no ping needed"));
- return NS_OK;
- }
-
- return mSocketThread->Dispatch(
- NewRunnableMethod("net::WebSocketChannel::OnNetworkChanged",
- this,
- &WebSocketChannel::OnNetworkChanged),
- NS_DISPATCH_NORMAL);
- }
-
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("WebSocketChannel::OnNetworkChanged() - on socket thread %p", this));
if (mPingOutstanding) {
// If there's an outstanding ping that's expected to get a pong back
// we let that do its thing.
LOG(("WebSocket: pong already pending"));
diff --git a/netwerk/protocol/websocket/WebSocketChannel.h b/netwerk/protocol/websocket/WebSocketChannel.h
--- a/netwerk/protocol/websocket/WebSocketChannel.h
+++ b/netwerk/protocol/websocket/WebSocketChannel.h
@@ -146,16 +146,17 @@ private:
void EnqueueOutgoingMessage(nsDeque &aQueue, OutboundMessage *aMsg);
void PrimeNewOutgoingMessage();
void DeleteCurrentOutGoingMessage();
void GeneratePong(uint8_t *payload, uint32_t len);
void GeneratePing();
+ MOZ_MUST_USE nsresult OnNetworkChangedTargetThread();
MOZ_MUST_USE nsresult OnNetworkChanged();
MOZ_MUST_USE nsresult StartPinging();
void BeginOpen(bool aCalledFromAdmissionManager);
void BeginOpenInternal();
MOZ_MUST_USE nsresult HandleExtensions();
MOZ_MUST_USE nsresult SetupRequest();
MOZ_MUST_USE nsresult ApplyForAdmission();