From 0328da92d21278920033d707aec53e9e12e7be6a Mon Sep 17 00:00:00 2001 From: Eric MacDonald Date: Mon, 28 May 2018 19:35:10 -0400 Subject: [PATCH] Mtce: Stop calling 'event_base_loopbreak' for nonblocking http requests The SM API event handler is calling event_base_loopbreak for all requests. This is sometimes causing segfault when this is done in the http handler for non-blocking requests. This update prevents this call for non-blocking requests. Change-Id: Ib083100ccd74aa984bd86921c7521bfec925e779 Signed-off-by: Eric MacDonald --- .../maintenance/mtcHttpUtil.cpp | 5 +++++ .../maintenance/mtcNodeHdlrs.cpp | 1 - .../cgts-mtce-common-1.0/maintenance/mtcSmgrApi.cpp | 13 ++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mtce-common/cgts-mtce-common-1.0/maintenance/mtcHttpUtil.cpp b/mtce-common/cgts-mtce-common-1.0/maintenance/mtcHttpUtil.cpp index f0faf728..aebea177 100755 --- a/mtce-common/cgts-mtce-common-1.0/maintenance/mtcHttpUtil.cpp +++ b/mtce-common/cgts-mtce-common-1.0/maintenance/mtcHttpUtil.cpp @@ -1000,6 +1000,11 @@ int mtcHttpUtil_receive ( libEvent & event ) break ; } } + if ( rc != RETRY ) + { + mtcHttpUtil_free_conn ( event ); + mtcHttpUtil_free_base ( event ); + } return (rc); } diff --git a/mtce-common/cgts-mtce-common-1.0/maintenance/mtcNodeHdlrs.cpp b/mtce-common/cgts-mtce-common-1.0/maintenance/mtcNodeHdlrs.cpp index 8b5a2f46..33904671 100755 --- a/mtce-common/cgts-mtce-common-1.0/maintenance/mtcNodeHdlrs.cpp +++ b/mtce-common/cgts-mtce-common-1.0/maintenance/mtcNodeHdlrs.cpp @@ -3648,7 +3648,6 @@ int nodeLinkClass::swact_handler ( struct nodeLinkClass::node * node_ptr ) * the task and setting it back to the start. */ if ( node_ptr->mtcSwact_timer.ring == true ) { - mtcHttpUtil_free_conn ( nodeLinkClass::smgrEvent ); mtcInvApi_force_task ( node_ptr, ""); nodeLinkClass::smgrEvent.active = false ; nodeLinkClass::smgrEvent.mutex = false ; diff --git a/mtce-common/cgts-mtce-common-1.0/maintenance/mtcSmgrApi.cpp b/mtce-common/cgts-mtce-common-1.0/maintenance/mtcSmgrApi.cpp index 99c3ba4f..f5431f11 100644 --- a/mtce-common/cgts-mtce-common-1.0/maintenance/mtcSmgrApi.cpp +++ b/mtce-common/cgts-mtce-common-1.0/maintenance/mtcSmgrApi.cpp @@ -58,13 +58,16 @@ void nodeLinkClass::mtcSmgrApi_handler ( struct evhttp_request *req, void *arg ) mtcSmgrApi_handler_out: - mtcHttpUtil_free_conn ( smgrEvent ); - mtcHttpUtil_free_base ( smgrEvent ); + if ( smgrEvent.blocking == true ) + { + mtcHttpUtil_free_conn ( smgrEvent ); + mtcHttpUtil_free_base ( smgrEvent ); + /* This is needed to get out of the loop in the blocking case + * Calling this here in non-blocking calls can lead to segfault */ + event_base_loopbreak((struct event_base *)arg); + } smgrEvent.active = false ; - - /* This is needed to get out of the loop */ - event_base_loopbreak((struct event_base *)arg); } /*