summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
2d180c1)
If a routing table update happens while traversing entries to print
routing statistics, then it will cause RMR to crash. This
crash is generated due to an unsafe reference used to print
the rt statistics. This change fixes this routing statistic
printout crash.
This change also fixes a related problem of read-access to ref count
in routing table that is not protected by a mutex.
Issue-ID: RIC-872
Signed-off-by: Alexandre Huff <alexandrehuff@utfpr.edu.br>
Change-Id: I03b0cb79a62e7fbdb1eb08c2006894fab4ebf5cd
Signed-off-by: Alexandre Huff <alexandrehuff@utfpr.edu.br>
# API and build change and fix summaries. Doc corrections
# and/or changes are not mentioned here; see the commit messages.
# API and build change and fix summaries. Doc corrections
# and/or changes are not mentioned here; see the commit messages.
+2022 January 17; version 4.8.2
+ Fixes routing statistics printout crash (RIC-872).
+
2022 January 7; version 4.8.1
Re-enables RMR libary's module tests (RIC-861).
Creates a new unit test for the debugging rmr rx queue API.
2022 January 7; version 4.8.1
Re-enables RMR libary's module tests (RIC-861).
Creates a new unit test for the debugging rmr rx queue API.
set( major_version "4" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this
set( minor_version "8" )
set( major_version "4" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this
set( minor_version "8" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_inc "include/rmr" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_inc "include/rmr" )
version 4.0.0, the RMR versions should no longer skip.
version 4.0.0, the RMR versions should no longer skip.
+2022 January 17; version 4.8.2
+------------------------------
+
+Fixes routing statistics printout crash (RIC-872).
+
+
+
2022 January 7; version 4.8.1
------------------------------
2022 January 7; version 4.8.1
------------------------------
*/
static route_table_t* prep_new_rt( uta_ctx_t* ctx, int all ) {
int counter = 0;
*/
static route_table_t* prep_new_rt( uta_ctx_t* ctx, int all ) {
int counter = 0;
route_table_t* rt;
if( ctx == NULL ) {
route_table_t* rt;
if( ctx == NULL ) {
if( (rt = ctx->old_rtable) != NULL ) {
ctx->old_rtable = NULL;
if( (rt = ctx->old_rtable) != NULL ) {
ctx->old_rtable = NULL;
- while( rt->ref_count > 0 ) { // wait for all who are using to stop
+
+ pthread_mutex_lock( ctx->rtgate );
+ ref_count = rt->ref_count;
+ pthread_mutex_unlock( ctx->rtgate );
+
+ while( ref_count > 0 ) { // wait for all who are using to stop
if( counter++ > 1000 ) {
rmr_vlog( RMR_VL_WARN, "rt_prep_newrt: internal mishap, ref count on table seems wedged" );
break;
}
usleep( 1000 ); // small sleep to yield the processer if that is needed
if( counter++ > 1000 ) {
rmr_vlog( RMR_VL_WARN, "rt_prep_newrt: internal mishap, ref count on table seems wedged" );
break;
}
usleep( 1000 ); // small sleep to yield the processer if that is needed
+
+ pthread_mutex_lock( ctx->rtgate );
+ ref_count = rt->ref_count;
+ pthread_mutex_unlock( ctx->rtgate );
}
if( rt->hash != NULL ) {
}
if( rt->hash != NULL ) {
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
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
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
count_delay = 300;
}
if( vlevel >= 0 ) { // allow it to be forced off with -n in verbose file
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
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
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
char* payload; // payload in the message
size_t mlen;
char* port; // a port number we listen/connect to
if( blabber > bump_freq ) {
count_delay = 300;
}
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