From ae8e63b75e4c5e754c1f3c2d4a600100a05225a0 Mon Sep 17 00:00:00 2001 From: "E. Scott Daniels" Date: Mon, 22 Apr 2019 19:30:49 +0000 Subject: [PATCH] fix(routes): Allow RTS without specific rt entry In order to return a message to the original sender (rts) the sender's hostname:port was required to be in the route table for the instance. This might not always be the case as an application may need to send messages to another only in an RTS capacity and not as a message type routed message. Threfore the requirement that an application host:port be listed in the route table for this type of relationship isn't needed. With this change, an application will be able to call rmr_rts_msg() for any received message regardless of whether the sender is listed in the local route table. Change-Id: I9ab04a874524369dc218bacade0e34f7ea13ea95 Signed-off-by: E. Scott Daniels --- src/nanomsg/src/rtable_static.c | 4 +++- src/nng/src/rtable_nng_static.c | 19 +++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/nanomsg/src/rtable_static.c b/src/nanomsg/src/rtable_static.c index 2233da4..41ebc61 100644 --- a/src/nanomsg/src/rtable_static.c +++ b/src/nanomsg/src/rtable_static.c @@ -172,7 +172,9 @@ static int uta_epsock_byname( route_table_t* rt, char* ep_name ) { ep = rmr_sym_get( rt->hash, ep_name, 1 ); if( ep == NULL ) { - return -1; + if( ! ep_name || (ep = rt_ensure_ep( rt, ep_name)) == NULL ) { // create one if not in rt (support rts without entry in our table) + return -1; + } } if( !ep->open ) { // not connected; must connect now diff --git a/src/nng/src/rtable_nng_static.c b/src/nng/src/rtable_nng_static.c index 8b3bf67..d1e0cbb 100644 --- a/src/nng/src/rtable_nng_static.c +++ b/src/nng/src/rtable_nng_static.c @@ -155,20 +155,6 @@ extern endpoint_t* uta_add_ep( route_table_t* rt, rtable_ent_t* rte, char* ep_n } ep = rt_ensure_ep( rt, ep_name ); // get the ep and create one if not known - /* - if( (ep = uta_get_ep( rt, ep_name )) == NULL ) { // not there yet, make - if( (ep = (endpoint_t *) malloc( sizeof( *ep ) )) == NULL ) { - fprintf( stderr, "uta: [WARN] malloc failed for endpoint creation: %s\n", ep_name ); - return NULL; - } - - ep->open = 0; // not connected - ep->addr = uta_h2ip( ep_name ); - ep->name = strdup( ep_name ); - - rmr_sym_put( rt->hash, ep_name, 1, ep ); - } - */ if( rrg != NULL ) { if( rrg->nused >= rrg->nendpts ) { @@ -199,11 +185,12 @@ static int uta_epsock_byname( route_table_t* rt, char* ep_name, nng_socket* nn_s return FALSE; } - ep = rmr_sym_get( rt->hash, ep_name, 1 ); if( ep == NULL ) { if( DEBUG ) fprintf( stderr, "[DBUG] get ep by name for %s not in hash!\n", ep_name ); - return FALSE; + if( ! ep_name || (ep = rt_ensure_ep( rt, ep_name)) == NULL ) { // create one if not in rt (support rts without entry in our table) + return FALSE; + } } if( ! ep->open ) { // not open -- connect now -- 2.16.6