fix 104020 and 119592 problems with sending offline notification after socket transport shutdown so add a new notification sent before that r=ccarlen sr=sspitzer a=asa

This commit is contained in:
bienvenu%netscape.com 2002-03-08 14:51:00 +00:00
parent cec282695c
commit 6bb9918106
3 changed files with 12 additions and 7 deletions

View File

@ -89,7 +89,7 @@
#define ACCOUNT_PREFIX "account"
#define SERVER_PREFIX "server"
#define ID_PREFIX "id"
#define OFFLINE_STATUS_CHANGED_TOPIC "network:offline-status-changed"
#define ABOUT_TO_GO_OFFLINE_TOPIC "network:offline-about-to-go-offline"
static NS_DEFINE_CID(kMsgAccountCID, NS_MSGACCOUNT_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
@ -164,7 +164,7 @@ nsMsgAccountManager::~nsMsgAccountManager()
if (NS_SUCCEEDED(rv))
{
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
observerService->RemoveObserver(this, "network:offline-status-changed");
observerService->RemoveObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC);
}
}
}
@ -187,7 +187,7 @@ nsresult nsMsgAccountManager::Init()
{
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
observerService->AddObserver(this, "quit-application" , PR_TRUE);
observerService->AddObserver(this, "network:offline-status-changed", PR_TRUE);
observerService->AddObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC, PR_TRUE);
observerService->AddObserver(this, "session-logout", PR_TRUE);
observerService->AddObserver(this, "profile-before-change", PR_TRUE);
}
@ -243,7 +243,7 @@ NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const char *aT
return NS_OK;
}
if (!nsCRT::strcmp(aTopic,"network:offline-status-changed"))
if (!nsCRT::strcmp(aTopic, ABOUT_TO_GO_OFFLINE_TOPIC))
{
nsAutoString dataString(NS_LITERAL_STRING("offline"));
if (someData)

View File

@ -84,8 +84,6 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID);
#define OFFLINE_STATUS_CHANGED_TOPIC "network:offline-status-changed"
#define PORT_NOT_SET -1
MOZ_DECL_CTOR_COUNTER(nsMsgIncomingServer)

View File

@ -791,7 +791,14 @@ nsIOService::SetOffline(PRBool offline)
nsresult rv1 = NS_OK;
nsresult rv2 = NS_OK;
if (offline) {
NS_NAMED_LITERAL_STRING(offlineString, "offline");
mOffline = PR_TRUE; // indicate we're trying to shutdown
// don't care if notification fails
if (observerService)
// this allows users to attempt a little cleanup before dns and socket transport are shut down.
(void)observerService->NotifyObservers(NS_STATIC_CAST(nsIIOService *, this),
"network:offline-about-to-go-offline",
offlineString.get());
// be sure to try and shutdown both (even if the first fails)
if (mDNSService)
rv1 = mDNSService->Shutdown(); // shutdown dns service first, because it has callbacks for socket transport
@ -804,7 +811,7 @@ nsIOService::SetOffline(PRBool offline)
if (observerService)
(void)observerService->NotifyObservers(NS_STATIC_CAST(nsIIOService *, this),
"network:offline-status-changed",
NS_LITERAL_STRING("offline").get());
offlineString.get());
}
else if (!offline && mOffline) {
// go online