mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +09:00
Issue #1767 - Prevent incorrect calling of network change detection function.
This rewrites the websocket channel network change detection function to not skip part of its logic in a situation that has already been checked, preventing a thread race. See analysis of the problem in the issue.
This commit is contained in:
parent
0be821b7c1
commit
434b3269fb
2 changed files with 16 additions and 13 deletions
|
|
@ -1247,10 +1247,10 @@ WebSocketChannel::Observe(nsISupports *subject,
|
|||
// Next we check mDataStarted, which we need to do on mTargetThread.
|
||||
if (!IsOnTargetThread()) {
|
||||
mTargetThread->Dispatch(
|
||||
NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged),
|
||||
NewRunnableMethod(this, &WebSocketChannel::OnNetworkChangedTargetThread),
|
||||
NS_DISPATCH_NORMAL);
|
||||
} else {
|
||||
OnNetworkChanged();
|
||||
OnNetworkChangedTargetThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1260,21 +1260,23 @@ WebSocketChannel::Observe(nsISupports *subject,
|
|||
}
|
||||
|
||||
nsresult
|
||||
WebSocketChannel::OnNetworkChanged()
|
||||
WebSocketChannel::OnNetworkChangedTargetThread()
|
||||
{
|
||||
if (IsOnTargetThread()) {
|
||||
LOG(("WebSocketChannel::OnNetworkChanged() - on target thread %p", this));
|
||||
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(this, &WebSocketChannel::OnNetworkChanged),
|
||||
NS_DISPATCH_NORMAL);
|
||||
if (!mDataStarted) {
|
||||
LOG(("WebSocket: data not started yet, no ping needed"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mSocketThread->Dispatch(
|
||||
NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
WebSocketChannel::OnNetworkChanged()
|
||||
{
|
||||
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
|
||||
|
||||
LOG(("WebSocketChannel::OnNetworkChanged() - on socket thread %p", this));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue