[PATCH 1.1] Interlocked changes queue.c: Correct reference counting and destroy interlock
John Gray <jgray@...>
Index: queue.c =================================================================== RCS file: /cvsroot/products/mama/c_cpp/src/c/queue.c,v retrieving revision 1.35.4.5.2.1.4.11 diff -w -u -r1.35.4.5.2.1.4.11 queue.c --- queue.c 27 Sep 2011 12:38:50 -0000 1.35.4.5.2.1.4.11 +++ queue.c 14 Jan 2012 09:41:43 -0000 @@ -198,6 +198,7 @@ impl->mQueueMonitorClosure = NULL;
/* Create the counter lock. */ + wInterlocked_initialize(&impl->mNumberOpenObjects); wInterlocked_set(0, &impl->mNumberOpenObjects);
@@ -436,7 +437,7 @@ int newCount = wInterlocked_decrement(&impl->mNumberOpenObjects);
/* Write a log if something has gone wrong. */ - if(impl->mNumberOpenObjects < 0) + if(newCount < 0) { mama_log(MAMA_LOG_LEVEL_ERROR, "Queue 0x%p has been dereferenced too many times.", queue); } @@ -719,6 +720,9 @@ impl->mMamaQueueBridgeImpl = NULL; impl->mMsg = NULL;
+ /* Destroy the counter lock */ + wInterlocked_destroy(&impl->mNumberOpenObjects); + free (impl);
mama_log (MAMA_LOG_LEVEL_FINEST, "Leaving mamaQueue_destroy for queue 0x%X.", queue); Index: subscription.c =================================================================== RCS file: /cvsroot/products/mama/c_cpp/src/c/subscription.c,v retrieving revision 1.152.4.15.2.8.2.10 diff -w -u -r1.152.4.15.2.8.2.10 subscription.c --- subscription.c 10 Oct 2011 16:03:18 -0000 1.152.4.15.2.8.2.10 +++ subscription.c 14 Jan 2012 09:41:43 -0000 @@ -1831,6 +1831,9 @@ /* Destroy the mutex. */ wlock_destroy(impl->mCreateDestroyLock);
+ /* Destroy the state. */ + wInterlocked_destroy(&impl->mState); + /* Free the subscription impl. */ free(impl); }
Signed-off-by: John Gray <jgray@...> |
|