Date   

[PATCH] Added listenerMsgCallbackImpl_logUnknowStatus

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This method refactors repeated logging statements and make the source easier to
follow.

Signed-off-by: Micheal Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/listenermsgcallback.c | 46 +++++++++++++++++++++++--------
1 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/mama/c_cpp/src/c/listenermsgcallback.c b/mama/c_cpp/src/c/listenermsgcallback.c
index cbc8224..9e770a9 100644
--- a/mama/c_cpp/src/c/listenermsgcallback.c
+++ b/mama/c_cpp/src/c/listenermsgcallback.c
@@ -64,6 +64,17 @@ listenerMsgCallbackImpl_invokeErrorCallback(listenerMsgCallback callback,
subscription, const char *userSymbol);

/**
+ * This function will write a log message if an unknown message status is detected.
+ *
+ * @param[in] ctx The subscription context.
+ * @param[in] status The message status.
+ * @param[in] subscription The subscription.
+ */
+static void
+listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, int status,
+ mamaSubscription subscription);
+
+/**
* Main callback for MamaListener. This is the base strategy for
* handling messages.
*/
@@ -303,21 +314,15 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,
* MISC status. */
break;
}
- /* else drop through to default... */
+
+ /* Otherwise log the fact we have received an unknown message. */
+ listenerMsgCallbackImpl_logUnknownStatus(ctx, status, subscription);
+ break;
}
default:
{
- if ((gMamaLogLevel >= MAMA_LOG_LEVEL_FINE) ||
- (mamaSubscription_checkDebugLevel (subscription,
- MAMA_LOG_LEVEL_FINE)))
- {
- const char* userSymbol = NULL;
- mamaSubscription_getSymbol (subscription, &userSymbol);
- mama_log (MAMA_LOG_LEVEL_FINE,
- "%s%s%s%s Unexpected status: %s",
- userSymbolFormatted, ctxSymbolFormatted,
- mamaMsgStatus_stringForStatus( status ) );
- }
+ /* Log the fact we have received an unknown message. */
+ listenerMsgCallbackImpl_logUnknownStatus(ctx, status, subscription);
}
}
}
@@ -572,3 +577,20 @@ void listenerMsgCallbackImpl_invokeErrorCallback(listenerMsgCallback callback, S
userSymbol,
closure);
}
+
+void listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, int status,
+ mamaSubscription subscription)
+{
+ /* Write the log at fine level. */
+ if ((gMamaLogLevel >= MAMA_LOG_LEVEL_FINE) ||
+ (mamaSubscription_checkDebugLevel (subscription,
+ MAMA_LOG_LEVEL_FINE)))
+ {
+ const char* userSymbol = NULL;
+ mamaSubscription_getSymbol (subscription, &userSymbol);
+ mama_log (MAMA_LOG_LEVEL_FINE,
+ "%s%s%s%s Unexpected status: %s",
+ userSymbolFormatted, ctxSymbolFormatted,
+ mamaMsgStatus_stringForStatus( status ) );
+ }
+}
--
1.7.5.4


[PATCH] Only invoke onQuality callbck for MAMA_MSG_TYPE_MISC

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

When amessage arrives with a status of POSSIBLY_STALE, verify that the message
type is MAMA_MSG_TYPE_MISC. This behavior is consistent with OpenMAMA market
data publishers.

