return rte;
}
-/*
- Given a route table and meid string, find the owner (if known). Returns a pointer to
- the endpoint struct or nil.
-*/
-static inline endpoint_t* get_meid_owner( route_table_t *rt, char* meid ) {
- endpoint_t* ep; // the ep we found in the hash
-
- if( rt == NULL || rt->hash == NULL || meid == NULL || *meid == 0 ) {
- return NULL;
- }
-
- return (endpoint_t *) rmr_sym_get( rt->hash, meid, RT_ME_SPACE );
-}
-
/*
Return a string of count information. E.g.:
<ep-name>:<port> <good> <hard-fail> <soft-fail>
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;
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