From e21dbee1d382e73d1897f96c0bd450f216389b74 Mon Sep 17 00:00:00 2001 From: "E. Scott Daniels" Date: Wed, 25 Sep 2019 11:06:07 -0400 Subject: [PATCH] Correct bug in mt call mode receive with timeout 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 Change-Id: Icbbd5705e1d631f3c78dc0c27a392f681dad8737 --- CHANGES | 3 +++ CMakeLists.txt | 2 +- src/rmr/nng/src/rmr_nng.c | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index c81d88a..dce91d3 100644 --- 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. diff --git a/CMakeLists.txt b/CMakeLists.txt index b84fb8b..e98bdc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" ) diff --git a/src/rmr/nng/src/rmr_nng.c b/src/rmr/nng/src/rmr_nng.c index bc3fe10..a4b4009 100644 --- a/src/rmr/nng/src/rmr_nng.c +++ b/src/rmr/nng/src/rmr_nng.c @@ -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; } -- 2.16.6