You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2007/12/05 17:19:33 UTC

svn commit: r601391 - /incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp

Author: gsim
Date: Wed Dec  5 08:19:32 2007
New Revision: 601391

URL: http://svn.apache.org/viewvc?rev=601391&view=rev
Log:
Avoid holding lock while making the flush calls (can cause deadlocking)


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp?rev=601391&r1=601390&r2=601391&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp Wed Dec  5 08:19:32 2007
@@ -28,12 +28,18 @@
 
 void PersistableMessage::flush()
 {
-    sys::ScopedLock<sys::Mutex> l(storeLock);
-    if (store) {
-        for (syncList::iterator i = synclist.begin(); i != synclist.end(); ++i) {
-            store->flush(*(*i));
-        } 
+    syncList copy;
+    {
+        sys::ScopedLock<sys::Mutex> l(storeLock);
+	if (store) {
+	    copy = synclist;
+	} else {
+            return;//early exit as nothing to do
+	}
     }
+    for (syncList::iterator i = copy.begin(); i != copy.end(); ++i) {
+        store->flush(*(*i));
+    } 
 }