Code Review
/
ric-plt
/
lib
/
rmr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Address code analysis issues
[ric-plt/lib/rmr.git]
/
src
/
rmr
/
common
/
src
/
wormholes.c
diff --git
a/src/rmr/common/src/wormholes.c
b/src/rmr/common/src/wormholes.c
index
2518b7a
..
76567f9
100644
(file)
--- a/
src/rmr/common/src/wormholes.c
+++ b/
src/rmr/common/src/wormholes.c
@@
-105,7
+105,7
@@
static int wh_init( uta_ctx_t* ctx ) {
}
if( (whm = malloc( sizeof( *whm ) )) == NULL ) {
}
if( (whm = malloc( sizeof( *whm ) )) == NULL ) {
-
fprintf( stderr
, "mem alloc failed for whm: alloc %d bytes\n", (int) sizeof( *whm ) );
+
rmr_vlog( RMR_VL_ERR
, "mem alloc failed for whm: alloc %d bytes\n", (int) sizeof( *whm ) );
errno = ENOMEM;
return 0;
}
errno = ENOMEM;
return 0;
}
@@
-113,7
+113,7
@@
static int wh_init( uta_ctx_t* ctx ) {
whm->nalloc = 16;
alloc_sz = whm->nalloc * sizeof( endpoint_t );
if( (whm->eps = (endpoint_t **) malloc( alloc_sz )) == NULL ) {
whm->nalloc = 16;
alloc_sz = whm->nalloc * sizeof( endpoint_t );
if( (whm->eps = (endpoint_t **) malloc( alloc_sz )) == NULL ) {
-
fprintf( stderr
, "mem alloc failed: alloc %d bytes\n", (int) alloc_sz );
+
rmr_vlog( RMR_VL_ERR
, "mem alloc failed: alloc %d bytes\n", (int) alloc_sz );
free( whm );
errno = ENOMEM;
return 0;
free( whm );
errno = ENOMEM;
return 0;
@@
-209,7
+209,7
@@
extern rmr_whid_t rmr_wh_open( void* vctx, char const* target ) {
if( (ep = rt_ensure_ep( ctx->rtable, target )) == NULL ) { // get pointer to ep if there, create new if not
if( (ep = rt_ensure_ep( ctx->rtable, target )) == NULL ) { // get pointer to ep if there, create new if not
-
fprintf( stderr, "ensure ep returned bad; setting no memory error\n"
);
+
rmr_vlog( RMR_VL_ERR, "wormhole_open: ensure ep returned bad: target=(%s)\n", target
);
return -1; // ensure sets errno
}
return -1; // ensure sets errno
}
@@
-220,7
+220,12
@@
extern rmr_whid_t rmr_wh_open( void* vctx, char const* target ) {
}
if( whm->eps[i] == ep ) {
}
if( whm->eps[i] == ep ) {
- return i; // we're already pointing to it, just send it back again
+ if( whm->eps[i]->open ) { // we know about it and it's open
+ return i; // just send back the reference
+ }
+
+ whid = i; // have it, but not open, reopen
+ break;
}
}
}
}
@@
-230,7
+235,7
@@
extern rmr_whid_t rmr_wh_open( void* vctx, char const* target ) {
}
}
}
}
- if( !rt_link2_ep(
ep ) ) { // start a connection if open already
+ if( !rt_link2_ep(
ctx, ep ) ) { // start a connection if not already open
errno = ECONNREFUSED;
return -1;
}
errno = ECONNREFUSED;
return -1;
}
@@
-249,6
+254,7
@@
extern rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg
uta_ctx_t* ctx;
endpoint_t* ep; // enpoint that wormhole ID references
wh_mgt_t *whm;
uta_ctx_t* ctx;
endpoint_t* ep; // enpoint that wormhole ID references
wh_mgt_t *whm;
+ char* d1; // point at the call-id in the header
if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) { // bad stuff, bail fast
errno = EINVAL; // if msg is null, this is their clue
if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) { // bad stuff, bail fast
errno = EINVAL; // if msg is null, this is their clue
@@
-273,15
+279,21
@@
extern rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg
return msg;
}
return msg;
}
- errno = 0;
// nng seems not to set errno any longer, so ensure it's clear
+ errno = 0;
if( msg->header == NULL ) {
if( msg->header == NULL ) {
-
fprintf( stderr, "[ERR]
rmr_wh_send_msg: message had no header\n" );
+
rmr_vlog( RMR_VL_ERR, "
rmr_wh_send_msg: message had no header\n" );
msg->state = RMR_ERR_NOHDR;
errno = EBADMSG; // must ensure it's not eagain
return msg;
}
msg->state = RMR_ERR_NOHDR;
errno = EBADMSG; // must ensure it's not eagain
return msg;
}
+ d1 = DATA1_ADDR( msg->header );
+ d1[D1_CALLID_IDX] = NO_CALL_ID; // must blot out so it doesn't queue on a chute at the other end
+
ep = whm->eps[whid];
ep = whm->eps[whid];
+ if( ! ep->open ) {
+ rmr_wh_open( ctx, ep->name );
+ }
return send2ep( ctx, ep, msg ); // send directly to the endpoint
}
return send2ep( ctx, ep, msg ); // send directly to the endpoint
}