Signed-off-by: Michael Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/listenermsgcallback.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/mama/c_cpp/src/c/listenermsgcallback.c b/mama/c_cpp/src/c/listenermsgcallback.c
index 9e770a9..dca5474 100644
--- a/mama/c_cpp/src/c/listenermsgcallback.c
+++ b/mama/c_cpp/src/c/listenermsgcallback.c
@@ -306,6 +306,25 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,
handleNoSubscribers (impl, msg, ctx);
return;
}
+
+ /* The possibly stale messages are sent by the MAMACACHE with a miscellanious type and should be translated
+ * into a quality event.
+ */
+ case MAMA_MSG_STATUS_POSSIBLY_STALE:
+ {
+ /* Verify that the type is misc. */
+ if(msgType == MAMA_MSG_TYPE_MISC)
+ {
+ /* Change the state to maybe stale and invoke the onquality callback. */
+ mamaSubscription_setPossiblyStale(subscription);
+ break;
+ }
+
+ /* Otherwise log the fact we have received an unknown message. */
+ listenerMsgCallbackImpl_logUnknownStatus(ctx, status, subscription);
+ break;
+ }
+
case MAMA_MSG_STATUS_MISC:
{
if (msgType == MAMA_MSG_TYPE_REFRESH)
--
1.7.5.4


[PATCH] Initialize Callbacks structs to 0 for mamasymbolist subscriber

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This avoids a potentional sgmentation fault in the event that an uninitialized
callback gets invoked.

Signed-off-by: John Gray <jgray@nyx.com>
---
.../src/examples/c/mamasymbollistsubscriberc.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c b/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
index 29a2eb7..0160df7 100644
--- a/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
+++ b/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
@@ -151,6 +151,7 @@ int main (int argc, const char **argv)
mama_status status;
mamaMsgCallbacks symbolListCallbacks;
mamaSubscription symbolListSubscription;
+ memset(&symbolListCallbacks, 0, sizeof(symbolListCallbacks));

gSymbolList = (const char**) calloc (MAX_SUBSCRIPTIONS, sizeof (char*));
gSubscriptionList = (mamaSubscription*)calloc (MAX_SUBSCRIPTIONS,
@@ -463,6 +464,7 @@ static void subscribeToSymbols (void)
mama_status status = MAMA_STATUS_OK;
size_t i;
mamaMsgCallbacks callbacks;
+ memset(&callbacks, 0, sizeof(callbacks));

callbacks.onCreate = subscriptionOnCreate;
callbacks.onError = subscriptionOnError;
--
1.7.5.4


[PATCH] Use Transport Properties for FT Configuration

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

Currently, the FT setup code uses the hard-coded transport name, "ft", to read
properties from mama.properties despite the fact that the caller supplies a
mamaTransport reference. This change uses the supplied transport's name to
lookup FT configuration properties.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/ft.c | 86 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/mama/c_cpp/src/c/ft.c b/mama/c_cpp/src/c/ft.c
index 2066b0c..efbc16d 100644
--- a/mama/c_cpp/src/c/ft.c
+++ b/mama/c_cpp/src/c/ft.c
@@ -58,6 +58,8 @@
#define FT_FIELD_IPADDRESS "MamaIPAddress"
#define FT_FIELD_IPADDRESS_FID 206

+#define FT_MAX_PROPERTY_NAME_LENGTH 1024
+
mama_status
multicastFt_setup (
mamaFtMember member,
@@ -105,6 +107,10 @@ static void bridgeFt_sendHeartbeat (mamaFtMember member);
static int multicastFt_receiveHeartbeat(void* member);
static int bridgeFt_receiveHeartbeat(void* member);

+static const char*
+multicastFt_getProperty(char *buffer, const char *propertyName, const char
+ *transportName);
+
static int foundheartbeat=0;

/*****************************************
@@ -878,6 +884,32 @@ struct in_addr resolve_ip (const char * arg)
/****************************************************************************
* Multicast FT specific
******************************************************************************/
+
+const char *multicastFt_getProperty(char *buffer, const char *propertyName, const char *transportName)
+{
+ /* Returns. */
+ const char *ret = NULL;
+
+ /* Format the full property name. */
+ int numberWritten = snprintf(buffer, (FT_MAX_PROPERTY_NAME_LENGTH - 1), propertyName, transportName);
+
+ /* If too many characters are written the log an error. */
+ if((FT_MAX_PROPERTY_NAME_LENGTH - 1) < numberWritten)
+ {
+ mama_log(MAMA_LOG_LEVEL_ERROR, "%s Property name too long. Length [%d],"
+ " Max Length [%d].", transportName, strlen(transportName),
+ (FT_MAX_PROPERTY_NAME_LENGTH - 1));
+ }
+
+ else
+ {
+ /* Otherwise get the property. */
+ ret = mama_getProperty(buffer);
+ }
+
+ return ret;
+}
+
mama_status
multicastFt_setup (
mamaFtMember member,
@@ -904,46 +936,70 @@ multicastFt_setup (
const char* ftNetwork = NULL;
const char* ftTtl = NULL;
const char* iorecvstr = NULL;
+ const char* transportName = NULL;
+ mama_status status = MAMA_STATUS_OK;
struct in_addr iface;
struct in_addr cFtIfAddr;

+ /* This buffer is used for formatting property names. */
+ char propertyName[FT_MAX_PROPERTY_NAME_LENGTH] = "";
+
mamaFtMemberImpl* impl = (mamaFtMemberImpl*) member;

- if (!impl || !groupName)
+ if (!impl || !groupName || !transport)
return MAMA_STATUS_INVALID_ARG;

- ftInterface = mama_getProperty ("mama.multicast.transport.ft.interface");
- if (ftInterface == NULL)
+ /* Get the transport name. */
+ status = mamaTransport_getName(transport, &transportName);
+ if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' ==
+ transportName[0]))
{
- ftInterface = mama_getProperty ("mama.native.transport.ft.interface");
+ mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name "
+ "is invalid");
+ return MAMA_STATUS_INVALID_ARG;
+ }
+
+ ftInterface = multicastFt_getProperty(propertyName,
+ "mama.multicast.transport.%s.interface", transportName);
if (ftInterface == NULL)
+ {
+ ftInterface = multicastFt_getProperty(propertyName,
+ "mama.native.transport.%s.interface", transportName);
+ if (ftInterface == NULL)
ftInterface = "";
}
- ftNetwork = mama_getProperty ("mama.multicast.transport.ft.network");
+ ftNetwork = multicastFt_getProperty (propertyName,
+ "mama.multicast.transport.%s.network", transportName);
if (ftNetwork == NULL)
{
- ftNetwork = mama_getProperty ("mama.native.transport.ft.network");
- if (ftNetwork == NULL)
- ftNetwork = FT_NETWORK;
+ ftNetwork = multicastFt_getProperty (propertyName,
+ "mama.native.transport.%s.network", transportName);
+ if (ftNetwork == NULL)
+ ftNetwork = FT_NETWORK;
}

- ftService = mama_getProperty ("mama.multicast.transport.ft.service");
+ ftService = multicastFt_getProperty (propertyName,
+ "mama.multicast.transport.%s.service", transportName);
if (ftService == NULL)
{
- ftService = mama_getProperty ("mama.native.transport.ft.service");
+ ftService = multicastFt_getProperty (propertyName,
+ "mama.native.transport.%s.service", transportName);
if (ftService != NULL)
- service = atol (ftService);
+ service = atol (ftService);
}

- ftTtl = mama_getProperty ("mama.multicast.transport.ft.ttl");
+ ftTtl = multicastFt_getProperty (propertyName,
+ "mama.multicast.transport.%s.ttl", transportName);
if (ftTtl == NULL)
{
- ftTtl = mama_getProperty ("mama.native.transport.ft.ttl");
+ ftTtl = multicastFt_getProperty (propertyName,
+ "mama.native.transport.%s.ttl", transportName);
if (ftTtl != NULL)
- ttl = atol (ftTtl);
+ ttl = atol (ftTtl);
}

- iorecvstr = mama_getProperty ("mama.multicast.transport.ft.iowindow");
+ iorecvstr = multicastFt_getProperty (propertyName,
+ "mama.multicast.transport.%s.iowindow", transportName);
if (iorecvstr != NULL)
{
iorecv=atoi (iorecvstr);
--
1.7.5.4


[PATCH] Added mamaTransportImpl_setAdvisoryCauseAndPlatformInfo()

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This method allows bridges to pass middleware specific details regarding errors
and events.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/transport.c | 67 +++++++++++++++++++++++---------------
mama/c_cpp/src/c/transportimpl.h | 39 ++++++++++++++++++---
2 files changed, 74 insertions(+), 32 deletions(-)

diff --git a/mama/c_cpp/src/c/transport.c b/mama/c_cpp/src/c/transport.c
index 95e912c..20ee0cc 100644
--- a/mama/c_cpp/src/c/transport.c
+++ b/mama/c_cpp/src/c/transport.c
@@ -1960,32 +1960,6 @@ mamaTransportImpl_unsetAllPossiblyStale (mamaTransport transport)
}
}

-/**
- * Return the cause and platform info for the last message processed on the
- * transport.
- *
- * @param transport The transport.
- * @param cause To return the cause.
- * @param platformInfo To return the bridge specific info, under no circumstances
- * should the returned object be deleted.
- */
-void
-mamaTransportImpl_getAdvisoryCauseAndPlatformInfo (mamaTransport transport,
- short* cause,
- const void** platformInfo)
-{
- if (!self)
- {
- mama_log (MAMA_LOG_LEVEL_ERROR,
- "mamaTransportImpl_getAdvisoryCauseAndPlatformInfo (): "
- "NULL transport.");
- return;
- }
-
- *cause = self->mCause;
- *platformInfo = self->mPlatformInfo;
-}
-
void
mamaTransportImpl_getTransportIndex (mamaTransport transport,
int* transportIndex)
@@ -2363,3 +2337,44 @@ mama_status mamaTransport_removePublisher (mamaTransport transport, void *handle
return MAMA_STATUS_OK;
}

+/* *************************************************** */
+/* Internal Functions. */
+/* *************************************************** */
+
+void mamaTransportImpl_getAdvisoryCauseAndPlatformInfo(mamaTransport transport,
+ short *cause, const void **platformInfo)
+{
+ /* Get the impl. */
+ transportImpl *impl = (transportImpl *)transport;
+ if(NULL != impl)
+ {
+ /* Return the cause. */
+ *cause = impl->mCause;
+ *platformInfo = impl->mPlatformInfo;
+ }
+ else
+ {
+ mama_log (MAMA_LOG_LEVEL_ERROR,
+ "mamaTransportImpl_getAdvisoryCauseAndPlatformInfo(): NULL "
+ "transport.");
+ }
+}
+
+void mamaTransportImpl_setAdvisoryCauseAndPlatformInfo (mamaTransport transport,
+ short cause, const void *platformInfo)
+{
+ /* Get the impl. */
+ transportImpl *impl = (transportImpl *)transport;
+ if(NULL != impl)
+ {
+ /* Set the cause. */
+ impl->mCause = cause;
+ impl->mPlatformInfo = (void*)platformInfo;
+ }
+ else
+ {
+ mama_log (MAMA_LOG_LEVEL_ERROR,
+ "mamaTransportImpl_setAdvisoryCauseAndPlatformInfo(): NULL "
+ "transport.");
+ }
+}
diff --git a/mama/c_cpp/src/c/transportimpl.h b/mama/c_cpp/src/c/transportimpl.h
index cf4b3d0..5ae83c6 100644
--- a/mama/c_cpp/src/c/transportimpl.h
+++ b/mama/c_cpp/src/c/transportimpl.h
@@ -158,12 +158,6 @@ MAMAExpDLL
extern void
mamaTransportImpl_unsetAllPossiblyStale (mamaTransport tport);

-MAMAExpDLL
-extern void
-mamaTransportImpl_getAdvisoryCauseAndPlatformInfo (mamaTransport tport,
- short* cause,
- const void** platformInfo);
-
/*
Get the bridge impl associated with the specified transport.
This will be how other objects gain access to the bridge.
@@ -251,4 +245,37 @@ preInitialScheme mamaTransportImpl_getPreInitialScheme (mamaTransport transport)
}
#endif

+
+/**
+ * This function will return the cause and platform info for the last message
+ * processed on the transport.
+ *
+ * @param[in] transport The transport.
+ * @param[out] cause To return the cause.
+ * @param[out] platformInfo To return the bridge specific info, under no
+ * circumstances should the returned object be deleted.
+ *
+ */
+MAMAExpDLL
+extern void
+mamaTransportImpl_getAdvisoryCauseAndPlatformInfo(
+ mamaTransport tport,
+ short *cause,
+ const void **platformInfo);
+
+/**
+ * This function will set the cause and platform info for the transport.
+ *
+ * @param[in] transport The transport.
+ * @param[in] cause The cause.
+ * @param[in] platformInfo Bridge specific info.
+ *
+ */
+MAMAExpDLL
+extern void
+mamaTransportImpl_setAdvisoryCauseAndPlatformInfo(
+ mamaTransport transport,
+ short cause,
+ const void *platformInfo);
+
#endif /* TransportImplH__ */
--
1.7.5.4


[PATCH] MAMA: Move global bridge data to struct

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This is in preparation for adding improved reference counting and locking around
mama_open(), and mama_close() to enable them to be called safely from
multi-threaded applications.

A number of compiler warnings are also fixed.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/mama.c | 106 +++++++++++++++++++++++++++++------------------
1 files changed, 66 insertions(+), 40 deletions(-)

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index ee0d6a0..4142c16 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -128,7 +128,6 @@ static const char* gHostName = NULL;

static void lookupIPAddress (void);

-static int gRefCount = 0;

wproperty_t gProperties = 0;
static mamaStatsLogger gStatsPublisher = NULL;
@@ -148,11 +147,9 @@ mamaStat gRvMsgsStat;

#define MAMA_PAYLOAD_MAX CHAR_MAX

-static mamaBridge gMamaBridges [MAMA_MIDDLEWARE_MAX];
-static mamaPayloadBridge gMamaPayloads [MAMA_PAYLOAD_MAX];
static mamaPayloadBridge gDefaultPayload = NULL;

-pthread_key_t last_err_key;
+static pthread_key_t last_err_key;

/**
* struct mamaApplicationGroup
@@ -164,16 +161,39 @@ typedef struct mamaAppContext_
const char* myApplicationClass;
} mamaApplicationContext;

+/**
+ * This structure contains data needed to control starting and stopping of
+ * mama.
+ *
+ * TODO: Access to this structure will ultimately be protected by a reference
+ * count and a lock.
+ */
+typedef struct mamaImpl_
+{
+ mamaBridge myBridges[MAMA_MIDDLEWARE_MAX];
+ mamaPayloadBridge myPayloads[MAMA_PAYLOAD_MAX];
+ LIB_HANDLE myBridgeLibraries[MAMA_MIDDLEWARE_MAX];
+ LIB_HANDLE myPayloadLibraries[MAMA_PAYLOAD_MAX];
+ unsigned int myRefCount;
+ pthread_mutex_t myLock;
+} mamaImpl;

static mamaApplicationContext appContext;
static char mama_ver_string[256];

+static mamaImpl gImpl = {{0}, {0}, {0}, {0}, 0, PTHREAD_MUTEX_INITIALIZER};
+
+/* ************************************************************************* */
+/* Private Function Prototypes. */
+/* ************************************************************************* */
+
+
/* Description : This function will free any memory associated with a
* mamaApplicationContext object but will not free the
* object itself.
* Arguments : context [I] The context object to free.
*/
-void
+static void
mama_freeAppContext(mamaApplicationContext *context)
{
/* Only continue if the object is valid. */
@@ -348,7 +368,7 @@ mamaInternal_createStatsPublisher ()
statsLogMiddlewareName = "wmw";
}

- bridge = gMamaBridges[mamaMiddleware_convertFromString (statsLogMiddlewareName)];
+ bridge = gImpl.myBridges[mamaMiddleware_convertFromString (statsLogMiddlewareName)];

if (MAMA_STATUS_OK != (result = mamaBridgeImpl_getInternalEventQueue (bridge,
&queue)))
@@ -596,7 +616,7 @@ mamaInternal_findBridge ()

for (middleware = 0; middleware < MAMA_MIDDLEWARE_MAX; middleware++)
{
- bridge = gMamaBridges [middleware];
+ bridge = gImpl.myBridges [middleware];

if (bridge != NULL)
{
@@ -610,9 +630,10 @@ mamaInternal_findBridge ()
mamaPayloadBridge
mamaInternal_findPayload (char id)
{
- if (('\0' == id) || (MAMA_PAYLOAD_MAX < id)) return NULL;
+ if ('\0' == id)
+ return NULL;

- return gMamaPayloads[(uint8_t)id];
+ return gImpl.myPayloads[(uint8_t)id];
}

mamaPayloadBridge
@@ -668,7 +689,7 @@ mama_openWithProperties (const char* path,
"********************************************************");
#endif

- if (gRefCount++) return result;
+ if (gImpl.myRefCount++) return result;

#ifdef WITH_INACTIVE_CHECK
mama_log (MAMA_LOG_LEVEL_WARN,
@@ -831,10 +852,10 @@ mama_openWithProperties (const char* path,
/* Look for a bridge for each of the middlewares and open them */
for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)
{
- mamaBridgeImpl* impl = (mamaBridgeImpl*) gMamaBridges [middleware];
+ mamaBridgeImpl* impl = (mamaBridgeImpl*) gImpl.myBridges [middleware];
if (impl)
{
- mama_log (MAMA_LOG_LEVEL_FINE, mama_getVersion (gMamaBridges[middleware]));
+ mama_log (MAMA_LOG_LEVEL_FINE, mama_getVersion (gImpl.myBridges[middleware]));
mamaQueue_enableStats(impl->mDefaultEventQueue);
++numBridges;
}
@@ -903,7 +924,7 @@ mama_openWithProperties (const char* path,
statsMiddleware = "wmw";
}

- bridge = gMamaBridges[mamaMiddleware_convertFromString (statsMiddleware)];
+ bridge = gImpl.myBridges[mamaMiddleware_convertFromString (statsMiddleware)];

if (MAMA_STATUS_OK != (result = mamaBridgeImpl_getInternalEventQueue (bridge,
&statsGenQueue)))
@@ -1050,7 +1071,7 @@ mama_close ()
mamaMiddleware middleware = 0;
int payload = 0;

- if( !--gRefCount )
+ if( !--gImpl.myRefCount )
{
#ifdef WITH_ENTITLEMENTS
if( gEntitlementClient != 0 )
@@ -1064,19 +1085,19 @@ mama_close ()

for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)
{
- mamaBridge bridge = gMamaBridges[middleware];
+ mamaBridge bridge = gImpl.myBridges[middleware];
if (bridge)
mamaBridgeImpl_stopInternalEventQueue (bridge);
}
/* Look for a bridge for each of the payloads and close them */
for (payload = 0; payload != MAMA_PAYLOAD_MAX; ++payload)
{
- mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*) gMamaPayloads [(uint8_t)payload];
+ mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*) gImpl.myPayloads [(uint8_t)payload];
if (impl)
{

}
- gMamaPayloads[(uint8_t)payload] = NULL;
+ gImpl.myPayloads[(uint8_t)payload] = NULL;
}

gDefaultPayload = NULL;
@@ -1166,11 +1187,11 @@ mama_close ()
/* Look for a bridge for each of the middlewares and close them */
for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)
{
- mamaBridgeImpl* impl = (mamaBridgeImpl*) gMamaBridges [middleware];
+ mamaBridgeImpl* impl = (mamaBridgeImpl*) gImpl.myBridges [middleware];
if (impl)
{
if (MAMA_STATUS_OK != (
- (result = impl->bridgeClose (gMamaBridges[middleware]))))
+ (result = impl->bridgeClose (gImpl.myBridges[middleware]))))
{
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_close(): Error closing %s bridge.",
@@ -1178,7 +1199,7 @@ mama_close ()

}
}
- gMamaBridges[middleware] = NULL;
+ gImpl.myBridges[middleware] = NULL;
}

