X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fnng%2Fsrc%2Frmr_nng.c;h=720f6ade6ce722b89eb50978c06fda174e59dba4;hb=ec88d3c0563eeb6ae5f73427edb0b3c4d7acf299;hp=45a0e2349e96098533dfe20ba322f0267188e1e4;hpb=b96e3d0a31cbe1451eec330f0615477b92258a33;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/nng/src/rmr_nng.c b/src/rmr/nng/src/rmr_nng.c index 45a0e23..720f6ad 100644 --- a/src/rmr/nng/src/rmr_nng.c +++ b/src/rmr/nng/src/rmr_nng.c @@ -454,7 +454,12 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) { if( (eps->ep_fd = epoll_create1( 0 )) < 0 ) { fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno ); free( eps ); - return NULL; + ctx->eps = NULL; + if( old_msg != NULL ) { + old_msg->state = RMR_ERR_INITFAILED; + old_msg->tp_state = errno; + } + return old_msg; } eps->nng_fd = rmr_get_rcvfd( ctx ); @@ -464,7 +469,12 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) { if( epoll_ctl( eps->ep_fd, EPOLL_CTL_ADD, eps->nng_fd, &eps->epe ) != 0 ) { fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) ); free( eps ); - return NULL; + ctx->eps = NULL; + if( old_msg != NULL ) { + old_msg->state = RMR_ERR_INITFAILED; + old_msg->tp_state = errno; + } + return old_msg; } ctx->eps = eps; @@ -1076,3 +1086,40 @@ extern rmr_mbuf_t* rmr_mt_call( void* vctx, rmr_mbuf_t* mbuf, int call_id, int m return mbuf; } + +/* + Given an existing message buffer, reallocate the payload portion to + be at least new_len bytes. The message header will remain such that + the caller may use the rmr_rts_msg() function to return a payload + to the sender. + + The mbuf passed in may or may not be reallocated and the caller must + use the returned pointer and should NOT assume that it can use the + pointer passed in with the exceptions based on the clone flag. + + If the clone flag is set, then a duplicated message, with larger payload + size, is allocated and returned. The old_msg pointer in this situation is + still valid and must be explicitly freed by the application. If the clone + message is not set (0), then any memory management of the old message is + handled by the function. + + If the copy flag is set, the contents of the old message's payload is + copied to the reallocated payload. If the flag is not set, then the + contents of the payload is undetermined. +*/ +extern rmr_mbuf_t* rmr_realloc_payload( rmr_mbuf_t* old_msg, int new_len, int copy, int clone ) { + if( old_msg == NULL ) { + return NULL; + } + + return realloc_payload( old_msg, new_len, copy, clone ); // message allocation is transport specific, so this is a passthrough +} + +/* + The following functions are "dummies" as NNG has no concept of supporting + them, but are needed to resolve calls at link time. +*/ + +extern void rmr_set_fack( void* p ) { + return; +}