r7943 - /trunk/licq/src/plugins/pluginmanager.cpp

[email protected]
Newsgroups gmane.network.licq.cvs
Message-ID <20101024173416.0FEA2224B85@thejon>
Author: erijo
Date: Mon Oct 25 02:34:10 2010
New Revision: 7943

Log:
Changed lock order to please valgrind

Modified:
    trunk/licq/src/plugins/pluginmanager.cpp

Modified: trunk/licq/src/plugins/pluginmanager.cpp
==============================================================================
--- trunk/licq/src/plugins/pluginmanager.cpp (original)
+++ trunk/licq/src/plugins/pluginmanager.cpp Mon Oct 25 02:34:10 2010
@@ -226,30 +226,32 @@
   if (myGeneralPlugins.empty() && myProtocolPlugins.empty())
     LICQ_THROW(Licq::Exception());
 
-  MutexLocker exitListLocker(myExitListMutex);
   protocolLocker.unlock();
   generalLocker.unlock();
 
-  while (myExitList.empty())
-  {
-    if (timeout)
-    {
-      if (!myExitListSignal.wait(myExitListMutex, timeout * 1000))
-        LICQ_THROW(Licq::Exception());
-    }
-    else
-      myExitListSignal.wait(myExitListMutex);
-  }
-
-  unsigned short exitId = myExitList.front();
-  myExitList.pop();
+  unsigned short exitId;
+  {
+    MutexLocker exitListLocker(myExitListMutex);
+    while (myExitList.empty())
+    {
+      if (timeout)
+      {
+        if (!myExitListSignal.wait(myExitListMutex, timeout * 1000))
+          LICQ_THROW(Licq::Exception());
+      }
+      else
+        myExitListSignal.wait(myExitListMutex);
+    }
+
+    exitId = myExitList.front();
+    myExitList.pop();
+  }
+
+  if (exitId == DAEMON_ID)
+    return DAEMON_ID;
 
   generalLocker.relock();
   protocolLocker.relock();
-  exitListLocker.unlock();
-
-  if (exitId == DAEMON_ID)
-    return DAEMON_ID;
 
   // Check general plugins first
   for (GeneralPluginsList::iterator plugin = myGeneralPlugins.begin();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.