Move AddRef to before the unlock. (Bug 650674, patch 2) r=bsmedberg
authorL. David Baron <dbaron@dbaron.org>
Wed, 20 Apr 2011 14:29:45 -0700
changeset 68375 127b9421c7c343df214249e347d5ee94afbbe6c2
parent 68374 772d6e702817cb9c5769262809571d8375fd4084
child 68376 48893035944cda590191702aafd86fbd7e3e735e
push id19613
push userdbaron@mozilla.com
push dateWed, 20 Apr 2011 21:30:12 +0000
treeherdermozilla-central@127b9421c7c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs650674
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Move AddRef to before the unlock. (Bug 650674, patch 2) r=bsmedberg
xpcom/proxy/src/nsProxyEvent.cpp
--- a/xpcom/proxy/src/nsProxyEvent.cpp
+++ b/xpcom/proxy/src/nsProxyEvent.cpp
@@ -470,25 +470,27 @@ nsProxyObject::LockedFind(REFNSIID aIID,
             return rv;
         }
     }
 
     // Now that we're locked again, check for races by repeating the
     // linked-list check.
     for (peo = mFirst; peo; peo = peo->mNext) {
         if (peo->GetClass()->GetProxiedIID().Equals(aIID)) {
+            // Best to AddRef for our caller before unlocking.
+            peo->LockedAddRef();
+
             {
                 // Deleting an nsProxyEventObject can call Release on an
                 // nsProxyObject, which can only happen when not holding
                 // the lock.
                 MutexAutoUnlock unlock(pom->GetLock());
                 delete newpeo;
             }
             *aResult = static_cast<nsISupports*>(peo->mXPTCStub);
-            peo->LockedAddRef();
             return NS_OK;
         }
     }
 
     newpeo->mNext = mFirst;
     mFirst = newpeo;
 
     newpeo->LockedAddRef();