diff options
| -rw-r--r-- | libglusterfs/src/event.c | 10 | 
1 files changed, 7 insertions, 3 deletions
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c index f19d43a0ab1..b956d25595f 100644 --- a/libglusterfs/src/event.c +++ b/libglusterfs/src/event.c @@ -235,10 +235,14 @@ event_dispatch_destroy (struct event_pool *event_pool)          pthread_mutex_lock (&event_pool->mutex);          {                  /* Write to pipe(fd[1]) and then wait for 1 second or until -                 * a poller thread that is dying, broadcasts. +                 * a poller thread that is dying, broadcasts. Make sure we +                 * do not loop forever by limiting to 10 retries                   */ -                while (event_pool->activethreadcount > 0) { -                        write (fd[1], "dummy", 6); +                int retry = 0; + +                while (event_pool->activethreadcount > 0 && retry++ < 10) { +                        if (write (fd[1], "dummy", 6) == -1) +                                break;                          sleep_till.tv_sec = time (NULL) + 1;                          ret = pthread_cond_timedwait (&event_pool->cond,                                                        &event_pool->mutex,  | 
