fix(routes): Allow RTS without specific rt entry 74/74/1
authorE. Scott Daniels <daniels@research.att.com>
Mon, 22 Apr 2019 19:30:49 +0000 (19:30 +0000)
committerE. Scott Daniels <daniels@research.att.com>
Mon, 22 Apr 2019 19:30:49 +0000 (19:30 +0000)
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 <daniels@research.att.com>
src/nanomsg/src/rtable_static.c
src/nng/src/rtable_nng_static.c

index 2233da4..41ebc61 100644 (file)
@@ -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
index 8b3bf67..d1e0cbb 100644 (file)
@@ -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