[PATCH 1/4] [mama] CPP Default queue tidy up


Ian Bell <IBell@...>
 

Attached new patch with bool instead of short

 

From b87a8a6a5fffc8ec23881863cb2aee0eccc1c521 Mon Sep 17 00:00:00 2001

Message-Id: <b87a8a6a5fffc8ec23881863cb2aee0eccc1c521.1349355876.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Thu, 4 Oct 2012 14:02:05 +0100

Subject: [PATCH] [mamacpp] CPP Default queue tidy up

 

Tidyup the cpp default queue wrapper to avoid memory leak / core on shutdown.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/cpp/MamaQueue.cpp    |   10 +++++++++-

mama/c_cpp/src/cpp/mama/MamaQueue.h |    2 ++

mama/c_cpp/src/cpp/mamacpp.cpp      |    4 ++--

3 files changed, 13 insertions(+), 3 deletions(-)

 

diff --git a/mama/c_cpp/src/cpp/MamaQueue.cpp b/mama/c_cpp/src/cpp/MamaQueue.cpp

index b5b41db..ec6ca3d 100644

--- a/mama/c_cpp/src/cpp/MamaQueue.cpp

+++ b/mama/c_cpp/src/cpp/MamaQueue.cpp

@@ -156,9 +156,11 @@ namespace Wombat

             : mClosure          (NULL)

             , mEnqueueCallback  (NULL)

                , mUserClosure      (NULL)

+             , mOwner                            (false)

         {

         }

+                             bool                                                                         mOwner;

         void*                     mClosure;

         MamaQueueEnqueueCallback* mEnqueueCallback;

         MamaQueueMonitorCallback* mMonitorCallback;

@@ -174,6 +176,11 @@ namespace Wombat

     {

     }

+             MamaQueue::MamaQueue (mamaQueue cQueue)

+        : mPimpl (new MamaQueueImpl)

+        , mQueue (cQueue)

