Bug 462497 - nsComponentManagerImpl::HashContractID() reenters mMon; r=benjamin
authorSergey Yanovich <ynvich@gmail.com>
Sat, 20 Dec 2008 02:21:04 +0100
changeset 22970 8b5a38ba459a9f2e3ead5def89d09492fdacc94d
parent 22969 d29b48d75da176d2c1720c02a99bfe5034e5f5a2
child 22971 09cfc25615d337a2cecc61ccb6ec2b79735a0413
child 22973 efe3c6f76bca38763cebf51a26460b6ab2bc4195
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs462497
milestone1.9.2a1pre
Bug 462497 - nsComponentManagerImpl::HashContractID() reenters mMon; r=benjamin
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -1293,17 +1293,17 @@ out:
 nsresult
 nsComponentManagerImpl::HashContractID(const char *aContractID,
                                        PRUint32 aContractIDLen,
                                        nsFactoryEntry *fe)
 {
     if(!aContractID || !aContractIDLen)
         return NS_ERROR_NULL_POINTER;
 
-    nsAutoMonitor mon(mMon);
+    NS_ASSERTION(PR_GetMonitorEntryCount(mMon), "called from outside mMon");
 
     nsContractIDTableEntry* contractIDTableEntry =
         static_cast<nsContractIDTableEntry*>
                    (PL_DHashTableOperate(&mContractIDs, aContractID,
                                             PL_DHASH_ADD));
     if (!contractIDTableEntry)
         return NS_ERROR_OUT_OF_MEMORY;
 
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -208,16 +208,19 @@ public:
     nsresult FindFactory(const char *contractID, PRUint32 aContractIDLen, nsIFactory **aFactory) ;
     nsresult LoadFactory(nsFactoryEntry *aEntry, nsIFactory **aFactory);
 
     nsFactoryEntry *GetFactoryEntry(const char *aContractID,
                                     PRUint32 aContractIDLen);
     nsFactoryEntry *GetFactoryEntry(const nsCID &aClass);
 
     nsresult SyncComponentsInDir(PRInt32 when, nsIFile *dirSpec);
+
+    // NOTE: HashContractID operates on the hash table with ContractIDs,
+    // for thread-safety it should only be invoked from inside mMon.
     nsresult HashContractID(const char *acontractID, PRUint32 aContractIDLen,
                             nsFactoryEntry *fe_ptr);
 
     void DeleteContractIDEntriesByCID(const nsCID* aClass, nsIFactory* factory);
     nsresult AutoRegisterImpl(nsIFile*                  inDirSpec,
                               nsCOMArray<nsILocalFile> &aLeftovers,
                               nsTArray<DeferredModule> &aDeferred);
     nsresult AutoRegisterDirectory(nsIFile*                  aComponentFile,