From 5be33c4e24cdb8ec8be54b2fb6d8484db321382c Mon Sep 17 00:00:00 2001 From: Jeff Weston Date: Wed, 11 Sep 2019 12:09:35 -0400 Subject: [PATCH] v1.5b4 --- VERSION.TXT | 9 +++++++++ include/normVersion.h | 2 +- src/common/normApi.cpp | 35 ++++++++++++++++++++++------------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/VERSION.TXT b/VERSION.TXT index d420bd4..783a16d 100644 --- a/VERSION.TXT +++ b/VERSION.TXT @@ -1,5 +1,14 @@ NORM Version History +Version 1.5b4 +============= + - Corrected change in behavior of non-blocking version of + NormGetNextEvent() call to be consistent with documentation + +Version 1.5b3 +============= + - Added API functions to support integration of NORM into ZeroMQ + Version 1.5b2 ============= - Fixed bug with "graceful" stream closure when the sender application diff --git a/include/normVersion.h b/include/normVersion.h index fa86254..fe83e11 100644 --- a/include/normVersion.h +++ b/include/normVersion.h @@ -36,6 +36,6 @@ #ifndef _NORM_VERSION #define _NORM_VERSION -#define VERSION "1.5b2" +#define VERSION "1.5b4" #endif // _NORM_VERSION diff --git a/src/common/normApi.cpp b/src/common/normApi.cpp index ff53b56..f09e959 100644 --- a/src/common/normApi.cpp +++ b/src/common/normApi.cpp @@ -456,7 +456,7 @@ void NormInstance::PurgeSessionNotifications(NormSessionHandle sessionHandle) { Notification* prev = NULL; Notification* next = notify_queue.GetHead(); - while (next) + while (NULL != next) { if (next->event.session == sessionHandle) { @@ -546,9 +546,19 @@ bool NormInstance::GetNextEvent(NormEvent* theEvent) default: break; } - if (NULL != theEvent) *theEvent = n->event; + break; + } + if (NULL != n) + { previous_notification = n; // keep dispatched event for garbage collection - return true; + if (NULL != theEvent) *theEvent = n->event; + } + else if (NULL != theEvent) + { + theEvent->type = NORM_EVENT_INVALID; + theEvent->session = NORM_SESSION_INVALID; + theEvent->sender = NORM_SESSION_INVALID; + theEvent->object = NORM_SESSION_INVALID; } if (notify_queue.IsEmpty()) { @@ -560,7 +570,7 @@ bool NormInstance::GetNextEvent(NormEvent* theEvent) while (read(notify_fd[0], byte, 32) > 0); // TBD - error check #endif // if/else WIN32/UNIX } - return false; + return (NULL != n); } // end NormInstance::GetNextEvent() bool NormInstance::WaitForEvent() @@ -813,8 +823,8 @@ NormDescriptor NormGetDescriptor(NormInstanceHandle instanceHandle) NORM_API_LINKAGE bool NormGetNextEvent(NormInstanceHandle instanceHandle, NormEvent* theEvent, bool waitForEvent) { - bool result = false; NormInstance* instance = (NormInstance*)instanceHandle; + bool result = false; if (instance) { if (instance->dispatcher.SuspendThread()) @@ -828,6 +838,8 @@ bool NormGetNextEvent(NormInstanceHandle instanceHandle, NormEvent* theEvent, bo if (!instance->WaitForEvent()) { // Indication that NormInstance is dead + // TBD - how do we inform app although this shouldn't + // happen unless the app destroys the "instance" return false; } // re-suspend thread after wait @@ -838,10 +850,7 @@ bool NormGetNextEvent(NormInstanceHandle instanceHandle, NormEvent* theEvent, bo instance->dispatcher.ResumeThread(); } } - // We do this so we only return "false" when NormInstance is dead - if (!result && (NULL != theEvent)) - theEvent->type = NORM_EVENT_INVALID; - return true; + return result; } // end NormGetNextEvent() @@ -882,11 +891,11 @@ void NormDestroySession(NormSessionHandle sessionHandle) if (instance->dispatcher.SuspendThread()) { NormSession* session = (NormSession*)sessionHandle; - if (session) + if (NULL != session) { - session->Close(); - session->GetSessionMgr().DeleteSession(session); - instance->PurgeSessionNotifications(sessionHandle); + session->Close(); + session->GetSessionMgr().DeleteSession(session); + instance->PurgeSessionNotifications(sessionHandle); } instance->dispatcher.ResumeThread(); }