summaryrefslogtreecommitdiff
path: root/mcastseed/src/mcastleech.c
diff options
context:
space:
mode:
Diffstat (limited to 'mcastseed/src/mcastleech.c')
-rw-r--r--mcastseed/src/mcastleech.c12
1 files changed, 11 insertions, 1 deletions
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;
}