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=7a8b666841926165d9e2d8edfe8d0388f4546427;hb=2dfb310585e1ea20d222aa1ed129c89e8c240935;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..7a8b666 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++; } @@ -223,6 +223,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 +278,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