Bug 1079311 - Unlock mutex before logging error in RegisterContractIDLocked. r=bsmedberg
authorBrian Marshall <bmarsd@gmail.com>
Wed, 08 Oct 2014 16:08:28 -0700
changeset 210361 64aa0ab1f87b4823e32ccc5c81007868dc1ddfd4
parent 210360 a19c2e8143cb4099f594fcc77418f0fc69914cbc
child 210362 307181c1de8e61875ec22084b53b8f4c9328a25f
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbsmedberg
bugs1079311
milestone36.0a1
Bug 1079311 - Unlock mutex before logging error in RegisterContractIDLocked. r=bsmedberg
xpcom/components/nsComponentManager.cpp
xpcom/tests/component/TestComponent.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -558,21 +558,22 @@ nsComponentManagerImpl::RegisterContract
   mLock.AssertCurrentThreadOwns();
 
   if (!ProcessSelectorMatches(aEntry->processSelector)) {
     return;
   }
 
   nsFactoryEntry* f = mFactories.Get(*aEntry->cid);
   if (!f) {
-    NS_ERROR("No CID found when attempting to map contract ID");
+    NS_WARNING("No CID found when attempting to map contract ID");
 
     char idstr[NSID_LENGTH];
     aEntry->cid->ToProvidedString(idstr);
 
+    SafeMutexAutoUnlock unlock(mLock);
     LogMessage("Could not map contract ID '%s' to CID %s because no implementation of the CID is registered.",
                aEntry->contractid,
                idstr);
 
     return;
   }
 
   mContractIDs.Put(nsDependentCString(aEntry->contractid), f);
--- a/xpcom/tests/component/TestComponent.cpp
+++ b/xpcom/tests/component/TestComponent.cpp
@@ -3,31 +3,41 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ModuleUtils.h"
 
 #define NS_TESTING_CID \
 { 0x335fb596, 0xe52d, 0x418f, \
   { 0xb0, 0x1c, 0x1b, 0xf1, 0x6c, 0xe5, 0xe7, 0xe4 } }
+#define NS_NONEXISTENT_CID \
+{ 0x1e61fb15, 0xead4, 0x45cd, \
+  { 0x80, 0x13, 0x40, 0x99, 0xa7, 0x10, 0xa2, 0xfa } }
 
 NS_DEFINE_NAMED_CID(NS_TESTING_CID);
+NS_DEFINE_NAMED_CID(NS_NONEXISTENT_CID);
 
 static nsresult
 DummyConstructorFunc(nsISupports* aOuter, const nsIID& aIID, void** aResult)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 static const mozilla::Module::CIDEntry kTestCIDs[] = {
   { &kNS_TESTING_CID, false, nullptr, DummyConstructorFunc },
   { &kNS_TESTING_CID, false, nullptr, DummyConstructorFunc },
   { nullptr }
 };
 
+static const mozilla::Module::ContractIDEntry kTestContractIDs[] = {
+  { "@testing/foo", &kNS_NONEXISTENT_CID },
+  { nullptr }
+};
+
 static const mozilla::Module kTestModule = {
   mozilla::Module::kVersion,
-  kTestCIDs
+  kTestCIDs,
+  kTestContractIDs
 };
 
 NSMODULE_DEFN(dummy) = &kTestModule;