X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fnng%2Fsrc%2Frtable_nng_static.c;fp=src%2Frmr%2Fnng%2Fsrc%2Frtable_nng_static.c;h=34a1ed15ca934a7d89ce65740156970ee1296e62;hb=bf897297010df539909b7638d96557d41fd217b0;hp=2cec490a0d469aac99b1b458ceaad68efbed1ea3;hpb=99584a241c64d29fc20e74a4b4e01427d0f00e73;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/nng/src/rtable_nng_static.c b/src/rmr/nng/src/rtable_nng_static.c index 2cec490..34a1ed1 100644 --- a/src/rmr/nng/src/rtable_nng_static.c +++ b/src/rmr/nng/src/rtable_nng_static.c @@ -429,13 +429,16 @@ static inline char* get_ep_counts( endpoint_t* ep, char* ubuf, int ubuf_len ) { We've been told that the meid is a string, thus we count on it being a nil terminated set of bytes. + + If we return false there is no guarentee that the caller's reference to the + ep is valid or nil. Caller can trus the ep reference only when the return is + true. */ static int epsock_meid( route_table_t *rtable, rmr_mbuf_t* msg, nng_socket* nn_sock, endpoint_t** uepp ) { endpoint_t* ep; // seected end point int state = FALSE; // processing state char* meid; - errno = 0; if( ! nn_sock || msg == NULL || rtable == NULL ) { // missing stuff; bail fast errno = EINVAL; @@ -445,14 +448,14 @@ static int epsock_meid( route_table_t *rtable, rmr_mbuf_t* msg, nng_socket* nn_s meid = ((uta_mhdr_t *) msg->header)->meid; if( (ep = get_meid_owner( rtable, meid )) == NULL ) { - if( uepp != NULL ) { // caller needs refernce to endpoint too - *uepp = NULL; - } - if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "epsock_meid: no ep in hash for (%s)\n", meid ); return FALSE; } + if( uepp != NULL ) { // ensure ep is returned to the caller + *uepp = ep; + } + state = TRUE; if( ! ep->open ) { // not connected if( ep->addr == NULL ) { // name didn't resolve before, try again