[rhmessaging-commits] rhmessaging commits: r1386 - store/trunk/cpp/lib.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Nov 29 05:19:28 EST 2007


Author: gordonsim
Date: 2007-11-29 05:19:28 -0500 (Thu, 29 Nov 2007)
New Revision: 1386

Modified:
   store/trunk/cpp/lib/BdbMessageStore.cpp
Log:
Initial (temporary?) fix for deadlocking in bdbstore.



Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp	2007-11-29 09:57:11 UTC (rev 1385)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp	2007-11-29 10:19:28 UTC (rev 1386)
@@ -1130,6 +1130,22 @@
 
 bool BdbMessageStore::dequeue(DbTxn* txn, Dbt& messageId, Dbt& queueId)
 {
+    //need to get a lock on the messageDb in case we want to delete
+    //(to avoid deadlocks with enqueue that acquires locks in this
+    //order)
+    Dbt peek;
+    peek.set_flags(DB_DBT_USERMEM);
+    peek.set_ulen(0);
+    try {
+        int status = messageDb.get(txn, &messageId, &peek, DB_RMW);
+        if (status != DB_BUFFER_SMALL) {
+            THROW_STORE_EXCEPTION("Unexpected status code when peeking at message: " + string(DbEnv::strerror(status)));
+        }
+    } catch (DbMemoryException& expected) {
+        //api doc indicates may throw exception instead of status = DB_BUFFER_SMALL;
+    }
+
+
     Cursor cursor;
     cursor.open(mappingDb, txn);
 




More information about the rhmessaging-commits mailing list