X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fsi%2Fsrc%2Frmr_si.c;h=c8c3b4aa384dcc35a9733e8383ab8b454cb65b1c;hb=c1f84f8a4a4e2b90ad9ec18aba2b5365d3e51386;hp=8e499c1cd730d9feeb5e40504c55c95bbf6d1ff3;hpb=5200efe1e6dd13b1e1241ce623c4978151be34e8;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/si/src/rmr_si.c b/src/rmr/si/src/rmr_si.c index 8e499c1..c8c3b4a 100644 --- a/src/rmr/si/src/rmr_si.c +++ b/src/rmr/si/src/rmr_si.c @@ -526,7 +526,7 @@ extern int rmr_set_rtimeout( void* vctx, int time ) { static void* init( char* uproto_port, int max_msg_size, int flags ) { static int announced = 0; uta_ctx_t* ctx = NULL; - char bind_info[NNG_MAXADDRLEN]; // bind info + char bind_info[256]; // bind info char* proto = "tcp"; // pointer into the proto/port string user supplied char* port; char* interface = NULL; // interface to bind to (from RMR_BIND_IF, 0.0.0.0 if not defined) @@ -570,9 +570,16 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { ctx->max_ibm = max_msg_size; // default to user supplied message size ctx->mring = uta_mk_ring( 4096 ); // message ring is always on for si + ctx->zcb_mring = uta_mk_ring( 128 ); // zero copy buffer mbuf ring to reduce malloc/free calls + + if( ! (flags & RMRFL_NOLOCK) ) { // user did not specifically ask that it be off; turn it on + uta_ring_config( ctx->mring, RING_RLOCK ); // concurrent rcv calls require read lock + uta_ring_config( ctx->zcb_mring, RING_WLOCK ); // concurrent free calls from userland require write lock + } else { + fprintf( stderr, "[INFO] receive ring locking disabled by user application\n" ); + } init_mtcall( ctx ); // set up call chutes - ctx->zcb_mring = uta_mk_ring( 128 ); // zero copy buffer mbuf ring ctx->max_plen = RMR_MAX_RCV_BYTES; // max user payload lengh if( max_msg_size > 0 ) { @@ -1030,6 +1037,34 @@ 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 +} + /* Enable low latency things in the transport (when supported). */