/* The properties must not be closed down until after the bridges have been destroyed. */
@@ -1203,9 +1224,9 @@ mama_close ()
mama_freeAppContext(&appContext);

}
- if (gRefCount < 0)
+ if (gImpl.myRefCount < 0)
{
- gRefCount = 0;
+ gImpl.myRefCount = 0;
}
return result;
}
@@ -1339,10 +1360,10 @@ mama_stopAll (void)
/* Look for a bridge for each of the middlewares and open them */
for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)
{
- mamaBridgeImpl* impl = (mamaBridgeImpl*) gMamaBridges [middleware];
+ mamaBridgeImpl* impl = (mamaBridgeImpl*) gImpl.myBridges [middleware];
if (impl)
{
- status = mama_stop (gMamaBridges[middleware]);
+ status = mama_stop (gImpl.myBridges[middleware]);
if (MAMA_STATUS_OK != status)
{
mama_log (MAMA_LOG_LEVEL_ERROR,
@@ -1676,8 +1697,10 @@ void
mamaInternal_registerBridge (mamaBridge bridge,
const char* middlewareName)
{
- mamaMiddleware middleware =
- mamaMiddleware_convertFromString (middlewareName);
+ mamaMiddleware middleware;
+
+ middleware = mamaMiddleware_convertFromString (middlewareName);
+
if (middleware >= MAMA_MIDDLEWARE_MAX)
{
mama_log (MAMA_LOG_LEVEL_SEVERE,
@@ -1686,15 +1709,16 @@ mamaInternal_registerBridge (mamaBridge bridge,
return;
}

- gMamaBridges [middleware] = bridge;
+ gImpl.myBridges[middleware] = bridge;
}

mama_status
mama_setDefaultPayload (char id)
{
- if (('\0' == id) || (MAMA_PAYLOAD_MAX < id) || gMamaPayloads[(uint8_t)id] == NULL) return MAMA_STATUS_NULL_ARG;
+ if ('\0' == id || gImpl.myPayloads[(uint8_t)id] == NULL)
+ return MAMA_STATUS_NULL_ARG;

- gDefaultPayload = gMamaPayloads[(uint8_t)id];
+ gDefaultPayload = gImpl.myPayloads[(uint8_t)id];

return MAMA_STATUS_OK;
}
@@ -1756,7 +1780,7 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

- if (gMamaPayloads [payloadChar])
+ if (gImpl.myPayloads [(int)payloadChar])
{
mama_log (MAMA_LOG_LEVEL_NORMAL,
"mama_loadPayloadBridge(): "
@@ -1765,7 +1789,8 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
return MAMA_STATUS_OK;
}

- gMamaPayloads [payloadChar] = *impl;
+ gImpl.myPayloads [(int)payloadChar] = *impl;
+ gImpl.myPayloadLibraries [(int)payloadChar] = bridgeLib;

if (!gDefaultPayload)
{
@@ -1804,14 +1829,15 @@ mama_loadBridgeWithPath (mamaBridge* impl,
LIB_HANDLE bridgeLib = NULL;
bridge_createImpl initFunc = NULL;
char* payloadName = NULL;
- char payloadId = NULL;
+ char payloadId = '\0';
mama_status result = MAMA_STATUS_OK;
- mamaMiddleware middleware =
- mamaMiddleware_convertFromString (middlewareName);
+ mamaMiddleware middleware = 0;

if (!impl)
return MAMA_STATUS_NULL_ARG;

+ middleware = mamaMiddleware_convertFromString (middlewareName);
+
if (middleware >= MAMA_MIDDLEWARE_MAX)
{
mama_log (MAMA_LOG_LEVEL_ERROR,
@@ -1820,9 +1846,9 @@ mama_loadBridgeWithPath (mamaBridge* impl,
}

/* Check if a bridge has already been initialized for the middleware */
- if (gMamaBridges [middleware])
+ if (gImpl.myBridges [middleware])
{
- *impl = gMamaBridges [middleware];
+ *impl = gImpl.myBridges [middleware];
return MAMA_STATUS_OK;
}

@@ -1844,7 +1870,6 @@ mama_loadBridgeWithPath (mamaBridge* impl,
bridgeImplName ? bridgeImplName : "",
getLibError());
}
-
else
{
mama_log (MAMA_LOG_LEVEL_ERROR,
@@ -1889,18 +1914,19 @@ mama_loadBridgeWithPath (mamaBridge* impl,

result = ((mamaBridgeImpl*)(*impl))->bridgeOpen (*impl);

- if (MAMA_STATUS_OK != result) return result;
+ if (MAMA_STATUS_OK != result)
+ return result;

if (((mamaBridgeImpl*)(*impl))->bridgeGetDefaultPayloadId(&payloadName, &payloadId) == MAMA_STATUS_OK)
{
- if (!gMamaPayloads [(uint8_t)payloadId])
+ if (!gImpl.myPayloads [(uint8_t)payloadId])
{
mamaPayloadBridge payloadImpl;
mama_loadPayloadBridge (&payloadImpl,payloadName);
}
}

- gMamaBridges [middleware] = *impl;
+ gImpl.myBridges [middleware] = *impl;

return MAMA_STATUS_OK;
}
--
1.7.5.4


[PATCH 1/4] Added locking around mama_open() and mama_close()

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

Improved the reference counting logic and added locking around mama_open() and
mama_close(). The change ensures that all initialization (one-time) and cleanup
only occurs once. It also ensures that the reference count never goes belowe
zero.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/mama.c | 39 ++++++++++++++++++++++++++++-----------
1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index 4142c16..cecfa4a 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -654,6 +654,8 @@ mama_openWithProperties (const char* path,
const char* statsLogging = "false";
const char* catchCallbackExceptions = NULL;

+ pthread_mutex_lock (&gImpl.myLock);
+
if (pthread_key_create(&last_err_key, NULL) != 0)
{
mama_log (MAMA_LOG_LEVEL_NORMAL, "WARNING!!! - CANNOT ALLOCATE KEY FOR ERRORS");
@@ -689,7 +691,14 @@ mama_openWithProperties (const char* path,
"********************************************************");
#endif

- if (gImpl.myRefCount++) return result;
+ if (0 != gImpl.myRefCount)
+ {
+ if (MAMA_STATUS_OK == result)
+ gImpl.myRefCount++;
+ pthread_mutex_unlock (&gImpl.myLock);
+ return result;
+ }
+ /* Code after this point is one-time initialization */

#ifdef WITH_INACTIVE_CHECK
mama_log (MAMA_LOG_LEVEL_WARN,
@@ -748,10 +757,10 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_openWithProperties(): "
"Could not create stats generator.");
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}

-
globalLogging = properties_Get (gProperties, "mama.statslogging.global.logging");
globalPublishing = properties_Get (gProperties, "mama.statslogging.global.publishing");
transportLogging = properties_Get (gProperties, "mama.statslogging.transport.logging");
@@ -842,7 +851,6 @@ mama_openWithProperties (const char* path,
}
}

-
if (mamaInternal_statsPublishingEnabled())
{
mamaInternal_loadStatsPublisher();
@@ -866,16 +874,16 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_SEVERE,
"mama_openWithProperties(): "
"At least one bridge must be specified");
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

if (!gDefaultPayload)
{
-
-
mama_log (MAMA_LOG_LEVEL_SEVERE,
"mama_openWithProperties(): "
"At least one payload must be specified");
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -893,6 +901,7 @@ mama_openWithProperties (const char* path,
"mama_openWithProperties(): "
"Error connecting to Entitlements Server");
mama_close();
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}
#endif /* WITH_ENTITLEMENTS */
@@ -929,6 +938,7 @@ mama_openWithProperties (const char* path,
if (MAMA_STATUS_OK != (result = mamaBridgeImpl_getInternalEventQueue (bridge,
&statsGenQueue)))
{
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}
}
@@ -938,6 +948,7 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_openWithProperties(): "
"Could not set queue for stats generator.");
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -946,10 +957,13 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_openWithProperties(): "
"Failed to enable stats logging");
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}
}

+ gImpl.myRefCount++;
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -1071,7 +1085,14 @@ mama_close ()
mamaMiddleware middleware = 0;
int payload = 0;

- if( !--gImpl.myRefCount )
+ pthread_mutex_lock (&gImpl.myLock);
+ if (gImpl.myRefCount == 0)
+ {
+ pthread_mutex_unlock (&gImpl.myLock);
+ return MAMA_STATUS_OK;
+ }
+
+ if (!--gImpl.myRefCount)
{
#ifdef WITH_ENTITLEMENTS
if( gEntitlementClient != 0 )
@@ -1120,7 +1141,6 @@ mama_close ()
gUnknownMsgStat = NULL;
}

-
if (gMessageStat)
{
mamaStat_destroy (gMessageStat);
@@ -1224,10 +1244,7 @@ mama_close ()
mama_freeAppContext(&appContext);

}
- if (gImpl.myRefCount < 0)
- {
- gImpl.myRefCount = 0;
- }
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
}

--
1.7.5.4


[PATCH 2/4] Add mama_openWithPropertiesCount() and mama_closeCount()

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

These methods take an additonal unsigned int* parameter that upon return
contains the the reference count for mama_openXXX() and mama_closeXXX(). This
allows applications to performa one-time global initialization when
the int is 1 and mama_openWithPropertiesCount() returns MAMA_STATUS_OK. Likewise
applications can clean up global data when the count is zero and
mama_closeCount() returns MAMA_STATUS_OK.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/mama.c | 58 +++++++++++++++++++++++++++++++++++------
mama/c_cpp/src/c/mama/mama.h | 45 ++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 9 deletions(-)

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index cecfa4a..7b6add9 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -643,8 +643,9 @@ mamaInternal_getDefaultPayload (void)
}

mama_status
-mama_openWithProperties (const char* path,
- const char* filename)
+mama_openWithPropertiesCount (const char* path,
+ const char* filename,
+ unsigned int* count)
{
mama_status result = MAMA_STATUS_OK;
mama_size_t numBridges = 0;
@@ -695,6 +696,10 @@ mama_openWithProperties (const char* path,
{
if (MAMA_STATUS_OK == result)
gImpl.myRefCount++;
+
+ if (count)
+ *count = gImpl.myRefCount;
+
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
@@ -757,6 +762,9 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_openWithProperties(): "
"Could not create stats generator.");
+ if (count)
+ *count = gImpl.myRefCount;
+
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
@@ -874,6 +882,9 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_SEVERE,
"mama_openWithProperties(): "
"At least one bridge must be specified");
+ if (count)
+ *count = gImpl.myRefCount;
+
pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}
@@ -883,6 +894,9 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_SEVERE,
"mama_openWithProperties(): "
"At least one payload must be specified");
+ if (count)
+ *count = gImpl.myRefCount;
+
pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}
@@ -901,6 +915,10 @@ mama_openWithProperties (const char* path,
"mama_openWithProperties(): "
"Error connecting to Entitlements Server");
mama_close();
+
+ if (count)
+ *count = gImpl.myRefCount;
+
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
@@ -938,6 +956,8 @@ mama_openWithProperties (const char* path,
if (MAMA_STATUS_OK != (result = mamaBridgeImpl_getInternalEventQueue (bridge,
&statsGenQueue)))
{
+ if (count)
+ *count = gImpl.myRefCount;
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
@@ -948,6 +968,8 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_openWithProperties(): "
"Could not set queue for stats generator.");
+ if (count)
+ *count = gImpl.myRefCount;
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
@@ -957,12 +979,16 @@ mama_openWithProperties (const char* path,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_openWithProperties(): "
"Failed to enable stats logging");
+ if (count)
+ *count = gImpl.myRefCount;
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
}

gImpl.myRefCount++;
+ if (count)
+ *count = gImpl.myRefCount;
pthread_mutex_unlock (&gImpl.myLock);
return result;
}
@@ -972,7 +998,14 @@ mama_open ()
{
/*Passing NULL as path and filename will result in the
default behaviour - mama.properties on $WOMBAT_PATH*/
- return mama_openWithProperties (NULL, NULL);
+ return mama_openWithPropertiesCount (NULL, NULL, NULL);
+}
+
+mama_status
+mama_openWithProperties (const char* path,
+ const char* filename)
+{
+ return mama_openWithPropertiesCount (path, filename, NULL);
}

mama_status
@@ -1079,7 +1112,7 @@ mama_getVersion (mamaBridge bridgeImpl)
}

mama_status
-mama_close ()
+mama_closeCount (unsigned int* count)
{
mama_status result = MAMA_STATUS_OK;
mamaMiddleware middleware = 0;
@@ -1088,6 +1121,8 @@ mama_close ()
pthread_mutex_lock (&gImpl.myLock);
if (gImpl.myRefCount == 0)
{
+ if (count)
+ *count = gImpl.myRefCount;
pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_OK;
}
@@ -1113,11 +1148,8 @@ mama_close ()
/* Look for a bridge for each of the payloads and close them */
for (payload = 0; payload != MAMA_PAYLOAD_MAX; ++payload)
{
- mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*) gImpl.myPayloads [(uint8_t)payload];
- if (impl)
- {
-
- }
+ /* mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*)
+ * gImpl.myPayloads [(uint8_t)payload];*/
gImpl.myPayloads[(uint8_t)payload] = NULL;
}

@@ -1244,10 +1276,18 @@ mama_close ()
mama_freeAppContext(&appContext);

}
+ if (count)
+ *count = gImpl.myRefCount;
pthread_mutex_unlock (&gImpl.myLock);
return result;
}

