X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Frmr%2Fcommon%2Fsrc%2Frtc_static.c;h=f29f65fadf021fde459ad4f9db23f22442df8245;hb=817516b6d7d3ffd874192c3a5342ead4c5da498b;hp=3f486952e4a431ae0ccd145a41059f19a1fa62af;hpb=71df2a2b09d072090c29713d05a49b5670b11053;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/common/src/rtc_static.c b/src/rmr/common/src/rtc_static.c index 3f48695..f29f65f 100644 --- a/src/rmr/common/src/rtc_static.c +++ b/src/rmr/common/src/rtc_static.c @@ -117,13 +117,18 @@ static void* rtc_file( void* vctx ) { ctx->flags |= CFL_NO_RTACK; // no attempt to ack when reading from a file while( 1 ) { vlevel = refresh_vlevel( 0 ); - read_static_rt( ctx, vlevel ); // seed the route table if one provided + read_static_rt( ctx, vlevel ); // refresh from the file if( ctx->shutdown != 0 ) { // allow for graceful termination and unit testing refresh_vlevel( 1 ); // close the verbose file if open return NULL; } - sleep( 60 ); + + if( ctx->rtable_ready ) { + sleep( 60 ); + } else { + sleep( 1 ); // check every second until we have a good one + } } } @@ -186,7 +191,7 @@ static void rtc_parse_msg( uta_ctx_t *ctx, uta_ctx_t* pvt_cx, rmr_mbuf_t* msg, i } if( vlevel > 1 ) { - rmr_vlog_force( RMR_VL_DEBUG, "rmr_rtc_parse_msg: processing (%s)\n", curr ); + rmr_vlog_force( RMR_VL_DEBUG, "rmr_rtc_parse_msg: snarf_fd=%d processing (%s)\n", ctx ? ctx->snarf_rt_fd : -99, curr ); } parse_rt_rec( ctx, pvt_cx, curr, vlevel, msg ); // parse record and add to in progress table; ack using rts to msg @@ -263,6 +268,7 @@ static void* rtc( void* vctx ) { uta_ctx_t* ctx; // context user has -- where we pin the route table uta_ctx_t* pvt_cx; // private context for session with rtg rmr_mbuf_t* msg = NULL; // message from rtg + route_table_t* rt; // the routing table that will be traversed to print statistics char* my_port; // the port number that we will listen on (4561 has been the default for this) char* rtg_addr; // host:port address of route table generator (route manager) char* daddr; // duplicated rtg address string to parse/trash @@ -305,6 +311,7 @@ static void* rtc( void* vctx ) { ctx->flags |= CFL_NO_RTACK; // don't ack when reading from a file read_static_rt( ctx, vlevel ); // seed the route table if one provided ctx->flags &= ~CFL_NO_RTACK; + ctx->flags &= ~CFL_FULLRT; // even though rmr-ready goes true, the seed doesn't count as a full RT from route generator my_port = getenv( ENV_CTL_PORT ); // default port to listen on (likely 4561) @@ -354,6 +361,8 @@ static void* rtc( void* vctx ) { ctx->rtg_whid = -1; + cycle_snarfed_rt( ctx ); // cause the nrt to be opened + if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "rtc thread is running and listening; listening for rtg conns on %s\n", my_port ); bump_freq = time( NULL ) + 300; // after 5 minutes we decrease the count frequency @@ -377,7 +386,9 @@ static void* rtc( void* vctx ) { count_delay = 300; } if( vlevel >= 0 ) { // allow it to be forced off with -n in verbose file - rt_epcounts( ctx->rtable, ctx->my_name ); + rt = get_rt( ctx ); // get active route table and up ref count + rt_epcounts( rt, ctx->my_name ); + release_rt( ctx, rt ); // dec safely the ref counter } } @@ -456,6 +467,7 @@ static void* raw_rtc( void* vctx ) { uta_ctx_t* ctx; // context user has -- where we pin the route table uta_ctx_t* pvt_cx; // private context for session with rtg rmr_mbuf_t* msg = NULL; // message from rtg + route_table_t* rt; // the routing table that will be traversed to print statistics char* payload; // payload in the message size_t mlen; char* port; // a port number we listen/connect to @@ -574,7 +586,9 @@ static void* raw_rtc( void* vctx ) { if( blabber > bump_freq ) { count_delay = 300; } - rt_epcounts( ctx->rtable, ctx->my_name ); + rt = get_rt( ctx ); // get active route table and up ref count + rt_epcounts( rt, ctx->my_name ); + release_rt( ctx, rt ); // dec safely the ref counter } }