X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fsi%2Fsrc%2Fmt_call_si_static.c;h=862b55441c4ba6a410125cd82a5e3a5437448345;hb=6d112571b27574ae857da7cb8dc8758ffee4ff60;hp=37364205f17c905165a4d3e0d9ad115243c2f19f;hpb=0d4def6c7b673f3be486338ced65ccdd25a859ed;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/si/src/mt_call_si_static.c b/src/rmr/si/src/mt_call_si_static.c index 3736420..862b554 100644 --- a/src/rmr/si/src/mt_call_si_static.c +++ b/src/rmr/si/src/mt_call_si_static.c @@ -38,7 +38,7 @@ static inline void queue_normal( uta_ctx_t* ctx, rmr_mbuf_t* mbuf ) { if( ! uta_ring_insert( ctx->mring, mbuf ) ) { rmr_free_msg( mbuf ); // drop if ring is full if( !warned ) { - rmr_vlog( RMR_VL_WARN, "rmr_mt_receive: application is not receiving fast enough; messages dropping\n" ); + rmr_vlog( RMR_VL_ERR, "rmr_mt_receive: application is not receiving fast enough; messages dropping\n" ); warned++; } @@ -134,7 +134,7 @@ static int mt_data_cb( void* vctx, int fd, char* buf, int buflen ) { if( river->state == RS_NEW ) { memset( river, 0, sizeof( *river ) ); //river->nbytes = sizeof( char ) * (8 * 1024); - river->nbytes = sizeof( char ) * ctx->max_ibm; // max inbound message size + river->nbytes = sizeof( char ) * (ctx->max_ibm + 1024); // max inbound message size river->accum = (char *) malloc( river->nbytes ); river->ipt = 0; } else { @@ -144,15 +144,6 @@ static int mt_data_cb( void* vctx, int fd, char* buf, int buflen ) { } river->state = RS_GOOD; - -/* -fprintf( stderr, "\n>>>>> data callback for %d bytes from %d\n", buflen, fd ); -for( i = 0; i < 40; i++ ) { - fprintf( stderr, "%02x ", (unsigned char) *(buf+i) ); -} -fprintf( stderr, "\n" ); -*/ - remain = buflen; while( remain > 0 ) { // until we've done something with all bytes passed in if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "====== data callback top of loop bidx=%d msize=%d ipt=%d remain=%d\n", bidx, river->msg_size, river->ipt, remain ); @@ -203,7 +194,7 @@ fprintf( stderr, "\n" ); if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "data callback enough in the buffer size=%d need=%d remain=%d\n", river->msg_size, need, remain ); if( (river->flags & RF_DROP) == 0 ) { memcpy( &river->accum[river->ipt], buf+bidx, need ); // grab just what is needed (might be more) - buf2mbuf( ctx, river->accum, river->msg_size, fd ); // build an RMR mbuf and queue + buf2mbuf( ctx, river->accum, river->nbytes, fd ); // build an RMR mbuf and queue river->accum = (char *) malloc( sizeof( char ) * river->nbytes ); // fresh accumulator } else { if( !(river->flags & RF_NOTIFIED) ) { @@ -223,6 +214,31 @@ fprintf( stderr, "\n" ); return SI_RET_OK; } +/* + Callback driven on a disconnect notification. We will attempt to find the related + endpoint via the fd2ep hash maintained in the context. If we find it, then we + remove it from the hash, and mark the endpoint as closed so that the next attempt + to send forces a reconnect attempt. + + Future: put the ep on a queue to automatically attempt to reconnect. +*/ +static int mt_disc_cb( void* vctx, int fd ) { + uta_ctx_t* ctx; + endpoint_t* ep; + + if( (ctx = (uta_ctx_t *) vctx) == NULL ) { + return SI_RET_OK; + } + + ep = fd2ep_del( ctx, fd ); // find ep and remote the fd from the hash + if( ep ) { + ep->open = FALSE; + ep->nn_sock = -1; + } + + return SI_RET_OK; +} + /* This is expected to execute in a separate thread. It is responsible for @@ -253,7 +269,10 @@ static void* mt_receive( void* vctx ) { } if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "mt_receive: registering SI95 data callback and waiting\n" ); + SIcbreg( ctx->si_ctx, SI_CB_CDATA, mt_data_cb, vctx ); // our callback called only for "cooked" (tcp) data + SIcbreg( ctx->si_ctx, SI_CB_DISC, mt_disc_cb, vctx ); // our callback for handling disconnects + SIwait( ctx->si_ctx ); return NULL; // keep the compiler happy though never can be reached as SI wait doesn't return