diff --git a/doc/pol.pl.md b/doc/pol.pl.md index b2366b3..0a875b9 100644 --- a/doc/pol.pl.md +++ b/doc/pol.pl.md @@ -12,7 +12,12 @@ Parameter | Meaning ----------| ------- -g | Specifies a "grep" string that is used to filter the output. You can specify any valid Perl regex for grep-string (see example below). -> Note that the log file must contain naming messages (`log_level_naming` in mama.properties) to get the process's name and PID. +The output of the command is in tab-separated format, and can easily be imported into most spreadsheet programs. + +### Notes + +1. The log file must contain naming messages (`log_level_naming` in mama.properties) to get the process's name and PID. +2. Only the first CONNECT REQ from a particular endpoint is displayed -- subsequent CONNECT REQ messages are discarded. ## Example @@ -30,7 +35,7 @@ Time | Event | Host | Port | Prog | PID | fd 6/13 16:07:13.207611|CONNECT REQ|nsb12|43814|tpsdaemon|12334|0 6/13 16:07:13.209573|CONNECTED|nsb12|39195|tpsdaemon|18893|52 6/13 16:07:13.209682|CONNECTED|nsb11|36375|tpsdaemon|16384|51 -6/13 16:07:13.209904|CONNECTED|nsb12|43814|tpsdaemon|12334|55 -6/13 16:07:13.210329|CONNECT REQ|nsb13|38855|tpsworker|7412|0 -6/13 16:07:13.210723|CONNECT REQ|nsb12|33745|tpsdaemon|7679|0 -6/13 16:07:13.210904|CONNECT REQ|nsb13|44681|tpsworker|7576|0 +6/13 16:07:13.232949|HANDSHAKE_SUCCEEDED|nsb11|43735|tpsworker|16623|81 +6/13 16:07:13.233025|HANDSHAKE_SUCCEEDED|nsb11|42554|tpsworker|16884|97 +6/13 16:07:13.233087|HANDSHAKE_SUCCEEDED|nsb11|37988|tpsworker|20351|93 +6/13 16:07:13.236395|HANDSHAKE_SUCCEEDED|nsb11|36375|tpsdaemon|16384|51 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f4dc214..9affb04 100755 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -42,3 +42,7 @@ install(TARGETS timer DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}) add_executable(timer2 timer2.cpp) target_link_libraries(timer2 ozimpl mama) install(TARGETS timer2 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}) + +add_executable(leak leak.cpp) +target_link_libraries(leak ozimpl mama) +install(TARGETS leak DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/examples/leak.cpp b/examples/leak.cpp new file mode 100644 index 0000000..fc49047 --- /dev/null +++ b/examples/leak.cpp @@ -0,0 +1,43 @@ +// just to verify that asan/lsan are working properly + +#include +#include +using namespace std; + +#include + +#include "ozimpl.h" +using namespace oz; + +class myTimerEvents : public timerEvents +{ + virtual void MAMACALLTYPE onTimer() override + { + static int i = 0; + fprintf(stderr, "timer=%d\n", ++i); + } +}; + + +int main(int argc, char** argv) +{ + cmdLine cli(argc, argv); + + auto conn = createConnection(cli.getMw(), cli.getPayload(), cli.getTportSub()); + TRY_MAMA_FUNC(conn->start()); + + auto sess = conn->createSession(); + TRY_MAMA_FUNC(sess->start()); + + myTimerEvents timerEvents; + auto pTimer = sess->createTimer(0.5, &timerEvents).release(); + TRY_MAMA_FUNC(pTimer->start()); + + sleep(5); + + pTimer->destroy(); + + void* leak = malloc(512); + + return 0; +} diff --git a/src/bridge.c b/src/bridge.c index ebb6307..5dcc05b 100755 --- a/src/bridge.c +++ b/src/bridge.c @@ -149,7 +149,8 @@ zmqBridge_close(mamaBridge bridgeImpl) /* The timer thread expects us to be responsible for terminating it */ wthread_join(timerThread, NULL); } - mamaBridgeImpl_setClosure(bridgeImpl, NULL); + mamaBridgeImpl_setClosure(bridgeImpl, NULL); + free(closure); /* Destroy once queue has been emptied */ mama_getDefaultEventQueue(bridgeImpl, &defaultEventQueue); diff --git a/src/subscription.c b/src/subscription.c index 1f5bf93..2fd6e68 100755 --- a/src/subscription.c +++ b/src/subscription.c @@ -113,10 +113,16 @@ mama_status zmqBridgeMamaSubscription_createWildCard(subscriptionBridge* subscri if (prefix[0] == '^') { ++prefix; // skip beginning anchor } - char* regexPos = strpbrk(prefix, "[^/]+.*"); // find wildcard regex? + char* regexPos = strstr(prefix, "[^/]+"); // find wildcard regex? if (regexPos != NULL) { *regexPos = '\0'; // overwrite with null } + else { + int l = strlen(prefix); + if (strcmp(&prefix[l-3], "/.*") == 0) { // find trailing "super" wildcard? + prefix[l-2] = '\0'; // overwrite with null + } + } MAMA_LOG(MAMA_LOG_LEVEL_FINE, "source=%s,prefix=%s", source, prefix); // create regex to match against diff --git a/src/transport.c b/src/transport.c index ea07c0a..8778ac8 100755 --- a/src/transport.c +++ b/src/transport.c @@ -702,7 +702,7 @@ mama_status zmqBridgeMamaTransportImpl_dispatchNamingMsg(zmqTransportBridge* imp wlock_unlock(impl->mZmqDataPub.mLock); #endif - MAMA_LOG(MAMA_LOG_LEVEL_NORMAL, "Disconnecting data sockets from publisher:%s", pMsg->mEndPointAddr); + MAMA_LOG(MAMA_LOG_LEVEL_NORMAL, "Disconnected data sockets from publisher:%s", pMsg->mEndPointAddr); } else if (pMsg->mType == 'W') { // welcome msg - naming subscriber is connected @@ -1005,7 +1005,7 @@ void MAMACALLTYPE zmqBridgeMamaTransportImpl_wcCallback(mamaQueue queue, void* findClosure.mSubscription = NULL; list_for_each(tmsg->mTransport->mWcEndpoints, (wListCallback) zmqBridgeMamaTransportImpl_findWildcard, &findClosure); if (findClosure.mSubscription == NULL) { - MAMA_LOG(MAMA_LOG_LEVEL_ERROR, "No endpoint found for topic %s with id %s", subject, tmsg->mEndpointIdentifier); + MAMA_LOG(MAMA_LOG_LEVEL_WARN, "No endpoint found for topic %s with id %s", subject, tmsg->mEndpointIdentifier); goto exit; } @@ -1205,7 +1205,7 @@ mama_status zmqBridgeMamaTransportImpl_disconnectSocket(zmqSocket* socket, const int rc = zmq_disconnect(socket->mSocket, uri); if (0 != rc) { - MAMA_LOG(MAMA_LOG_LEVEL_ERROR, "zmq_disconnect(%p, %s) failed: %d(%s)", socket->mSocket, uri, zmq_errno(), zmq_strerror(errno)); + MAMA_LOG(MAMA_LOG_LEVEL_WARN, "zmq_disconnect(%p, %s) failed: %d(%s)", socket->mSocket, uri, zmq_errno(), zmq_strerror(errno)); status = MAMA_STATUS_PLATFORM; }