+mama_status
+mama_close (void)
+{
+ return mama_closeCount (NULL);
+}
+
/**
* Start processing messages.
*/
diff --git a/mama/c_cpp/src/c/mama/mama.h b/mama/c_cpp/src/c/mama/mama.h
index 658bce6..557ac2c 100644
--- a/mama/c_cpp/src/c/mama/mama.h
+++ b/mama/c_cpp/src/c/mama/mama.h
@@ -220,6 +220,40 @@ extern "C"
extern mama_status
mama_openWithProperties (const char* path,
const char* filename);
+ /**
+ * Initialize MAMA.
+ *
+ * Allows users of the API to override the default behavior of mama_open()
+ * where a file mama.properties is required to be located in the directory
+ * specified by \$WOMBAT_PATH.
+ *
+ * The properties file must have the same structure as a standard
+ * mama.properties file.
+ *
+ * If null is passed as the path the API will look for the properties file on
+ * the \$WOMBAT_PATH.
+ *
+ * If null is passed as the filename the API will look for the default
+ * filename of mama.properties.
+ *
+ * The count value on return will be the number of times that mama_openXxx()
+ * has ben invoked successfully. Applicatiins can use this to perform
+ * one-time initialization when the value is 1 and the return is
+ * MAMA_STATUS_OK
+ *
+ * @param path Fully qualified path to the directory containing the properties
+ * file
+ * @param filename The name of the file containing MAMA properties.
+ * @param count The number of times mama_OpenXXX() has been called
+ * successfully.
+ *
+ * @return mama_status Whether the call was successful or not.
+ */
+ MAMAExpDLL
+ extern mama_status
+ mama_openWithPropertiesCount (const char* path,
+ const char* filename,
+ unsigned int* count);

