X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fsi%2Fsrc%2Fsr_si_static.c;h=40ae61b1c474271530556884093be85d82272d57;hb=338fe5e46223df8145b53cdf52dab358f18c7f26;hp=8f2c6f13f30e589c45f43321a6deb2cc8a6a9e44;hpb=fc5c77b3d78988aa407118235d7f5978642df753;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/si/src/sr_si_static.c b/src/rmr/si/src/sr_si_static.c index 8f2c6f1..40ae61b 100644 --- a/src/rmr/si/src/sr_si_static.c +++ b/src/rmr/si/src/sr_si_static.c @@ -31,16 +31,35 @@ #ifndef _sr_si_static_c #define _sr_si_static_c -static void dump_40( char *p, char* label ) { +static void dump_n( char *p, char* label, int n ) { int i; + int j; + int t = 0; + int rows; + - if( label ) - fprintf( stderr, ">>>>> %s p=%p\n", label, p ); + if( label ) { + fprintf( stderr, ">>>>> %s p=%p %d bytes\n", label, p, n ); + } + + rows = (n/16) + ((n % 16) ? 1 : 0); + + for( j = 0; j < rows; j++ ) { + fprintf( stderr, "%04x: ", j * 16 ); - for( i = 0; i < 40; i++ ) { - fprintf( stderr, "%02x ", (unsigned char) *(p+i) ); + for( i = 0; t < n && i < 16; i++, t++ ) { + fprintf( stderr, "%02x ", (unsigned char) *p ); + p++; + } + fprintf( stderr, "\n" ); } - fprintf( stderr, "\n" ); +} + +/* + backwards compatability. +*/ +static void dump_40( char *p, char* label ) { + dump_n( p, label, 40 ); } /* @@ -128,6 +147,7 @@ static rmr_mbuf_t* alloc_zcmsg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int size, int s msg->alloc_len = 0; // force tp_buffer realloc below if( msg->tp_buf ) { free( msg->tp_buf ); + msg->tp_buf = NULL; } } else { mlen = msg->alloc_len; // msg given, allocate the same size as before @@ -141,10 +161,11 @@ static rmr_mbuf_t* alloc_zcmsg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int size, int s abort( ); // toss out a core file for this } -/* +#ifdef DEBUG memset( msg->tp_buf, 0, mlen ); // NOT for production (debug only) valgrind will complain about uninitalised use if we don't set memcpy( msg->tp_buf, "@@!!@@!!@@!!@@!!@@!!@@!!@@!!@@!!**", TP_HDR_LEN ); // NOT for production -- debugging eyecatcher -*/ +#endif + alen = (int *) msg->tp_buf; *alen = mlen; // FIX ME: need a stuct to go in these first bytes, not just dummy len @@ -166,7 +187,7 @@ static rmr_mbuf_t* alloc_zcmsg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int size, int s msg->payload = PAYLOAD_ADDR( hdr ); // point to payload (past all header junk) msg->xaction = ((uta_mhdr_t *)msg->header)->xid; // point at transaction id in header area msg->state = state; // fill in caller's state (likely the state of the last operation) - msg->flags |= MFL_ZEROCOPY; // this is a zerocopy sendable message + msg->flags = MFL_ZEROCOPY; // this is a zerocopy sendable message msg->ring = ctx->zcb_mring; // original msg_free() api doesn't get context so must dup on eaach :( strncpy( (char *) ((uta_mhdr_t *)msg->header)->src, ctx->my_name, RMR_MAX_SRC ); strncpy( (char *) ((uta_mhdr_t *)msg->header)->srcip, ctx->my_ip, RMR_MAX_SRC ); @@ -328,7 +349,7 @@ static inline rmr_mbuf_t* clone_msg( rmr_mbuf_t* old_msg ) { nm->len = old_msg->len; // length of data in the payload nm->alloc_len = mlen; // length of allocated payload - nm->xaction = hdr->xid; // reference xaction + nm->xaction = &hdr->xid[0]; // reference xaction nm->state = old_msg->state; // fill in caller's state (likely the state of the last operation) nm->flags = old_msg->flags | MFL_ZEROCOPY; // this is a zerocopy sendable message memcpy( nm->payload, old_msg->payload, old_msg->len ); @@ -406,7 +427,7 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len ) { nm->len = old_msg->len; // length of data in the payload nm->alloc_len = mlen; // length of allocated payload - nm->xaction = hdr->xid; // reference xaction + nm->xaction = &hdr->xid[0]; // reference xaction nm->state = old_msg->state; // fill in caller's state (likely the state of the last operation) nm->flags = old_msg->flags | MFL_ZEROCOPY; // this is a zerocopy sendable message memcpy( nm->payload, old_msg->payload, old_msg->len ); @@ -502,6 +523,7 @@ static inline rmr_mbuf_t* realloc_payload( rmr_mbuf_t* old_msg, int payload_len, if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "reallocate for payload increase. new message size: %d\n", (int) mlen ); if( (nm->tp_buf = (char *) malloc( sizeof( char ) * mlen )) == NULL ) { rmr_vlog( RMR_VL_CRIT, "rmr_realloc_payload: cannot get memory for zero copy buffer. bytes requested: %d\n", (int) mlen ); + free( nm ); return NULL; }