[PATCH 2.3.1 1/1] MAMAC: Missing actions for snapshot subscriptions transition to deactivate state

Alireza Assadzadeh <Alireza.Assadzadeh@...>

For snapshot subscriptions, there is no bridge subscription callback
to be called later with mamaSubscriptionImpl_onSubscriptionDestroyed.
Therefore, add code to perform the additional actions for deactivated
state in mamaSubscription_deactivate. Namely, add code to decrement
the queue object count.

Test Plan:
- Check with capturereplayc and mamalistenc using -shutdown option.
Use mama.properties: mama.queue.object_lock_tracking=1 and
- Build and run unit tests (UnitTestCommon*, UnitTestsMama*).

Signed-off-by: Alireza Assadzadeh <Alireza.Assadzadeh@...>

I have raised bug http://bugs.openmama.org/show_bug.cgi?id=176 to track
this issue and attached the patches to the bug.

The patches are against 'next' branch. They are tested by using gunittests,
and sample programs (capturereplayc, mamalistenc and bookticker).

Before this fix the problem is observable when calling mama_close after
earlier having created and destroyed a snapshot subscription (either
dictionary snapshot normal/book snapshot subscription). The mamaQueue_destory
for default queue times out since there are left over open objects in the queue
due to the missing call to mamaQueue_decrementObjectCount.
For example, using the mamalistenc with -shutdown option with qpid, the mama_close
takes 5 seconds to complete with the following finest log "Entering
mamaQueue_destroy for queue 0x<pointer>" repeated every 10ms (500 times) and
finally timing out with log "mamaQueue_destroy(): timed out destroying queue.".

mama/c_cpp/src/c/subscription.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/mama/c_cpp/src/c/subscription.c b/mama/c_cpp/src/c/subscription.c
index c809257..1f78746 100644
--- a/mama/c_cpp/src/c/subscription.c
+++ b/mama/c_cpp/src/c/subscription.c
@@ -2616,7 +2616,19 @@ mama_status mamaSubscription_deactivate(mamaSubscription subscription)
ret = mamaSubscription_deactivate_internal(impl);
if (impl->mSubscMsgType == MAMA_SUBSC_DDICT_SNAPSHOT ||
impl->mSubscMsgType == MAMA_SUBSC_SNAPSHOT)
+ {
+ /* Snapshot subscriptions don't have a bridge and are transitioned to deactivated
+ * immediately after deactivating.
+ * Also, since there is no bridge subscription callback to be called later with
+ * mamaSubscriptionImpl_onSubscriptionDestroyed, the necessary actions for deactivated
+ * state are performed here. Namely the queue object count is decremented.
+ */
+ if(NULL != impl->mQueue)
+ {
+ mamaQueue_decrementObjectCount(&impl->mLockHandle, impl->mQueue);
+ }
mamaSubscriptionImpl_setState(impl, MAMA_SUBSCRIPTION_DEACTIVATED);
+ }


Join Openmama-dev@lists.openmama.org to automatically receive all group messages.