/**
* Set a specific property for the API.
@@ -291,6 +325,17 @@ extern "C"
MAMAExpDLL
extern mama_status
mama_close (void);
+
+ /**
+ * Close MAMA and free all associated resource.
+ *
+ * @param count Filled with the number of times mama has been opened
+ * successfully. Applications can perform global one-time cleanup when this
+ * value is 0 and the return value is MAMA_STATUS_OK.
+ */
+ MAMAExpDLL
+ extern mama_status
+ mama_closeCount (unsigned int* count);

/**
* Return the version information for the library.
--
1.7.5.4


[PATCH 3/4] Added Per-bridge Reference Count

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

Added a reference count to mamaBridgeImpl struct. mama_start() and mama_stop()
increment and decrement this reference count to determine when initialization is
required and when the bridges can be unloaded. The internal registerBridge()
method ensures that it is properly initialized to 0.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/bridge.h | 3 +++
mama/c_cpp/src/c/mama.c | 41 +++++++++++++++++++++++++++++++++++++----
2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/mama/c_cpp/src/c/bridge.h b/mama/c_cpp/src/c/bridge.h
index 5a9588b..5ab7707 100644
--- a/mama/c_cpp/src/c/bridge.h
+++ b/mama/c_cpp/src/c/bridge.h
@@ -681,6 +681,9 @@ typedef mama_status
*/
typedef struct mamaBridgeImpl
{
+ /* Used by mama_start() and mama_stop(). */
+ unsigned int mRefCount;
+
/*The default event queue is now middleware specific. (Originally global)*/
mamaQueue mDefaultEventQueue;

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index 7b6add9..2623f29 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -1295,6 +1295,8 @@ mama_status
mama_start (mamaBridge bridgeImpl)
{
mamaBridgeImpl* impl = (mamaBridgeImpl*)bridgeImpl;
+ mama_status rval = MAMA_STATUS_OK;
+ unsigned int prevRefCnt = 0;

if (!impl)
{
@@ -1310,8 +1312,25 @@ mama_start (mamaBridge bridgeImpl)
return MAMA_STATUS_INVALID_QUEUE;
}

- /*Delegate to the bridge specific implementation*/
- return impl->bridgeStart (impl->mDefaultEventQueue);
+ pthread_mutex_lock(&gImpl.myLock);
+ prevRefCnt = impl->mRefCount++;
+ pthread_mutex_unlock(&gImpl.myLock);
+
+ if (prevRefCnt > 0)
+ return MAMA_STATUS_OK;
+
+ /* Delegate to the bridge specific implementation */
+ /* Can't hold lock because bridgeStart blocks */
+ rval = impl->bridgeStart (impl->mDefaultEventQueue);
+
+ if (rval != MAMA_STATUS_OK)
+ {
+ pthread_mutex_lock(&gImpl.myLock);
+ impl->mRefCount--;
+ pthread_mutex_unlock(&gImpl.myLock);
+ }
+
+ return rval;
}

struct startBackgroundClosure
@@ -1385,6 +1404,7 @@ mama_status
mama_stop (mamaBridge bridgeImpl)
{
mamaBridgeImpl* impl = (mamaBridgeImpl*)bridgeImpl;
+ mama_status rval = MAMA_STATUS_OK;

if (!impl)
{
@@ -1402,7 +1422,19 @@ mama_stop (mamaBridge bridgeImpl)
}

/*Delegate to the bridge specific implementation*/
- return impl->bridgeStop (impl->mDefaultEventQueue);
+ pthread_mutex_lock(&gImpl.myLock);
+ if (impl->mRefCount > 0)
+ {
+ impl->mRefCount--;
+ if(impl->mRefCount == 0)
+ {
+ rval = impl->bridgeStop (impl->mDefaultEventQueue);
+ if (MAMA_STATUS_OK != rval)
+ impl->mRefCount++;
+ }
+ }
+ pthread_mutex_unlock(&gImpl.myLock);
+ return rval;
}

/**
@@ -1749,7 +1781,6 @@ enableEntitlements (const char **servers)

#endif

-
void
mamaInternal_registerBridge (mamaBridge bridge,
const char* middlewareName)
@@ -1767,6 +1798,7 @@ mamaInternal_registerBridge (mamaBridge bridge,
}

gImpl.myBridges[middleware] = bridge;
+ ((mamaBridgeImpl*)(bridge))->mRefCount = 0;
}

mama_status
@@ -1779,6 +1811,7 @@ mama_setDefaultPayload (char id)

return MAMA_STATUS_OK;
}
+
mama_status
mama_loadPayloadBridge (mamaPayloadBridge* impl,
const char* payloadName)
--
1.7.5.4


[PATCH 4/4] Make sure that we load and unload bridges properly

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

These changes ensure that we hold the lock while opening and closing payload and
messaging brdiges. Additionally, we store the shared library handles so we can
close them when cleaning up.

Signed-off-by: John Gray <jgray@nyx.com>
---
mama/c_cpp/src/c/mama.c | 100 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 87 insertions(+), 13 deletions(-)

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index 2623f29..0657286 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -187,6 +187,11 @@ static mamaImpl gImpl = {{0}, {0}, {0}, {0}, 0, PTHREAD_MUTEX_INITIALIZER};
/* Private Function Prototypes. */
/* ************************************************************************* */

+static mama_status
+mama_loadBridgeWithPathInternal (mamaBridge* impl,
+ const char* middlewareName,
+ const char* path,
+ uint8_t lock);

/* Description : This function will free any memory associated with a
* mamaApplicationContext object but will not free the
@@ -332,8 +337,12 @@ static mama_status mamaInternal_loadStatsPublisher ()
}

/* Will load the bridge if its not already loaded */
+ /* Lock is alread acquired at this point */
if (MAMA_STATUS_OK !=
- (status = mama_loadBridge (&bridge, statsLogMiddlewareName)))
+ (status = mama_loadBridgeWithPathInternal (&bridge,
+ statsLogMiddlewareName,
+ NULL,
+ 0)))
{
mama_log (MAMA_LOG_LEVEL_ERROR,
"mamaInternal_loadStatsLogger(): ",
@@ -914,12 +923,12 @@ mama_openWithPropertiesCount (const char* path,
mama_log (MAMA_LOG_LEVEL_SEVERE,
"mama_openWithProperties(): "
"Error connecting to Entitlements Server");
+ pthread_mutex_unlock (&gImpl.myLock);
mama_close();

if (count)
*count = gImpl.myRefCount;

- pthread_mutex_unlock (&gImpl.myLock);
return result;
}
#endif /* WITH_ENTITLEMENTS */
@@ -1151,6 +1160,11 @@ mama_closeCount (unsigned int* count)
/* mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*)
* gImpl.myPayloads [(uint8_t)payload];*/
gImpl.myPayloads[(uint8_t)payload] = NULL;
+ if(gImpl.myPayloadLibraries[(uint8_t)payload])
+ {
+ closeSharedLib (gImpl.myPayloadLibraries[(uint8_t)payload]);
+ gImpl.myPayloadLibraries[(uint8_t)payload] = NULL;
+ }
}

gDefaultPayload = NULL;
@@ -1250,8 +1264,10 @@ mama_closeCount (unsigned int* count)
mamaMiddleware_convertToString (middleware));

}
+ gImpl.myBridges[middleware] = NULL;
+ closeSharedLib (gImpl.myBridgeLibraries[middleware]);
+ gImpl.myBridgeLibraries[middleware] = NULL;
}
- gImpl.myBridges[middleware] = NULL;
}

/* The properties must not be closed down until after the bridges have been destroyed. */
@@ -1796,9 +1812,11 @@ mamaInternal_registerBridge (mamaBridge bridge,
middlewareName ? middlewareName : "");
return;
}
-
+
+ pthread_mutex_lock (&gImpl.myLock);
gImpl.myBridges[middleware] = bridge;
((mamaBridgeImpl*)(bridge))->mRefCount = 0;
+ pthread_mutex_unlock (&gImpl.myLock);
}

mama_status
@@ -1813,8 +1831,9 @@ mama_setDefaultPayload (char id)
}

