You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Jim Meyering <ji...@meyering.net> on 2007/01/10 18:47:47 UTC

C++: FYI: bdbstore now passes its tests

The 108-based bdbstore shared library module now works with qpidd -s
and passes its self tests.  I've just checked in this change:

	system_test.sh didn't work at all (would seg-fault)
	* lib/BdbMessageStore.cpp: Comment out all attempts to write
	diagnostics to std::cout.  A shared library must not do that,
	and this one would segfault when invoked via qpidd -s ....
	(~BdbMessageStore): Rather than simply writing to std::cout,
	re-throw any close-provoked exception.

Index: lib/BdbMessageStore.cpp
===================================================================
--- lib/BdbMessageStore.cpp	(revision 673)
+++ lib/BdbMessageStore.cpp	(working copy)
@@ -67,10 +67,10 @@

         txn.commit();
     } catch (DbException& e) {
-        std::cout << "Error opening databases: " << e.what() << std::endl;
+        // std::cout << "Error opening databases: " << e.what() << std::endl;
         THROW_STORE_EXCEPTION_2("Error opening databases", e);
     } catch (std::exception& e) {
-        std::cout << "Error opening databases: " << e.what() << std::endl;
+        // std::cout << "Error opening databases: " << e.what() << std::endl;
         throw e;
     }
 }
@@ -85,9 +85,11 @@
         dequeueXidDb.close(0);
         prepareXidDb.close(0);
     } catch (DbException& e) {
-        std::cout << "Error closing databases: " << e.what() << std::endl;
+        // std::cout << "Error closing databases: " << e.what() << std::endl;
+        THROW_STORE_EXCEPTION_2("Error closing databases", e);
     } catch (std::exception& e) {
-        std::cout << "Error closing databases: " << e.what() << std::endl;
+        // std::cout << "Error closing databases: " << e.what() << std::endl;
+        throw e;
     }   
 }

@@ -239,7 +241,7 @@
         //find all the queues into which this message has been enqueued
         if (enqueueMessage(key, msg, index) == 0) {
             //message not referenced anywhere - can delete
-            std::cout << "Deleting unused message " << id << std::endl;
+            // std::cout << "Deleting unused message " << id << std::endl;
             messages->del(0);
         } else {
             if (id > maxMessageId) {
@@ -265,7 +267,7 @@
     for (int status = mappings->get(&msgId, &value, DB_SET); status == 0; status = mappings->get(&msgId, &value, DB_NEXT_DUP)) {
         Queue::shared_ptr queue = index[queueId];
         if (!queue) {
-            std::cout << "Missing queue for id: " << queueId << std::endl;
+            // std::cout << "Missing queue for id: " << queueId << std::endl;
             THROW_STORE_EXCEPTION("Missing queue");
         }
         queue->recover(msg);
@@ -605,13 +607,13 @@

 extern "C" MessageStore* create()
 {
-    std::cout << "creating BdbMessageStore" <<std::endl;
+    // std::cout << "creating BdbMessageStore" <<std::endl;
     return new BdbMessageStore();
 }

 extern "C" void destroy(MessageStore* store)
 {
-    std::cout << "destroying BdbMessageStore" <<std::endl;
+    // std::cout << "destroying BdbMessageStore" <<std::endl;
     delete store;
 }


Re: C++: FYI: bdbstore now passes its tests

Posted by Carl Trieloff <cc...@redhat.com>.
Thanks, I merge this.
Carl.

Jim Meyering wrote:
> The 108-based bdbstore shared library module now works with qpidd -s
> and passes its self tests.  I've just checked in this change:
>
> 	system_test.sh didn't work at all (would seg-fault)
> 	* lib/BdbMessageStore.cpp: Comment out all attempts to write
> 	diagnostics to std::cout.  A shared library must not do that,
> 	and this one would segfault when invoked via qpidd -s ....
> 	(~BdbMessageStore): Rather than simply writing to std::cout,
> 	re-throw any close-provoked exception.
>
> Index: lib/BdbMessageStore.cpp
> ===================================================================
> --- lib/BdbMessageStore.cpp	(revision 673)
> +++ lib/BdbMessageStore.cpp	(working copy)
> @@ -67,10 +67,10 @@
>
>          txn.commit();
>      } catch (DbException& e) {
> -        std::cout << "Error opening databases: " << e.what() << std::endl;
> +        // std::cout << "Error opening databases: " << e.what() << std::endl;
>          THROW_STORE_EXCEPTION_2("Error opening databases", e);
>      } catch (std::exception& e) {
> -        std::cout << "Error opening databases: " << e.what() << std::endl;
> +        // std::cout << "Error opening databases: " << e.what() << std::endl;
>          throw e;
>      }
>  }
> @@ -85,9 +85,11 @@
>          dequeueXidDb.close(0);
>          prepareXidDb.close(0);
>      } catch (DbException& e) {
> -        std::cout << "Error closing databases: " << e.what() << std::endl;
> +        // std::cout << "Error closing databases: " << e.what() << std::endl;
> +        THROW_STORE_EXCEPTION_2("Error closing databases", e);
>      } catch (std::exception& e) {
> -        std::cout << "Error closing databases: " << e.what() << std::endl;
> +        // std::cout << "Error closing databases: " << e.what() << std::endl;
> +        throw e;
>      }   
>  }
>
> @@ -239,7 +241,7 @@
>          //find all the queues into which this message has been enqueued
>          if (enqueueMessage(key, msg, index) == 0) {
>              //message not referenced anywhere - can delete
> -            std::cout << "Deleting unused message " << id << std::endl;
> +            // std::cout << "Deleting unused message " << id << std::endl;
>              messages->del(0);
>          } else {
>              if (id > maxMessageId) {
> @@ -265,7 +267,7 @@
>      for (int status = mappings->get(&msgId, &value, DB_SET); status == 0; status = mappings->get(&msgId, &value, DB_NEXT_DUP)) {
>          Queue::shared_ptr queue = index[queueId];
>          if (!queue) {
> -            std::cout << "Missing queue for id: " << queueId << std::endl;
> +            // std::cout << "Missing queue for id: " << queueId << std::endl;
>              THROW_STORE_EXCEPTION("Missing queue");
>          }
>          queue->recover(msg);
> @@ -605,13 +607,13 @@
>
>  extern "C" MessageStore* create()
>  {
> -    std::cout << "creating BdbMessageStore" <<std::endl;
> +    // std::cout << "creating BdbMessageStore" <<std::endl;
>      return new BdbMessageStore();
>  }
>
>  extern "C" void destroy(MessageStore* store)
>  {
> -    std::cout << "destroying BdbMessageStore" <<std::endl;
> +    // std::cout << "destroying BdbMessageStore" <<std::endl;
>      delete store;
>  }
>
>