mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 474434 - Active ftp sessions are not closed when clearing recent history; r=bzbarsky sr=cbiesinger
This commit is contained in:
parent
7afd1bbd24
commit
5e7c0ee5dd
@ -327,10 +327,10 @@ Sanitizer.prototype = {
|
||||
.getService(Components.interfaces.nsISecretDecoderRing);
|
||||
sdr.logoutAndTeardown();
|
||||
|
||||
// clear plain HTTP auth sessions
|
||||
var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1']
|
||||
.getService(Components.interfaces.nsIHttpAuthManager);
|
||||
authMgr.clearAll();
|
||||
// clear FTP and plain HTTP auth sessions
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.notifyObservers(null, "net:clear-active-logins", null);
|
||||
},
|
||||
|
||||
get canClear()
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
#include "nsFTPChannel.h"
|
||||
#include "nsFtpControlConnection.h"
|
||||
#include "nsFtpProtocolHandler.h"
|
||||
#include "prlog.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsIInputStream.h"
|
||||
@ -95,8 +96,10 @@ nsFtpControlConnection::OnInputStreamReady(nsIAsyncInputStream *stream)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsFtpControlConnection::nsFtpControlConnection(const nsCSubstring& host, PRUint32 port)
|
||||
: mServerType(0), mHost(host), mPort(port)
|
||||
nsFtpControlConnection::nsFtpControlConnection(const nsCSubstring& host,
|
||||
PRUint32 port)
|
||||
: mServerType(0), mSessionId(gFtpHandler->GetSessionId()), mHost(host)
|
||||
, mPort(port)
|
||||
{
|
||||
LOG_ALWAYS(("FTP:CC created @%p", this));
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ public:
|
||||
nsString mPassword;
|
||||
PRInt32 mSuspendedWrite;
|
||||
nsCString mPwd;
|
||||
PRUint32 mSessionId;
|
||||
|
||||
private:
|
||||
nsCString mHost;
|
||||
|
@ -94,6 +94,7 @@ nsFtpProtocolHandler *gFtpHandler = nsnull;
|
||||
|
||||
nsFtpProtocolHandler::nsFtpProtocolHandler()
|
||||
: mIdleTimeout(-1)
|
||||
, mSessionId(0)
|
||||
{
|
||||
#if defined(PR_LOGGING)
|
||||
if (!gFTPLog)
|
||||
@ -138,11 +139,16 @@ nsFtpProtocolHandler::Init()
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (observerService)
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this,
|
||||
"network:offline-about-to-go-offline",
|
||||
PR_TRUE);
|
||||
|
||||
|
||||
observerService->AddObserver(this,
|
||||
"net:clear-active-logins",
|
||||
PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -295,7 +301,10 @@ nsFtpProtocolHandler::InsertConnection(nsIURI *aKey, nsFtpControlConnection *aCo
|
||||
{
|
||||
NS_ASSERTION(aConn, "null pointer");
|
||||
NS_ASSERTION(aKey, "null pointer");
|
||||
|
||||
|
||||
if (aConn->mSessionId != mSessionId)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString spec;
|
||||
aKey->GetPrePath(spec);
|
||||
|
||||
@ -375,13 +384,22 @@ nsFtpProtocolHandler::Observe(nsISupports *aSubject,
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mIdleTimeout = timeout;
|
||||
} else if (!strcmp(aTopic, "network:offline-about-to-go-offline")) {
|
||||
PRUint32 i;
|
||||
for (i=0;i<mRootConnectionList.Length();++i)
|
||||
delete mRootConnectionList[i];
|
||||
mRootConnectionList.Clear();
|
||||
ClearAllConnections();
|
||||
} else if (!strcmp(aTopic, "net:clear-active-logins")) {
|
||||
ClearAllConnections();
|
||||
mSessionId++;
|
||||
} else {
|
||||
NS_NOTREACHED("unexpected topic");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsFtpProtocolHandler::ClearAllConnections()
|
||||
{
|
||||
PRUint32 i;
|
||||
for (i=0;i<mRootConnectionList.Length();++i)
|
||||
delete mRootConnectionList[i];
|
||||
mRootConnectionList.Clear();
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
// FTP Connection list access
|
||||
nsresult InsertConnection(nsIURI *aKey, nsFtpControlConnection *aConn);
|
||||
nsresult RemoveConnection(nsIURI *aKey, nsFtpControlConnection **aConn);
|
||||
PRUint32 GetSessionId() { return mSessionId; }
|
||||
|
||||
private:
|
||||
// Stuff for the timer callback function
|
||||
@ -97,11 +98,19 @@ private:
|
||||
};
|
||||
|
||||
static void Timeout(nsITimer *aTimer, void *aClosure);
|
||||
void ClearAllConnections();
|
||||
|
||||
nsTArray<timerStruct*> mRootConnectionList;
|
||||
|
||||
nsCOMPtr<nsICacheSession> mCacheSession;
|
||||
PRInt32 mIdleTimeout;
|
||||
|
||||
// When "clear active logins" is performed, all idle connection are dropped
|
||||
// and mSessionId is incremented. When nsFtpState wants to insert idle
|
||||
// connection we refuse to cache if its mSessionId is different (i.e.
|
||||
// control connection had been created before last "clear active logins" was
|
||||
// performed.
|
||||
PRUint32 mSessionId;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -284,6 +284,7 @@ nsHttpHandler::Init()
|
||||
mObserverService->AddObserver(this, "profile-change-net-teardown", PR_TRUE);
|
||||
mObserverService->AddObserver(this, "profile-change-net-restore", PR_TRUE);
|
||||
mObserverService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
mObserverService->AddObserver(this, "net:clear-active-logins", PR_TRUE);
|
||||
}
|
||||
|
||||
StartPruneDeadConnectionsTimer();
|
||||
@ -1727,6 +1728,9 @@ nsHttpHandler::Observe(nsISupports *subject,
|
||||
if (mConnMgr)
|
||||
mConnMgr->PruneDeadConnections();
|
||||
}
|
||||
else if (strcmp(topic, "net:clear-active-logins") == 0) {
|
||||
mAuthCache.ClearAll();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user