Bug 669151 - LDAP connections are not cleaned up until shutdown; r=bienvenu,a=Standard8 BETA_BASE_20110705
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 05 Jul 2011 15:58:07 +0100
changeset 7930 0d7f09a3495b0bcd96419ee6c9f54e02bf2a5b23
parent 7929 709cca34605481c91630b4ecac1314fe43d9e0a5
child 7931 1be20a148a24cc3c03c6af2c0301901c913f89e2
push id36
push userbugzilla@standard8.plus.com
push dateTue, 05 Jul 2011 19:03:23 +0000
treeherdercomm-beta@90e2a8a9bf0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu, Standard8
bugs669151
Bug 669151 - LDAP connections are not cleaned up until shutdown; r=bienvenu,a=Standard8
ldap/xpcom/src/nsLDAPConnection.cpp
--- a/ldap/xpcom/src/nsLDAPConnection.cpp
+++ b/ldap/xpcom/src/nsLDAPConnection.cpp
@@ -71,26 +71,25 @@ const char kDNSServiceContractId[] = "@m
 // constructor
 //
 nsLDAPConnection::nsLDAPConnection()
     : mConnectionHandle(0),
       mSSL(PR_FALSE),
       mVersion(nsILDAPConnection::VERSION3),
       mDNSRequest(0)
 {
-  // We have to abort all LDAP pending operation before shutdown.
-  nsCOMPtr<nsIObserverService> obsServ =
-      mozilla::services::GetObserverService();
-  obsServ->AddObserver(this, "profile-change-net-teardown", PR_FALSE);
 }
 
 // destructor
 //
 nsLDAPConnection::~nsLDAPConnection()
 {
+  nsCOMPtr<nsIObserverService> obsServ =
+      mozilla::services::GetObserverService();
+  obsServ->RemoveObserver(this, "profile-change-net-teardown");
   Close();
 }
 
 NS_IMPL_THREADSAFE_ADDREF(nsLDAPConnection)
 NS_IMPL_THREADSAFE_RELEASE(nsLDAPConnection)
 NS_IMPL_CLASSINFO(nsLDAPConnection, NULL, nsIClassInfo::THREADSAFE,
                   NS_LDAPCONNECTION_CID)
 
@@ -109,16 +108,22 @@ NS_IMPL_CI_INTERFACE_GETTER4(nsLDAPConne
 NS_IMETHODIMP
 nsLDAPConnection::Init(nsILDAPURL *aUrl, const nsACString &aBindName,
                        nsILDAPMessageListener *aMessageListener,
                        nsISupports *aClosure, PRUint32 aVersion)
 {
   NS_ENSURE_ARG_POINTER(aUrl);
   NS_ENSURE_ARG_POINTER(aMessageListener);
 
+  nsCOMPtr<nsIObserverService> obsServ =
+      mozilla::services::GetObserverService();
+
+  // We have to abort all LDAP pending operation before shutdown.
+  obsServ->AddObserver(this, "profile-change-net-teardown", PR_TRUE);
+
   // Save various items that we'll use later
   mBindName.Assign(aBindName);
   mClosure = aClosure;
   mInitListener = aMessageListener;
 
   // Make sure we haven't called Init earlier, i.e. there's a DNS
   // request pending.
   NS_ASSERTION(!mDNSRequest, "nsLDAPConnection::Init() "