[PATCH] [mama] Use local subscription list when refreshes disabled


mschonberg@...
 

From: Mike Schonberg <mschonberg@...>

Normally, with refreshes enabled, mamaTransport delegates maintaining a list of
subscriptions to the refresh sub-transport; however, when refreshes are disabled
with the "disable_refresh" transport property or programatically, the
mamaTransport must maintain this list. A previous refactoring effort,
erroneously removed the code that maintained this list when refresh messages are
disabled. This patch restores that code.

Signed-off-by: Michael Schonberg <mschobnerg@...>
---
mama/c_cpp/src/c/transport.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/mama/c_cpp/src/c/transport.c b/mama/c_cpp/src/c/transport.c
index d51d12d..742f05b 100644
--- a/mama/c_cpp/src/c/transport.c
+++ b/mama/c_cpp/src/c/transport.c
@@ -1549,6 +1549,8 @@ mamaTransport_addSubscription (mamaTransport transport,

if (self->mRefreshTransport)
handle = refreshTransport_allocateSubscInfo (self->mRefreshTransport);
+ else
+ handle = (SubscriptionInfo*)list_allocate_element (self->mListeners);

if (handle == NULL) return MAMA_STATUS_NOMEM;

@@ -1558,6 +1560,8 @@ mamaTransport_addSubscription (mamaTransport transport,

if (self->mRefreshTransport)
refreshTransport_addSubscription (self->mRefreshTransport, handle);
+ else
+ list_push_back (self->mListeners, handle);

return MAMA_STATUS_OK;
}
@@ -1572,6 +1576,11 @@ mamaTransport_removeListener (mamaTransport transport, void* handle)
{
refreshTransport_removeListener (self->mRefreshTransport, handle, 1);
}
+ else
+ {
+ list_remove_element (self->mListeners, handle);
+ list_free_element (self->mListeners, handle);
+ }

return MAMA_STATUS_OK;
}
@@ -1689,6 +1698,10 @@ setPossiblyStaleForListeners (transportImpl* transport)
refreshTransport_iterateListeners (self->mRefreshTransport,
setStaleListenerIterator, NULL);
}
+ else
+ {
+ list_for_each( self->mListeners, setStaleListenerIterator, NULL );
+ }
}

preInitialScheme
@@ -1831,6 +1844,9 @@ mamaTransportImpl_getTopicsAndTypesForSource (mamaTransport transport,
*/
if (self->mRefreshTransport)
size = refreshTransport_numListeners (self->mRefreshTransport);
+ else
+ size = list_size (self->mListeners);
+

closure.topics =
(const char**) calloc (sizeof (char*), size);
@@ -1847,6 +1863,10 @@ mamaTransportImpl_getTopicsAndTypesForSource (mamaTransport transport,
refreshTransport_iterateListeners (self->mRefreshTransport,
topicsForSourceIterator, &closure);
}
+ else
+ {
+ list_for_each (self->mListeners, topicsForSourceIterator, &closure);
+ }

*topics = closure.topics;
*types = closure.types;
@@ -2489,6 +2509,10 @@ void mamaTransportImpl_clearTransportWithListeners (transportImpl *impl)
refreshTransport_iterateListeners (impl->mRefreshTransport,
mamaTransportImpl_clearTransportCallback, NULL);
}
+ else
+ {
+ list_for_each(impl->mListeners, mamaTransportImpl_clearTransportCallback, NULL);
+ }
}

void mamaTransportImpl_clearTransportWithPublishers (transportImpl *impl)
--
1.7.7.6