summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-03-08 23:53:52 +0000
committerMoonchild <moonchild@palemoon.org>2022-05-30 08:19:22 +0000
commita595fa29a368c24978621fd90400964228b993b3 (patch)
treebb6662746882d6c4868dab71670c25ecf47d50e2 /netwerk
parent2705986b4a7977a30a18b20945ef072c4e32b89f (diff)
downloaduxp-a595fa29a368c24978621fd90400964228b993b3.tar.gz
[Network] Add a socket thread check and early exit for corner cases.
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/protocol/http/nsHttpConnectionMgr.cpp12
-rw-r--r--netwerk/protocol/http/nsHttpConnectionMgr.h12
2 files changed, 18 insertions, 6 deletions
diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
index 34bf9e58f3..70d051f747 100644
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -2630,6 +2630,7 @@ nsHttpConnectionMgr::OnMsgCompleteUpgrade(int32_t, ARefBase *param)
void
nsHttpConnectionMgr::OnMsgUpdateParam(int32_t inParam, ARefBase *)
{
+ MOZ_ASSERT(OnSocketThread(), "not on socket thread");
uint32_t param = static_cast<uint32_t>(inParam);
uint16_t name = ((param) & 0xFFFF0000) >> 16;
uint16_t value = param & 0x0000FFFF;
@@ -2701,9 +2702,18 @@ nsHttpConnectionMgr::ActivateTimeoutTick()
NS_WARNING("failed to create timer for http timeout management");
return;
}
+ ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+ if (!mSocketThreadTarget) {
+ NS_WARNING("HTTP Connection Manager: Cannot activate timout if not initialized or shutdown");
+ return;
+ }
mTimeoutTick->SetTarget(mSocketThreadTarget);
}
-
+ if (mIsShuttingDown) { // Atomic
+ // don't set a timer to generate an event if we're shutting down
+ // (mSocketThreadTarget might be null or garbage anyway if we're shutting down)
+ return;
+ }
MOZ_ASSERT(!mTimeoutTickArmed, "timer tick armed");
mTimeoutTickArmed = true;
mTimeoutTick->Init(this, 1000, nsITimer::TYPE_REPEATING_SLACK);
diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h
index b94761a018..10df91a75a 100644
--- a/netwerk/protocol/http/nsHttpConnectionMgr.h
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.h
@@ -483,8 +483,15 @@ private:
//-------------------------------------------------------------------------
ReentrantMonitor mReentrantMonitor;
+ // This is used as a flag that we're shut down, and no new events should be
+ // dispatched.
nsCOMPtr<nsIEventTarget> mSocketThreadTarget;
+ Atomic<bool, mozilla::Relaxed> mIsShuttingDown;
+
+ //-------------------------------------------------------------------------
+ // NOTE: these members are only accessed on the socket transport thread
+ //-------------------------------------------------------------------------
// connection limits
uint16_t mMaxConns;
uint16_t mMaxPersistConnsPerHost;
@@ -492,11 +499,6 @@ private:
uint16_t mMaxRequestDelay; // in seconds
uint16_t mMaxPipelinedRequests;
uint16_t mMaxOptimisticPipelinedRequests;
- Atomic<bool, mozilla::Relaxed> mIsShuttingDown;
-
- //-------------------------------------------------------------------------
- // NOTE: these members are only accessed on the socket transport thread
- //-------------------------------------------------------------------------
bool ProcessPendingQForEntry(nsConnectionEntry *, bool considerAll);
bool IsUnderPressure(nsConnectionEntry *ent,