mama_status
-mama_loadPayloadBridge (mamaPayloadBridge* impl,
- const char* payloadName)
+mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
+ const char* payloadName,
+ uint8_t lock)
{
char bridgeImplName [256];
char initFuncName [256];
@@ -1829,6 +1848,9 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
snprintf (bridgeImplName, 256, "mama%simpl",
payloadName);

+ if (lock)
+ pthread_mutex_lock (&gImpl.myLock);
+
bridgeLib = openSharedLib (bridgeImplName, NULL);

if (!bridgeLib)
@@ -1839,6 +1861,8 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
"Could not open payload bridge library [%s] [%s]",
bridgeImplName ? bridgeImplName : "",
getLibError());
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -1855,11 +1879,18 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
initFuncName ? initFuncName : "",
bridgeImplName ? bridgeImplName : "");
closeSharedLib (bridgeLib);
+
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
+
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

if (MAMA_STATUS_OK != (status = initFunc (impl, &payloadChar)))
{
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
+
return status;
}

@@ -1867,6 +1898,10 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
{
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_loadPayloadBridge(): Error in [%s] ", initFuncName);
+
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
+
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -1876,7 +1911,11 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
"mama_loadPayloadBridge(): "
"Payload bridge %s already loaded",
payloadName);
- return MAMA_STATUS_OK;
+
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
+
+ return MAMA_STATUS_OK;
}

gImpl.myPayloads [(int)payloadChar] = *impl;
@@ -1891,10 +1930,20 @@ mama_loadPayloadBridge (mamaPayloadBridge* impl,
"mama_loadPayloadBridge(): "
"Sucessfully loaded %s payload bridge from library [%s]",
payloadName, bridgeImplName);
+
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);

return MAMA_STATUS_OK;
}

