Bug 1211001 - constant ASSERTION: nsITimer->SetDelay() called when the one-shot timer is not set up, r=mcmanus

This commit is contained in:
Michal Novotny 2015-10-08 00:32:18 +02:00
parent d12bfed3c9
commit 05dff5829e
2 changed files with 16 additions and 11 deletions

View File

@ -3072,16 +3072,14 @@ WebSocketChannel::Notify(nsITimer *timer)
}
if (!mPingOutstanding) {
// Allow for the case where a PING was force-sent even though ping
// interval isn't enabled. Only issue a new PING if it truly is enabled.
if (mPingInterval || mPingForced) {
LOG(("nsWebSocketChannel:: Generating Ping\n"));
mPingOutstanding = 1;
mPingForced = 0;
GeneratePing();
mPingTimer->InitWithCallback(this, mPingResponseTimeout,
nsITimer::TYPE_ONE_SHOT);
}
// Ping interval must be non-null or PING was forced by OnNetworkChanged()
MOZ_ASSERT(mPingInterval || mPingForced);
LOG(("nsWebSocketChannel:: Generating Ping\n"));
mPingOutstanding = 1;
mPingForced = 0;
GeneratePing();
mPingTimer->InitWithCallback(this, mPingResponseTimeout,
nsITimer::TYPE_ONE_SHOT);
} else {
LOG(("nsWebSocketChannel:: Timed out Ping\n"));
mPingTimer = nullptr;

View File

@ -178,7 +178,14 @@ private:
{
mPingOutstanding = 0;
if (mPingTimer) {
mPingTimer->SetDelay(mPingInterval);
if (!mPingInterval) {
// The timer was created by forced ping and regular pinging is disabled,
// so cancel and null out mPingTimer.
mPingTimer->Cancel();
mPingTimer = nullptr;
} else {
mPingTimer->SetDelay(mPingInterval);
}
}
}