From 6d1adde7f4d51ec8d29d98920f2d22401a7a0e12 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Wed, 20 Jul 2016 14:17:41 +0200 Subject: Dummy stop condition to have gmon output for now (^C dont output gmon.out) --- mcastseed/src/mcastleech.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mcastseed/src/mcastleech.c b/mcastseed/src/mcastleech.c index 263bac4..bbdcf20 100644 --- a/mcastseed/src/mcastleech.c +++ b/mcastseed/src/mcastleech.c @@ -203,6 +203,7 @@ int wait_start_and_start_job() { int receive_data() { int info_r, info_w, res; ssize_t nread, nwrite; + static int noop_calls_count = 0; /* Read (blocking, timeout = 1 sec) */ nread = dgrambuf_recvmmsg(dgrambuf, mcast_sock, 1, &info_r); @@ -218,6 +219,16 @@ int receive_data() { fprintf(stderr, "receive_data(): nread == %zi, nwrite == %zi\n", nread, nwrite); + /* XXX Crapy dead state detection */ + if ( nread == 0 && nwrite == 0 ) { + if ( noop_calls_count > 10 ) { + return 0; + } + noop_calls_count++; + } else { + noop_calls_count = 0; + } + /* Consider sending status back to seeder */ res = send_status(1, info_r, info_w); if ( res < 0 ) { @@ -227,7 +238,6 @@ int receive_data() { if ( dgrambuf_everything_was_received(dgrambuf) ) { return 0; } - return 1; } -- cgit v1.2.3