+    {

+    }

     MamaQueue::~MamaQueue (void)

     {

         destroy ();

@@ -183,6 +190,7 @@ namespace Wombat

     void MamaQueue::create (mamaBridge bridgeImpl)

     {

         mamaTry (mamaQueue_create (&mQueue, bridgeImpl));

+                             mPimpl->mOwner=true;

     }

     void MamaQueue::create (mamaBridge  bridgeImpl,

@@ -470,7 +478,7 @@ namespace Wombat

     {        

         mama_status status = MAMA_STATUS_OK;

-        if (mQueue)

+        if ((mQueue) && (mPimpl->mOwner))

         {

            status = mamaQueue_destroy (mQueue);       

         }

diff --git a/mama/c_cpp/src/cpp/mama/MamaQueue.h b/mama/c_cpp/src/cpp/mama/MamaQueue.h

index b49ff43..019d880 100644

--- a/mama/c_cpp/src/cpp/mama/MamaQueue.h

+++ b/mama/c_cpp/src/cpp/mama/MamaQueue.h

@@ -23,6 +23,7 @@

#define MAMA_QUEUE_CPP_H__

 #include <mama/mamacpp.h>

+#include <mama/queue.h>

 namespace Wombat

 {

@@ -41,6 +42,7 @@ namespace Wombat

     public:

         MamaQueue          (void);

+        MamaQueue          (mamaQueue cQueue);

         virtual ~MamaQueue (void);

         /**

diff --git a/mama/c_cpp/src/cpp/mamacpp.cpp b/mama/c_cpp/src/cpp/mamacpp.cpp

index 7582ea2..86324e4 100644

--- a/mama/c_cpp/src/cpp/mamacpp.cpp

+++ b/mama/c_cpp/src/cpp/mamacpp.cpp

@@ -29,6 +29,7 @@

#include <string>

#include "MamaSubscriptionImpl.h"

#include <mama/queue.h>

+#include <mama/MamaQueue.h>

#include <mama/MamaReservedFields.h>

 namespace Wombat

@@ -289,8 +290,7 @@ namespace Wombat

             mamaQueue_getClosure (defaultQueueC, (void**)(&defaultQueue));

             if (defaultQueue == NULL)

             {

-                defaultQueue = new MamaQueue();

-                defaultQueue->setCValue(defaultQueueC);

+                defaultQueue = new MamaQueue(defaultQueueC);

                 mamaQueue_setClosure(defaultQueueC, (void*) defaultQueue);

             }

             return defaultQueue;

--

1.7.9.5

 

 

From: Glenn McClements
Sent: 04 October 2012 09:18
To: Ian Bell
Cc: openmama-dev@...
Subject: Re: [Openmama-dev] [PATCH 1/4] [mama] CPP Default queue tidy up

 

Ian,

Minor point. The C++ queue wrapper should be using bool not short for the mOwner flag. 

 

Glenn 

 

From: Ian Bell <ibell@...>
Date: Thu, 27 Sep 2012 08:01:39 +0000
To: "openmama-dev@..." <openmama-dev@...>
Subject: [Openmama-dev] [PATCH 1/4] [mama] CPP Default queue tidy up

 

From b3579c20edd49597fd58e530be463611e61515f0 Mon Sep 17 00:00:00 2001

Message-Id: <b3579c20edd49597fd58e530be463611e61515f0.1348732807.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Thu, 27 Sep 2012 08:41:41 +0100

Subject: [PATCH 1/4] [mama] CPP Default queue tidy up

 

Tidyup the cpp default queue wrapper to avoid memory leak /

core on shutdown.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/cpp/MamaQueue.cpp    |   10 +++++++++-

mama/c_cpp/src/cpp/mama/MamaQueue.h |    2 ++

mama/c_cpp/src/cpp/mamacpp.cpp      |    4 ++--

3 files changed, 13 insertions(+), 3 deletions(-)

 

diff --git a/mama/c_cpp/src/cpp/MamaQueue.cpp b/mama/c_cpp/src/cpp/MamaQueue.cpp

index b5b41db..abd880f 100644

--- a/mama/c_cpp/src/cpp/MamaQueue.cpp

+++ b/mama/c_cpp/src/cpp/MamaQueue.cpp

@@ -156,9 +156,11 @@ namespace Wombat

             : mClosure          (NULL)

             , mEnqueueCallback  (NULL)

                , mUserClosure      (NULL)

+             , mOwner                            (0)

         {

         }

+                             short                                                                       mOwner;

         void*                     mClosure;

         MamaQueueEnqueueCallback* mEnqueueCallback;

         MamaQueueMonitorCallback* mMonitorCallback;

@@ -174,6 +176,11 @@ namespace Wombat

     {

     }

+             MamaQueue::MamaQueue (mamaQueue cQueue)

+        : mPimpl (new MamaQueueImpl)

+        , mQueue (cQueue)

+    {

+    }

     MamaQueue::~MamaQueue (void)

     {

         destroy ();

@@ -183,6 +190,7 @@ namespace Wombat

     void MamaQueue::create (mamaBridge bridgeImpl)

     {

         mamaTry (mamaQueue_create (&mQueue, bridgeImpl));

+                             mPimpl->mOwner=1;

     }

     void MamaQueue::create (mamaBridge  bridgeImpl,

@@ -470,7 +478,7 @@ namespace Wombat

     {        

         mama_status status = MAMA_STATUS_OK;

-        if (mQueue)

+        if ((mQueue) && (mPimpl->mOwner))

         {

             status = mamaQueue_destroy (mQueue);       

         }

diff --git a/mama/c_cpp/src/cpp/mama/MamaQueue.h b/mama/c_cpp/src/cpp/mama/MamaQueue.h

index b49ff43..019d880 100644

--- a/mama/c_cpp/src/cpp/mama/MamaQueue.h

+++ b/mama/c_cpp/src/cpp/mama/MamaQueue.h

@@ -23,6 +23,7 @@

#define MAMA_QUEUE_CPP_H__

 #include <mama/mamacpp.h>

+#include <mama/queue.h>

 namespace Wombat

 {

@@ -41,6 +42,7 @@ namespace Wombat

     public:

         MamaQueue          (void);

+        MamaQueue          (mamaQueue cQueue);

         virtual ~MamaQueue (void);

         /**

diff --git a/mama/c_cpp/src/cpp/mamacpp.cpp b/mama/c_cpp/src/cpp/mamacpp.cpp

index 037f97b..6042e22 100644

--- a/mama/c_cpp/src/cpp/mamacpp.cpp

+++ b/mama/c_cpp/src/cpp/mamacpp.cpp

@@ -29,6 +29,7 @@

#include <string>

#include "MamaSubscriptionImpl.h"

#include <mama/queue.h>

+#include <mama/MamaQueue.h>

#include <mama/MamaReservedFields.h>

 namespace Wombat

@@ -283,8 +284,7 @@ namespace Wombat

             mamaQueue_getClosure (defaultQueueC, (void**)(&defaultQueue));

             if (defaultQueue == NULL)

             {

-                defaultQueue = new MamaQueue();

-                defaultQueue->setCValue(defaultQueueC);

+                defaultQueue = new MamaQueue(defaultQueueC);

                 mamaQueue_setClosure(defaultQueueC, (void*) defaultQueue);

             }

             return defaultQueue;

--

1.7.9.5

 

 



Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

_______________________________________________ Openmama-dev mailing list Openmama-dev@... https://lists.openmama.org/mailman/listinfo/openmama-dev




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


Glenn McClements <gmcclements@...>
 

Ian,
Minor point. The C++ queue wrapper should be using bool not short for the mOwner flag. 

Glenn 

From: Ian Bell <ibell@...>
Date: Thu, 27 Sep 2012 08:01:39 +0000
To: "openmama-dev@..." <openmama-dev@...>
Subject: [Openmama-dev] [PATCH 1/4] [mama] CPP Default queue tidy up

From b3579c20edd49597fd58e530be463611e61515f0 Mon Sep 17 00:00:00 2001

Message-Id: <b3579c20edd49597fd58e530be463611e61515f0.1348732807.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Thu, 27 Sep 2012 08:41:41 +0100

Subject: [PATCH 1/4] [mama] CPP Default queue tidy up

 

Tidyup the cpp default queue wrapper to avoid memory leak /

core on shutdown.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/cpp/MamaQueue.cpp    |   10 +++++++++-

mama/c_cpp/src/cpp/mama/MamaQueue.h |    2 ++

mama/c_cpp/src/cpp/mamacpp.cpp      |    4 ++--

3 files changed, 13 insertions(+), 3 deletions(-)

 

diff --git a/mama/c_cpp/src/cpp/MamaQueue.cpp b/mama/c_cpp/src/cpp/MamaQueue.cpp

index b5b41db..abd880f 100644

--- a/mama/c_cpp/src/cpp/MamaQueue.cpp

+++ b/mama/c_cpp/src/cpp/MamaQueue.cpp

@@ -156,9 +156,11 @@ namespace Wombat

             : mClosure          (NULL)

             , mEnqueueCallback  (NULL)

                , mUserClosure      (NULL)

+             , mOwner                            (0)

         {

         }

+                             short                                                                       mOwner;

         void*                     mClosure;

         MamaQueueEnqueueCallback* mEnqueueCallback;

         MamaQueueMonitorCallback* mMonitorCallback;

@@ -174,6 +176,11 @@ namespace Wombat

     {

     }

+             MamaQueue::MamaQueue (mamaQueue cQueue)

+        : mPimpl (new MamaQueueImpl)

+        , mQueue (cQueue)

+    {

+    }

     MamaQueue::~MamaQueue (void)

     {

         destroy ();

@@ -183,6 +190,7 @@ namespace Wombat

     void MamaQueue::create (mamaBridge bridgeImpl)

     {

         mamaTry (mamaQueue_create (&mQueue, bridgeImpl));

+                             mPimpl->mOwner=1;

     }

     void MamaQueue::create (mamaBridge  bridgeImpl,

@@ -470,7 +478,7 @@ namespace Wombat

     {        

         mama_status status = MAMA_STATUS_OK;

-        if (mQueue)

+        if ((mQueue) && (mPimpl->mOwner))

         {

             status = mamaQueue_destroy (mQueue);       

         }

diff --git a/mama/c_cpp/src/cpp/mama/MamaQueue.h b/mama/c_cpp/src/cpp/mama/MamaQueue.h

index b49ff43..019d880 100644

--- a/mama/c_cpp/src/cpp/mama/MamaQueue.h

+++ b/mama/c_cpp/src/cpp/mama/MamaQueue.h

@@ -23,6 +23,7 @@

#define MAMA_QUEUE_CPP_H__

 #include <mama/mamacpp.h>

+#include <mama/queue.h>

 namespace Wombat

 {

@@ -41,6 +42,7 @@ namespace Wombat

     public:

         MamaQueue          (void);

+        MamaQueue          (mamaQueue cQueue);

         virtual ~MamaQueue (void);

         /**

diff --git a/mama/c_cpp/src/cpp/mamacpp.cpp b/mama/c_cpp/src/cpp/mamacpp.cpp

index 037f97b..6042e22 100644

--- a/mama/c_cpp/src/cpp/mamacpp.cpp

+++ b/mama/c_cpp/src/cpp/mamacpp.cpp

@@ -29,6 +29,7 @@

#include <string>

#include "MamaSubscriptionImpl.h"

#include <mama/queue.h>

+#include <mama/MamaQueue.h>

#include <mama/MamaReservedFields.h>

 namespace Wombat

@@ -283,8 +284,7 @@ namespace Wombat

             mamaQueue_getClosure (defaultQueueC, (void**)(&defaultQueue));

             if (defaultQueue == NULL)

             {

-                defaultQueue = new MamaQueue();

-                defaultQueue->setCValue(defaultQueueC);

+                defaultQueue = new MamaQueue(defaultQueueC);

                 mamaQueue_setClosure(defaultQueueC, (void*) defaultQueue);

             }

             return defaultQueue;

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________ Openmama-dev mailing list Openmama-dev@... https://lists.openmama.org/mailman/listinfo/openmama-dev



Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


Ian Bell <IBell@...>
 

From b3579c20edd49597fd58e530be463611e61515f0 Mon Sep 17 00:00:00 2001

Message-Id: <b3579c20edd49597fd58e530be463611e61515f0.1348732807.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Thu, 27 Sep 2012 08:41:41 +0100

Subject: [PATCH 1/4] [mama] CPP Default queue tidy up

 

Tidyup the cpp default queue wrapper to avoid memory leak /

core on shutdown.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/cpp/MamaQueue.cpp    |   10 +++++++++-

mama/c_cpp/src/cpp/mama/MamaQueue.h |    2 ++

mama/c_cpp/src/cpp/mamacpp.cpp      |    4 ++--

3 files changed, 13 insertions(+), 3 deletions(-)

 

diff --git a/mama/c_cpp/src/cpp/MamaQueue.cpp b/mama/c_cpp/src/cpp/MamaQueue.cpp

index b5b41db..abd880f 100644

--- a/mama/c_cpp/src/cpp/MamaQueue.cpp

+++ b/mama/c_cpp/src/cpp/MamaQueue.cpp

@@ -156,9 +156,11 @@ namespace Wombat

             : mClosure          (NULL)

             , mEnqueueCallback  (NULL)

                , mUserClosure      (NULL)

+             , mOwner                            (0)

         {

         }

+                             short                                                                       mOwner;

         void*                     mClosure;

         MamaQueueEnqueueCallback* mEnqueueCallback;

         MamaQueueMonitorCallback* mMonitorCallback;

@@ -174,6 +176,11 @@ namespace Wombat

     {

     }

+             MamaQueue::MamaQueue (mamaQueue cQueue)

+        : mPimpl (new MamaQueueImpl)

+        , mQueue (cQueue)

+    {

+    }

     MamaQueue::~MamaQueue (void)

     {

         destroy ();

@@ -183,6 +190,7 @@ namespace Wombat

     void MamaQueue::create (mamaBridge bridgeImpl)

     {

         mamaTry (mamaQueue_create (&mQueue, bridgeImpl));

+                             mPimpl->mOwner=1;

     }

     void MamaQueue::create (mamaBridge  bridgeImpl,

@@ -470,7 +478,7 @@ namespace Wombat

     {        

         mama_status status = MAMA_STATUS_OK;

-        if (mQueue)

+        if ((mQueue) && (mPimpl->mOwner))

         {

             status = mamaQueue_destroy (mQueue);       

         }

diff --git a/mama/c_cpp/src/cpp/mama/MamaQueue.h b/mama/c_cpp/src/cpp/mama/MamaQueue.h

index b49ff43..019d880 100644

--- a/mama/c_cpp/src/cpp/mama/MamaQueue.h

+++ b/mama/c_cpp/src/cpp/mama/MamaQueue.h

@@ -23,6 +23,7 @@

#define MAMA_QUEUE_CPP_H__

 #include <mama/mamacpp.h>

+#include <mama/queue.h>

 namespace Wombat

 {

@@ -41,6 +42,7 @@ namespace Wombat

     public:

         MamaQueue          (void);

+        MamaQueue          (mamaQueue cQueue);

         virtual ~MamaQueue (void);

         /**

diff --git a/mama/c_cpp/src/cpp/mamacpp.cpp b/mama/c_cpp/src/cpp/mamacpp.cpp

index 037f97b..6042e22 100644

--- a/mama/c_cpp/src/cpp/mamacpp.cpp

+++ b/mama/c_cpp/src/cpp/mamacpp.cpp

@@ -29,6 +29,7 @@

#include <string>

#include "MamaSubscriptionImpl.h"

#include <mama/queue.h>

+#include <mama/MamaQueue.h>

#include <mama/MamaReservedFields.h>

 namespace Wombat

@@ -283,8 +284,7 @@ namespace Wombat

             mamaQueue_getClosure (defaultQueueC, (void**)(&defaultQueue));

             if (defaultQueue == NULL)

             {

-                defaultQueue = new MamaQueue();

-                defaultQueue->setCValue(defaultQueueC);

+                defaultQueue = new MamaQueue(defaultQueueC);

                 mamaQueue_setClosure(defaultQueueC, (void*) defaultQueue);

             }

             return defaultQueue;

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.