Correct bug in mt call mode receive with timeout 09/1009/1 1.8.2
authorE. Scott Daniels <daniels@research.att.com>
Wed, 25 Sep 2019 15:06:07 +0000 (11:06 -0400)
committerE. Scott Daniels <daniels@research.att.com>
Wed, 25 Sep 2019 15:06:07 +0000 (11:06 -0400)
The rmr_torcv_msg() function was improperly interpreting
the timeout setting with a value of 0 was given. The
expected behaviour is to return immediately if no messages
are waiting, but blocking was happening when used in
conjunction with the MT-CALL mode.

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: Icbbd5705e1d631f3c78dc0c27a392f681dad8737

CHANGES
CMakeLists.txt
src/rmr/nng/src/rmr_nng.c

diff --git a/CHANGES b/CHANGES
index c81d88a..dce91d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 API and build change  and fixe summaries. Doc correctsions
 and/or changes are not mentioned here; see the commit messages.
 
+2019 September 25; version 1.8.2
+       Correct bug in rmr_torcv_msg() when timeout set to zero (0).
+
 2019 September 19; version 1.8.1
        Correct missing constant for wrappers.
        
index b84fb8b..e98bdc7 100644 (file)
@@ -36,7 +36,7 @@ cmake_minimum_required( VERSION 3.5 )
 
 set( major_version "1" )               # should be automatically populated from git tag later, but until CI process sets a tag we use this
 set( minor_version "8" )
-set( patch_level "1" )
+set( patch_level "2" )
 
 set( install_root "${CMAKE_INSTALL_PREFIX}" )
 set( install_inc "include/rmr" )
index bc3fe10..a4b4009 100644 (file)
@@ -883,11 +883,11 @@ extern rmr_mbuf_t* rmr_mt_rcv( void* vctx, rmr_mbuf_t* mbuf, int max_wait ) {
 
        chute = &ctx->chutes[0];                                        // chute 0 used only for its semaphore
 
-       if( max_wait > 0 ) {
+       if( max_wait >= 0 ) {
                clock_gettime( CLOCK_REALTIME, &ts );   
 
                if( max_wait > 999 ) {
-                       seconds = (max_wait - 999)/1000;
+                       seconds = max_wait / 1000;
                        max_wait -= seconds * 1000;
                        ts.tv_sec += seconds;
                }
@@ -1000,11 +1000,11 @@ extern rmr_mbuf_t* rmr_mt_call( void* vctx, rmr_mbuf_t* mbuf, int call_id, int m
        d1[D1_CALLID_IDX] = (unsigned char) call_id;                                    // set the caller ID for the response
        mbuf->flags |= MFL_NOALLOC;                                                                             // send message without allocating a new one (expect nil from mtosend
 
-       if( max_wait > 0 ) {
+       if( max_wait >= 0 ) {
                clock_gettime( CLOCK_REALTIME, &ts );   
 
                if( max_wait > 999 ) {
-                       seconds = (max_wait - 999)/1000;
+                       seconds = max_wait / 1000;
                        max_wait -= seconds * 1000;
                        ts.tv_sec += seconds;
                }