diff --git a/include/player.h b/include/player.h index 584c613f..52edb336 100644 --- a/include/player.h +++ b/include/player.h @@ -78,6 +78,7 @@ struct player { time_t curup; /* when last input was received */ int aborted; /* interrupt cookie received? */ int eof; /* EOF (cookie or real) received? */ + int recvfail; /* #recvclient() failures */ int curid; /* for pr, cur. line's id, -1 none */ char *map; /* pointer to in-mem map */ char *bmap; /* pointer to in-mem bmap */ diff --git a/src/lib/player/recvclient.c b/src/lib/player/recvclient.c index 169a1424..5757aa40 100644 --- a/src/lib/player/recvclient.c +++ b/src/lib/player/recvclient.c @@ -90,10 +90,19 @@ recvclient(char *cmd, int size) player->eof = 1; } - if (player->eof) - return -1; - if (player->aborted) - return -2; + if (player->aborted || player->eof) { + player->recvfail++; + if (player->recvfail > 255) { + /* + * Looks like the thread is stuck in a loop that fails to + * check errors; oops once, then slow it down drastically. + */ + CANT_HAPPEN(player->recvfail == 256); + empth_sleep(time(NULL) + 60); + } + return player->eof ? -1 : -2; + } + player->recvfail = 0; return count; }