X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fxapp-utils%2Fxapp_rmr.cc;fp=src%2Fxapp-utils%2Fxapp_rmr.cc;h=d03de88dc0a5692d0decb292dbe3f08305ac0eaa;hb=91d30a6530398a9c7e50a15ea1cf9a027953bd39;hp=c822e55d9d4e3138469fc22ed5369047eb864e17;hpb=b85024cd183a527cd8d61353637850cb6d30cf36;p=ric-app%2Fhw.git diff --git a/src/xapp-utils/xapp_rmr.cc b/src/xapp-utils/xapp_rmr.cc index c822e55..d03de88 100755 --- a/src/xapp-utils/xapp_rmr.cc +++ b/src/xapp-utils/xapp_rmr.cc @@ -33,7 +33,6 @@ XappRmr::XappRmr(std::string port, int rmrattempts){ }; XappRmr::~XappRmr(void){ - // free memory if(_xapp_received_buff) rmr_free_msg(_xapp_received_buff); @@ -44,6 +43,7 @@ XappRmr::~XappRmr(void){ if (_xapp_rmr_ctx){ rmr_close(_xapp_rmr_ctx); } + }; //Get RMR Context. @@ -65,25 +65,20 @@ void XappRmr::xapp_rmr_init(){ return; } -//RMR Returning to the sender. -bool XappRmr::xapp_rmr_rts() -{ - mdclog_write(MDCLOG_INFO,"RMR Return to sender, file= %s, line=%d",__FILE__,__LINE__); - if ( _xapp_rmr_ctx == NULL){ - mdclog_write(MDCLOG_ERR,"Error Initializing RMR, file= %s, line=%d",__FILE__,__LINE__); - } - while( ! rmr_ready(_xapp_rmr_ctx) ) { - mdclog_write(MDCLOG_INFO,">>> waiting for RMR, file= %s, line=%d",__FILE__,__LINE__); - sleep(1); - } - rmr_rts_msg(_xapp_rmr_ctx, _xapp_received_buff ); - sleep(1); - return true; -} + //RMR Send with payload and header. bool XappRmr::xapp_rmr_send(xapp_rmr_header *hdr, void *payload){ + // Get the thread id + std::thread::id my_id = std::this_thread::get_id(); + std::stringstream thread_id; + std::stringstream ss; + + thread_id << my_id; + mdclog_write(MDCLOG_INFO, "Sending thread %s", thread_id.str().c_str()); + + int rmr_attempts = _nattempts; if( _xapp_send_buff == NULL ) { @@ -114,7 +109,9 @@ bool XappRmr::xapp_rmr_send(xapp_rmr_header *hdr, void *payload){ else { mdclog_write(MDCLOG_INFO,"Need to retry RMR: state=%d, attempt=%d, file=%s, line=%d",_xapp_send_buff->state, rmr_attempts,__FILE__,__LINE__); - rmr_attempts--; + if(_xapp_send_buff->state == RMR_ERR_RETRY){ + usleep(1); } + rmr_attempts--; } sleep(1); }