X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=sidecars%2Flistener%2Fsrc%2Fpipe_reader.c;h=88ad08f7584480dc099c8cef5c98b267dda5435f;hb=refs%2Fchanges%2F93%2F5793%2F1;hp=ae0a1da16140b85070bbd7bb128db1b1ecfc7ef5;hpb=9e389a0f00f4ce886fa0cafe3318ee0156770899;p=ric-app%2Fmc.git diff --git a/sidecars/listener/src/pipe_reader.c b/sidecars/listener/src/pipe_reader.c index ae0a1da..88ad08f 100644 --- a/sidecars/listener/src/pipe_reader.c +++ b/sidecars/listener/src/pipe_reader.c @@ -49,6 +49,7 @@ static void usage( char* argv0 ) { fprintf( stderr, " -d dir (default is /tmp/mcl/fifos)\n" ); fprintf( stderr, " -e disable extended headers expectation in FIFO data\n" ); fprintf( stderr, " -m msg-type (default is 0)\n" ); + fprintf( stderr, " -M max msg to read (default is all)\n" ); fprintf( stderr, " -s stats only mode\n" ); } @@ -76,6 +77,7 @@ int main( int argc, char** argv ) { char timestamp[MCL_TSTAMP_SIZE]; // we'll get the timestamp from this long count = 0; int blabber = 0; + int max = 0; // we'll force one reader down early to simulate MC going away signal( SIGINT, sigh ); signal( SIGTERM, sigh ); @@ -110,6 +112,16 @@ int main( int argc, char** argv ) { } break; + case 'M': + if( pidx+1 < argc ) { + max = atoi( argv[pidx+1] ); + pidx++; + } else { + bad_arg( argv[pidx] ); + error = 1; + } + break; + case 's': stats_only = 1; break; @@ -139,7 +151,8 @@ int main( int argc, char** argv ) { exit( 1 ); } - while( 1 ) { + fprintf( stderr, "[INFO] max = %d\n", max ); + while( max == 0 || count < max ) { len = mcl_fifo_tsread1( ctx, mtype, buf, sizeof( buf ) -1, long_hdrs, timestamp ); if( len > 0 ) { if( stats_only ) { @@ -156,7 +169,11 @@ int main( int argc, char** argv ) { } count++; + } else { + sleep( 1 ); } } + + fprintf( stderr, "[INFO] max reached: %d\n", max ); }