qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r601391 - /incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PersistableMessage.cpp
Date Wed, 05 Dec 2007 16:19:33 GMT
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));
+    } 
 }
 
     



Mime
View raw message