author | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-07-23 15:24:57 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-07-23 17:53:37 UTC |
parent | 3e9735d6f5800697c563741dfbf83114a3f3d3fd |
libfiu/fiu-rc.c | +10 | -1 |
diff --git a/libfiu/fiu-rc.c b/libfiu/fiu-rc.c index 805021b..a0491de 100644 --- a/libfiu/fiu-rc.c +++ b/libfiu/fiu-rc.c @@ -180,14 +180,22 @@ static char npipe_path_out[PATH_MAX]; static void *rc_fifo_thread(void *unused) { - int fdr, fdw, r; + int fdr, fdw, r, errcount; /* increment the recursion count so we're not affected by libfiu, * otherwise we could make the remote control useless by enabling all * failure points */ rec_count++; + errcount = 0; + reopen: + if (errcount > 10) { + fprintf(stderr, "libfiu: Too many errors in remote control " + "thread, shutting down\n"); + return NULL; + } + fdr = open(npipe_path_in, O_RDONLY); if (fdr < 0) return NULL; @@ -202,6 +210,7 @@ reopen: r = rc_do_command(fdr, fdw); if (r < 0 && errno != EPIPE) { perror("libfiu: Error reading from remote control"); + errcount++; close(fdr); close(fdw); goto reopen;