+mama_status
+mama_loadPayloadBridge (mamaPayloadBridge* impl,
+ const char* payloadName)
+{
+ return mama_loadPayloadBridgeInternal (impl, payloadName, 1);
+}
+
int
mamaInternal_generateLbmStats ()
{
@@ -1910,9 +1959,10 @@ mama_loadBridge (mamaBridge* impl,
}

mama_status
-mama_loadBridgeWithPath (mamaBridge* impl,
- const char* middlewareName,
- const char* path)
+mama_loadBridgeWithPathInternal (mamaBridge* impl,
+ const char* middlewareName,
+ const char* path,
+ uint8_t lock)
{
char bridgeImplName [256];
char initFuncName [256];
@@ -1934,15 +1984,19 @@ mama_loadBridgeWithPath (mamaBridge* impl,
"mama_loadBridge(): Invalid middleware [%s]",
middlewareName);
}
+
+ if (lock)
+ pthread_mutex_lock (&gImpl.myLock);

/* Check if a bridge has already been initialized for the middleware */
if (gImpl.myBridges [middleware])
{
*impl = gImpl.myBridges [middleware];
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_OK;
}

-
snprintf (bridgeImplName, 256, "mama%simpl",
middlewareName);

@@ -1950,7 +2004,6 @@ mama_loadBridgeWithPath (mamaBridge* impl,

if (!bridgeLib)
{
-
if (path)
{
mama_log (MAMA_LOG_LEVEL_ERROR,
@@ -1968,6 +2021,8 @@ mama_loadBridgeWithPath (mamaBridge* impl,
bridgeImplName ? bridgeImplName : "",
getLibError());
}
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -1984,6 +2039,8 @@ mama_loadBridgeWithPath (mamaBridge* impl,
initFuncName ? initFuncName : "",
bridgeImplName ? bridgeImplName : "");
closeSharedLib (bridgeLib);
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -1993,6 +2050,8 @@ mama_loadBridgeWithPath (mamaBridge* impl,
{
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_loadBridge(): Error in [%s] ", initFuncName);
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -2005,22 +2064,37 @@ mama_loadBridgeWithPath (mamaBridge* impl,
result = ((mamaBridgeImpl*)(*impl))->bridgeOpen (*impl);

if (MAMA_STATUS_OK != result)
+ {
+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return result;
+ }

if (((mamaBridgeImpl*)(*impl))->bridgeGetDefaultPayloadId(&payloadName, &payloadId) == MAMA_STATUS_OK)
{
if (!gImpl.myPayloads [(uint8_t)payloadId])
{
mamaPayloadBridge payloadImpl;
- mama_loadPayloadBridge (&payloadImpl,payloadName);
+ mama_loadPayloadBridgeInternal (&payloadImpl,payloadName,0);
}
}

gImpl.myBridges [middleware] = *impl;
+ gImpl.myBridgeLibraries [middleware] = bridgeLib;

+ if (lock)
+ pthread_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_OK;
}

+mama_status
+mama_loadBridgeWithPath (mamaBridge* impl,
+ const char* middlewareName,
+ const char* path)
+{
+ return mama_loadBridgeWithPathInternal(impl, middlewareName, path, 1);
+}
+
/*
* Function pointer type for calling getVersion in the wrapper
*/
--
1.7.5.4


Bridge Error Code

Mark Spielman
 

I am in the process of implementing a bridge support for a new middleware component in openMAMA.  During implementation I have a need to return a sensible mama_status code for a generic bridge error.  Something equivalent to handling unexpected internal errors.  I see there’s the following in status.h:

 

/* No bridge */

    MAMA_STATUS_NO_BRIDGE_IMPL              = 26,

 

But I’m looking more for something like: MAMA_STATUS_BRDIGE_INTERNAL_ERROR

 

Can you suggest what the appropriate code is.  In general I will try to match up to existing codes wherever possible.

 

Cheers,

Mark

 

 

 

Mark Spielman

Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021

mark.spielman@...

www.solacesystems.com

 

 


Re: Bridge Error Code

Mike Schonberg <mschonberg@...>
 

Mark,

 

MAMA_STATUS_PLATFORM is used for generic bridge errors. It might be useful to add some more specific error codes as well.

 

Regards,

-Mike

 

From: openmama-dev-bounces@... [mailto:openmama-dev-bounces@...] On Behalf Of Mark Spielman
Sent: Tuesday, March 27, 2012 12:08 PM
To: openmama-dev@...
Subject: [Openmama-dev] Bridge Error Code

 

I am in the process of implementing a bridge support for a new middleware component in openMAMA.  During implementation I have a need to return a sensible mama_status code for a generic bridge error.  Something equivalent to handling unexpected internal errors.  I see there’s the following in status.h:

 

/* No bridge */

    MAMA_STATUS_NO_BRIDGE_IMPL              = 26,

 

But I’m looking more for something like: MAMA_STATUS_BRDIGE_INTERNAL_ERROR

 

Can you suggest what the appropriate code is.  In general I will try to match up to existing codes wherever possible.

 

Cheers,

Mark

 

 

 

Mark Spielman

Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021

mark.spielman@...

www.solacesystems.com

 

 




Please consider the environment before printing this email.

Visit our website at http://www.nyse.com
*****************************************************************************
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.




Getting a bridge build version

Mark Spielman
 

I’m interested in any best practices for getting a build version to report as part of the bridgeImpl->bridgeGetVersion() method.  I’ve found what looks to be a reasonable version in the file: mama/c_cpp/config.h.  I believe this is what AVIS is using.  In OpenMAMA 1.1 it’s currently set to:

 

/* Version number of package */

#define VERSION "5.0.3rc11"

 

Or it seems I could just reuse the version from mama/c_cpp/c/src/c/mama/version.h as the equivalent of a bridge build version.  Any suggestions?  I’d like to be able to track a version that identifies a particular build of bridge code to correlate this for bug tracking.

 

Cheers,

Mark

 

 

Mark Spielman

Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021

mark.spielman@...

www.solacesystems.com

 

 


[Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

Mark Spielman
 

This patch introduces a .gitignore file to force git to skip known build artifacts when displaying status information.

Signed-off-by: Mark Spielman <mark.spielman@solacesystems.com>

---

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..182bfd9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,75 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.lo
+*.la
+
+# Temporary Directories #
+#########################
+.dep*
+.lib*
+
+# GNU Automake #
+################
+Makefile
+Makefile.in
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+
+# OpenMAMA Specific #
+# ###################
+common/c_cpp/aclocal.m4
+common/c_cpp/autom4te.cache/
+common/c_cpp/config.h
+common/c_cpp/config.h.in
+common/c_cpp/config.status
+common/c_cpp/configure
+common/c_cpp/etc/
+common/c_cpp/libtool
+common/c_cpp/src/c/properties.c
+common/c_cpp/src/c/version.h
+common/c_cpp/stamp-h1
+mama/c_cpp/aclocal.m4
+mama/c_cpp/autom4te.cache/
+mama/c_cpp/config.h
+mama/c_cpp/config.h.in
+mama/c_cpp/config.h.in~
+mama/c_cpp/config.status
+mama/c_cpp/configure
+mama/c_cpp/doc/c/
+mama/c_cpp/doxyconfig-c
+mama/c_cpp/etc/
+mama/c_cpp/libtool
+mama/c_cpp/src/c/bridge/solace/Makefile.am
+mama/c_cpp/src/c/mama/version.h
+mama/c_cpp/src/c/version.c
+mama/c_cpp/stamp-h1


Re: Getting a bridge build version

Michael Schonberg <mschonberg@...>
 

On 03/27/2012 01:12 PM, Mark Spielman wrote:
I'm interested in any best practices for getting a build version to report as part of the bridgeImpl->bridgeGetVersion() method. I've found what looks to be a reasonable version in the file: mama/c_cpp/config.h. I believe this is what AVIS is using. In OpenMAMA 1.1 it's currently set to:
It is largely up to the bridge implementor; however, it makes sense to identify both the version of the bridge code and the underlying middleware if it is available.

/* Version number of package */
#define VERSION "5.0.3rc11"
Avis does not provide version information through the API so the implementor simply used the MAMA version that was current at the time. Future releases of the Avis bridge will return "not implemented" for this method.

Or it seems I could just reuse the version from mama/c_cpp/c/src/c/mama/version.h as the equivalent of a bridge build version. Any suggestions? I'd like to be able to track a version that identifies a particular build of bridge code to correlate this for bug tracking.

Cheers,
Mark


Mark Spielman
Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021
mark.spielman@solacesystems.com<mailto:mark.spielman@solacesystems.com>
www.solacesystems.com<http://www.solacesystems.com/>





_______________________________________________
Openmama-dev mailing list
Openmama-dev@lists.openmama.org
http://lists.openmama.org/listinfo/openmama-dev
Regards,
-Mike


Re: [Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

Michael Schonberg <mschonberg@...>
 

This is very useful.

I would remove mama/c_cpp/config.h.in~ and add *~ and *.swp for temporary
files generated by vi.

-Mike

On 03/27/2012 01:53 PM, Mark Spielman wrote:
This patch introduces a .gitignore file to force git to skip known build artifacts when displaying status information.

Signed-off-by: Mark Spielman <mark.spielman@solacesystems.com>

---

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..182bfd9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,75 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.lo
+*.la
+
+# Temporary Directories #
+#########################
+.dep*
+.lib*
+
# Temporary Files
#################
*.swp
*~

+# GNU Automake #
+################
+Makefile
+Makefile.in
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+
+# OpenMAMA Specific #
+# ###################
+common/c_cpp/aclocal.m4
+common/c_cpp/autom4te.cache/
+common/c_cpp/config.h
+common/c_cpp/config.h.in
+common/c_cpp/config.status
+common/c_cpp/configure
+common/c_cpp/etc/
+common/c_cpp/libtool
+common/c_cpp/src/c/properties.c
+common/c_cpp/src/c/version.h
+common/c_cpp/stamp-h1
+mama/c_cpp/aclocal.m4
+mama/c_cpp/autom4te.cache/
+mama/c_cpp/config.h
+mama/c_cpp/config.h.in
+mama/c_cpp/config.status
+mama/c_cpp/configure
+mama/c_cpp/doc/c/
+mama/c_cpp/doxyconfig-c
+mama/c_cpp/etc/
+mama/c_cpp/libtool
+mama/c_cpp/src/c/bridge/solace/Makefile.am
+mama/c_cpp/src/c/mama/version.h
+mama/c_cpp/src/c/version.c
+mama/c_cpp/stamp-h1
_______________________________________________
Openmama-dev mailing list
Openmama-dev@lists.openmama.org
http://lists.openmama.org/listinfo/openmama-dev


Re: [Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

Mark Spielman
 

Hi Mike,

I appreciate the feedback. Below is an updated patch. Let me know if there are any other suggested edits.

Cheers,
Mark

---------

This patch introduces a .gitignore file to force git to skip known build artifacts when displaying status information.

Signed-off-by: Mark Spielman <mark.spielman@solacesystems.com>

---

iff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d018ef3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,76 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.lo
+*.la
+
+# Temporary Directories #
+#########################
+.dep*
+.lib*
+
+# GNU Automake #
+################
+Makefile
+Makefile.in
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+*~
+*.swp
+
+# OpenMAMA Specific #
+# ###################
+common/c_cpp/aclocal.m4
+common/c_cpp/autom4te.cache/
+common/c_cpp/config.h
+common/c_cpp/config.h.in
+common/c_cpp/config.status
+common/c_cpp/configure
+common/c_cpp/etc/
+common/c_cpp/libtool
+common/c_cpp/src/c/properties.c
+common/c_cpp/src/c/version.h
+common/c_cpp/stamp-h1
+mama/c_cpp/aclocal.m4
+mama/c_cpp/autom4te.cache/
+mama/c_cpp/config.h
+mama/c_cpp/config.h.in
+mama/c_cpp/config.status
+mama/c_cpp/configure
+mama/c_cpp/doc/c/
+mama/c_cpp/doxyconfig-c
+mama/c_cpp/etc/
+mama/c_cpp/libtool
+mama/c_cpp/src/c/bridge/solace/Makefile.am
+mama/c_cpp/src/c/mama/version.h
+mama/c_cpp/src/c/version.c
+mama/c_cpp/stamp-h1

-----Original Message-----
From: openmama-dev-bounces@lists.openmama.org [mailto:openmama-dev-bounces@lists.openmama.org] On Behalf Of Michael Schonberg
Sent: Tuesday, March 27, 2012 8:03 PM
To: openmama-dev@lists.openmama.org
Subject: Re: [Openmama-dev] [Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

This is very useful.

I would remove mama/c_cpp/config.h.in~ and add *~ and *.swp for temporary files generated by vi.

-Mike

[snip]

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


Re: Getting a bridge build version

Mark Spielman
 

Mike,

I believe it makes most sense for me to use the mama/version.h as it seems to be the correct place to get version information. One follow on question. Why even in the tar package I downloaded from OpenMAMA for 1.1 is the following still present in mama/version.h.

#define MAMA_VERSION "openmama DEVRELEASE.."

And this is the value I get when I print the global mama_version. To me this should be set to something like 5.0.3rc11 which would be the concat of:

#define MAMA_VERSION_MAJOR 5
#define MAMA_VERSION_MINOR 0
#define MAMA_VERSION_RELEASE 3rc11

Cheers,
Mark

-----Original Message-----
From: Michael Schonberg [mailto:mikeschonberg@gmail.com] On Behalf Of Michael Schonberg
Sent: Tuesday, March 27, 2012 5:00 PM
To: Mark Spielman
Cc: openmama-dev@lists.openmama.org
Subject: Re: [Openmama-dev] Getting a bridge build version

On 03/27/2012 01:12 PM, Mark Spielman wrote:
I'm interested in any best practices for getting a build version to report as part of the bridgeImpl->bridgeGetVersion() method. I've found what looks to be a reasonable version in the file: mama/c_cpp/config.h. I believe this is what AVIS is using. In OpenMAMA 1.1 it's currently set to:
It is largely up to the bridge implementor; however, it makes sense to identify both the version of the bridge code and the underlying middleware if it is available.

/* Version number of package */
#define VERSION "5.0.3rc11"
Avis does not provide version information through the API so the implementor simply used the MAMA version that was current at the time. Future releases of the Avis bridge will return "not implemented" for this method.

Or it seems I could just reuse the version from mama/c_cpp/c/src/c/mama/version.h as the equivalent of a bridge build version. Any suggestions? I'd like to be able to track a version that identifies a particular build of bridge code to correlate this for bug tracking.

Cheers,
Mark


Mark Spielman
Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021
mark.spielman@solacesystems.com<mailto:mark.spielman@solacesystems.com
www.solacesystems.com<http://www.solacesystems.com/>




_______________________________________________
Openmama-dev mailing list
Openmama-dev@lists.openmama.org
http://lists.openmama.org/listinfo/openmama-dev
Regards,
-Mike


[PATCH] [mama] Use "ft" as default FT transport name

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

When setting up fault tolerance use "ft" as the transport name for reading
properties if the call does not provide a transport.

Signed-off-by: Michael Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/ft.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/mama/c_cpp/src/c/ft.c b/mama/c_cpp/src/c/ft.c
index efbc16d..0a7931c 100644
--- a/mama/c_cpp/src/c/ft.c
+++ b/mama/c_cpp/src/c/ft.c
@@ -946,18 +946,23 @@ multicastFt_setup (

mamaFtMemberImpl* impl = (mamaFtMemberImpl*) member;

- if (!impl || !groupName || !transport)
+ if (!impl || !groupName)
return MAMA_STATUS_INVALID_ARG;

/* Get the transport name. */
- status = mamaTransport_getName(transport, &transportName);
- if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' ==
- transportName[0]))
+ if(transport)
{
- mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name "
- "is invalid");
- return MAMA_STATUS_INVALID_ARG;
+ status = mamaTransport_getName(transport, &transportName);
+ if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' ==
+ transportName[0]))
+ {
+ mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name "
+ "is invalid");
+ return MAMA_STATUS_INVALID_ARG;
+ }
}
+ else
+ transportName = "ft";

ftInterface = multicastFt_getProperty(propertyName,
"mama.multicast.transport.%s.interface", transportName);
--
1.7.7.6


[PATCH 00/30] Preparing for Windows Support

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

This rather large patch set introduces the changes required for Windows support.
Prior to OpenMAMA, MAMA supported other operating systems (Windows and Solaris)
through conditional compilation with ifdef's. This approach proved messy and
difficult to maintain.

For OpenMAMA, we removed most of the "#ifdef WIN32" blocks with the intention of
reintroducing Windows support in a better way. The following patches move all of
the Windows specific code to the windows subdirectory in common and puts the
Linux equivalents in a linux subdirectory when necessary. Most of the
portability layer consists of macros and small inline functions and is almost
entirely identical to the old #ifdef code; however, rather than scattering it
throughout the code base we have it all in one place.

This should greatly simplify future ports to Solaris and other platform:
implementors only need to reproduce the compatibility layer for the new
platform.

NOTE: The build infrastructure for Windows is not part of this patch set. It
will be checked in with the C++, Java and MAMDA support in the next few weeks.

Michael Schonberg (29):
Move Linux Specific #includes and Macros
Moved Calling Convention from wConfig.h to linux/port.h
Moved environment.c to linux/environment.c
Moved linux code from machine.c to linux/machine.c
Moved platform.c to linux/platform.c
Moved wincompat.h contents to _os_/port.h
Changes for queue.c to build on windows
wlock.c changes for windows support
Preparing timer.c and timer.c for windows support
Move wSemaphore.c to linx/wSemaphroe.c
Moved macros for inline functions to _os_/port.h
Added wthread_global_mutex macros
Header changes for windows support
Prepare ft.c for Windows support
Removed PATHSEP macro
Added Thread Local Storage
Added getHostName and getIpAddress.
mama.c changes for windows support
Add wtimegm macro for poritning timegm
Correct Method Signatures for Linking On Windows
Correct windows calling convention for queue
Conflation manager fixes for windows
Replaced numerous #ifdef WIN32 with port.h
Removed #ifdef WIN32 from playbackFileParser
Adding new common/../windows/* files
Changes for Windows
Added wdlXXX macos to linux/port.h
Moved port.h to wombat sub directory
Renamed resolve_ip to wresolve_ip

Mike Schonberg (1):
Moved wombat/wInterlocked.h to Linux directory

common/c_cpp/configure.ac | 13 +
common/c_cpp/src/c/MRSWLock.c | 2 +-
common/c_cpp/src/c/Makefile.am | 3 +
common/c_cpp/src/c/destroyHandle.c | 1 +
common/c_cpp/src/c/environment.c | 59 --
common/c_cpp/src/c/linux/environment.c | 59 ++
common/c_cpp/src/c/linux/machine.c | 599 ++++++++++++++++++++
common/c_cpp/src/c/linux/network.c | 195 +++++++
common/c_cpp/src/c/linux/platform.c | 84 +++
common/c_cpp/src/c/linux/port.h | 181 ++++++
common/c_cpp/src/c/linux/wConfig.h | 40 ++
common/c_cpp/src/c/linux/wInterlocked.h | 142 +++++
common/c_cpp/src/c/linux/wSemaphore.c | 57 ++
common/c_cpp/src/c/list.c | 6 +-
common/c_cpp/src/c/machine.c | 575 +-------------------
common/c_cpp/src/c/platform.c | 88 ---
common/c_cpp/src/c/platform.h | 21 -
common/c_cpp/src/c/properties.l | 16 +-
common/c_cpp/src/c/property.c | 4 +-
common/c_cpp/src/c/queue.c | 110 ++---
common/c_cpp/src/c/strutils.c | 7 +-
common/c_cpp/src/c/systree.h | 4 -
common/c_cpp/src/c/timers.c | 176 +++---
common/c_cpp/src/c/timers.h | 5 +-
common/c_cpp/src/c/wSemaphore.c | 192 -------
common/c_cpp/src/c/windows/environment.c | 81 +++
common/c_cpp/src/c/windows/lock.h | 82 +++
common/c_cpp/src/c/windows/machine_win.c | 213 +++++++
common/c_cpp/src/c/windows/mmap.h | 28 +
common/c_cpp/src/c/windows/network.c | 87 +++
common/c_cpp/src/c/windows/platform.c | 84 +++
common/c_cpp/src/c/windows/port.c | 276 +++++++++
common/c_cpp/src/c/windows/port.h | 251 ++++++++
common/c_cpp/src/c/windows/wSemaphore.c | 147 +++++
common/c_cpp/src/c/windows/wombat/targetsxs.h | 38 ++
common/c_cpp/src/c/windows/wombat/wConfig.h | 101 ++++
common/c_cpp/src/c/windows/wombat/wInterlocked.h | 97 ++++
common/c_cpp/src/c/wlock.c | 11 +-
common/c_cpp/src/c/wlock.h | 5 -
common/c_cpp/src/c/wombat/queue.h | 67 +--
common/c_cpp/src/c/wombat/strutils.h | 7 -
common/c_cpp/src/c/wombat/wCommon.h | 27 +-
common/c_cpp/src/c/wombat/wConfig.h | 99 +----
common/c_cpp/src/c/wombat/wInterlocked.h | 142 -----
common/c_cpp/src/c/wombat/wSemaphore.h | 51 +--
common/c_cpp/src/c/wombat/wincompat.h | 49 +--
mama/c_cpp/src/c/bridge/avis/bridge.c | 5 +-
mama/c_cpp/src/c/bridge/avis/msg.c | 5 +-
mama/c_cpp/src/c/bridge/avis/transportbridge.c | 5 +-
mama/c_cpp/src/c/conflation/connection.c | 4 +-
mama/c_cpp/src/c/conflation/connection_int.h | 10 +-
mama/c_cpp/src/c/conflation/manager.c | 10 +-
mama/c_cpp/src/c/conflation/manager_int.h | 4 +-
mama/c_cpp/src/c/conflation/serverconnection_int.h | 8 +-
mama/c_cpp/src/c/datetime.c | 5 +-
mama/c_cpp/src/c/fileutils.c | 1 -
mama/c_cpp/src/c/ft.c | 203 ++------
mama/c_cpp/src/c/imagerequest.c | 2 +-
mama/c_cpp/src/c/imagerequest.h | 2 +-
mama/c_cpp/src/c/mama.c | 163 ++----
mama/c_cpp/src/c/mama/conflation/manager.h | 16 +-
mama/c_cpp/src/c/mama/datetime.h | 4 +-
mama/c_cpp/src/c/mama/fielddesc.h | 4 +-
mama/c_cpp/src/c/mama/ft.h | 4 +-
mama/c_cpp/src/c/mama/mama.h | 14 +-
mama/c_cpp/src/c/mama/msg.h | 14 +-
mama/c_cpp/src/c/mama/msgfield.h | 4 +-
mama/c_cpp/src/c/mama/subscriptiontype.h | 3 +-
mama/c_cpp/src/c/mama/timezone.h | 4 +-
mama/c_cpp/src/c/mama/types.h | 2 +-
mama/c_cpp/src/c/msg.c | 2 +-
mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c | 4 +-
mama/c_cpp/src/c/playback/playbackFileParser.c | 31 +-
mama/c_cpp/src/c/playback/playbackFileParser.h | 10 +-
mama/c_cpp/src/c/playback/playbackpublisher.h | 5 +-
mama/c_cpp/src/c/priceimpl.c | 19 +-
mama/c_cpp/src/c/queue.c | 2 +-
mama/c_cpp/src/c/senderId.c | 7 +-
mama/c_cpp/src/c/stat.c | 2 +-
mama/c_cpp/src/c/statsgenerator.c | 2 +-
mama/c_cpp/src/c/statslogger.c | 4 +-
mama/c_cpp/src/c/syncresponder.c | 4 +-
mama/c_cpp/src/c/timezone.c | 36 +-
mama/c_cpp/src/examples/c/mamainboxc.c | 15 +-
mama/c_cpp/src/examples/c/mamaio.c | 9 +-
mama/c_cpp/src/examples/c/mamalistenc.c | 56 +-
mama/c_cpp/src/examples/c/mamaproxyc.c | 46 +-
mama/c_cpp/src/examples/c/mamapublisherc.c | 19 +-
mama/c_cpp/src/examples/c/mamasubscriberc.c | 20 +-
.../src/examples/c/mamasymbollistsubscriberc.c | 44 +-
mama/c_cpp/src/regression/c/tools/basicinbox.c | 31 +-
mama/c_cpp/src/regression/c/tools/basicpub.c | 50 +--
mama/c_cpp/src/regression/c/tools/basicsub.c | 61 +--
93 files changed, 3329 insertions(+), 2228 deletions(-)
delete mode 100644 common/c_cpp/src/c/environment.c
create mode 100644 common/c_cpp/src/c/linux/environment.c
create mode 100644 common/c_cpp/src/c/linux/machine.c
create mode 100644 common/c_cpp/src/c/linux/network.c
create mode 100644 common/c_cpp/src/c/linux/platform.c
create mode 100644 common/c_cpp/src/c/linux/port.h
create mode 100644 common/c_cpp/src/c/linux/wConfig.h
create mode 100644 common/c_cpp/src/c/linux/wInterlocked.h
create mode 100644 common/c_cpp/src/c/linux/wSemaphore.c
delete mode 100644 common/c_cpp/src/c/platform.c
delete mode 100644 common/c_cpp/src/c/wSemaphore.c
create mode 100644 common/c_cpp/src/c/windows/environment.c
create mode 100644 common/c_cpp/src/c/windows/lock.h
create mode 100644 common/c_cpp/src/c/windows/machine_win.c
create mode 100644 common/c_cpp/src/c/windows/mmap.h
create mode 100644 common/c_cpp/src/c/windows/network.c
create mode 100644 common/c_cpp/src/c/windows/platform.c
create mode 100644 common/c_cpp/src/c/windows/port.c
create mode 100644 common/c_cpp/src/c/windows/port.h
create mode 100644 common/c_cpp/src/c/windows/wSemaphore.c
create mode 100644 common/c_cpp/src/c/windows/wombat/targetsxs.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wConfig.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wInterlocked.h
mode change 100644 => 120000 common/c_cpp/src/c/wombat/wConfig.h
delete mode 100644 common/c_cpp/src/c/wombat/wInterlocked.h

--
1.7.7.6

61 - 80 of 2305