Bug 1242755 - Move nsHttpConnectionMgr->Shutdown back to nsHttpHandler. r=mcmanus

--HG--
extra : rebase_source : 762aa4b8f1e03c7422cd9416dfb724ac8926820d
This commit is contained in:
Dragana Damjanovic dd.mozilla@gmail.com 2016-02-04 04:14:00 +01:00
Родитель ebcfc8628c
Коммит 483a342274
3 изменённых файлов: 35 добавлений и 11 удалений

Просмотреть файл

@ -51,7 +51,6 @@
#include "CaptivePortalService.h"
#include "ReferrerPolicy.h"
#include "nsContentSecurityManager.h"
#include "nsHttpHandler.h"
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
@ -65,7 +64,6 @@
using namespace mozilla;
using mozilla::net::IsNeckoChild;
using mozilla::net::CaptivePortalService;
using mozilla::net::gHttpHandler;
#define PORT_PREF_PREFIX "network.security.ports."
#define PORT_PREF(x) PORT_PREF_PREFIX x
@ -182,6 +180,7 @@ nsIOService::nsIOService()
, mSettingOffline(false)
, mSetOfflineValue(false)
, mShutdown(false)
, mHttpHandlerAlreadyShutingDown(false)
, mNetworkLinkServiceInitialized(false)
, mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY)
, mAutoDialEnabled(false)
@ -1407,6 +1406,15 @@ nsIOService::NotifyWakeup()
return NS_OK;
}
void
nsIOService::SetHttpHandlerAlreadyShutingDown()
{
if (!mShutdown && !mOfflineForProfileChange) {
mNetTearingDownStarted = PR_IntervalNow();
mHttpHandlerAlreadyShutingDown = true;
}
}
// nsIObserver interface
NS_IMETHODIMP
nsIOService::Observe(nsISupports *subject,
@ -1418,12 +1426,12 @@ nsIOService::Observe(nsISupports *subject,
if (prefBranch)
PrefsChanged(prefBranch, NS_ConvertUTF16toUTF8(data).get());
} else if (!strcmp(topic, kProfileChangeNetTeardownTopic)) {
if (!mHttpHandlerAlreadyShutingDown) {
mNetTearingDownStarted = PR_IntervalNow();
}
mHttpHandlerAlreadyShutingDown = false;
if (!mOffline) {
mOfflineForProfileChange = true;
mNetTearingDownStarted = PR_IntervalNow();
if (gHttpHandler) {
gHttpHandler->ShutdownConnectionManager();
}
SetOffline(true);
}
} else if (!strcmp(topic, kProfileChangeNetRestoreTopic)) {
@ -1449,12 +1457,12 @@ nsIOService::Observe(nsISupports *subject,
// changes of the offline status from now. We must not allow going
// online after this point.
mShutdown = true;
if (!mOfflineForProfileChange) {
if (!mHttpHandlerAlreadyShutingDown && !mOfflineForProfileChange) {
mNetTearingDownStarted = PR_IntervalNow();
}
if (gHttpHandler) {
gHttpHandler->ShutdownConnectionManager();
}
mHttpHandlerAlreadyShutingDown = false;
SetOffline(true);
if (mCaptivePortalService) {

Просмотреть файл

@ -84,8 +84,17 @@ public:
PRIntervalTime LastOfflineStateChange() { return mLastOfflineStateChange; }
PRIntervalTime LastConnectivityChange() { return mLastConnectivityChange; }
PRIntervalTime LastNetworkLinkChange() { return mLastNetworkLinkChange; }
bool IsNetTearingDown() { return mShutdown || mOfflineForProfileChange; }
bool IsNetTearingDown() { return mShutdown || mOfflineForProfileChange ||
mHttpHandlerAlreadyShutingDown; }
PRIntervalTime NetTearingDownStarted() { return mNetTearingDownStarted; }
// nsHttpHandler is going to call this function to inform nsIOService that network
// is in process of tearing down. Moving nsHttpConnectionMgr::Shutdown to nsIOService
// caused problems (bug 1242755) so we doing it in this way.
// As soon as nsIOService gets notification that it is shutdown it is going to
// reset mHttpHandlerAlreadyShutingDown.
void SetHttpHandlerAlreadyShutingDown();
bool IsLinkUp();
// Should only be called from NeckoChild. Use SetAppOffline instead.
@ -152,6 +161,7 @@ private:
bool mSetOfflineValue;
mozilla::Atomic<bool, mozilla::Relaxed> mShutdown;
mozilla::Atomic<bool, mozilla::Relaxed> mHttpHandlerAlreadyShutingDown;
nsCOMPtr<nsPISocketTransportService> mSocketTransportService;
nsCOMPtr<nsPIDNSService> mDNSService;

Просмотреть файл

@ -53,6 +53,7 @@
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsSocketTransportService2.h"
#include "nsIOService.h"
#include "mozilla/net/NeckoChild.h"
#include "mozilla/ipc/URIUtils.h"
@ -2060,6 +2061,11 @@ nsHttpHandler::Observe(nsISupports *subject,
if (mWifiTickler)
mWifiTickler->Cancel();
// Inform nsIOService that network is tearing down.
gIOService->SetHttpHandlerAlreadyShutingDown();
ShutdownConnectionManager();
// need to reset the session start time since cache validation may
// depend on this value.
mSessionStartTime = NowInSeconds();