Bug 1218297 - eventtokenbucket shutdown leak r=valentin

This commit is contained in:
Patrick McManus 2015-12-23 10:47:13 -05:00
parent 3f8074f84e
commit a045ede9aa
4 changed files with 27 additions and 1 deletions

View File

@ -205,6 +205,18 @@ EventTokenBucket::UnPause()
UpdateTimer();
}
void
EventTokenBucket::Stop()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
SOCKET_LOG(("EventTokenBucket::Stop %p armed=%d\n", this, mTimerArmed));
mStopped = true;
if (mTimerArmed) {
mTimer->Cancel();
mTimerArmed = false;
}
}
nsresult
EventTokenBucket::SubmitEvent(ATokenBucketEvent *event, nsICancelable **cancelable)
{

View File

@ -86,7 +86,7 @@ public:
// credits. ClearCredits can be used before unpausing if desired.
void Pause();
void UnPause();
void Stop() { mStopped = true; }
void Stop();
// The returned cancelable event can only be canceled from the socket thread
nsresult SubmitEvent(ATokenBucketEvent *event, nsICancelable **cancelable);

View File

@ -2308,6 +2308,7 @@ nsHttpConnectionMgr::OnMsgShutdown(int32_t, ARefBase *param)
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
LOG(("nsHttpConnectionMgr::OnMsgShutdown\n"));
gHttpHandler->StopRequestTokenBucket();
mCT.Enumerate(ShutdownPassCB, this);
if (mTimeoutTick) {

View File

@ -29,6 +29,8 @@ class nsISiteSecurityService;
class nsIStreamConverterService;
class nsITimer;
extern mozilla::Atomic<PRThread*, mozilla::Relaxed> gSocketThread;
namespace mozilla {
namespace net {
class ATokenBucketEvent;
@ -563,6 +565,7 @@ public:
nsresult SubmitPacedRequest(ATokenBucketEvent *event,
nsICancelable **cancel)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
if (!mRequestTokenBucket)
return NS_ERROR_UNEXPECTED;
return mRequestTokenBucket->SubmitEvent(event, cancel);
@ -571,9 +574,19 @@ public:
// Socket thread only
void SetRequestTokenBucket(EventTokenBucket *aTokenBucket)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
mRequestTokenBucket = aTokenBucket;
}
void StopRequestTokenBucket()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
if (mRequestTokenBucket) {
mRequestTokenBucket->Stop();
mRequestTokenBucket = nullptr;
}
}
private:
RefPtr<Tickler> mWifiTickler;
void TickleWifi(nsIInterfaceRequestor *cb);