diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2015-03-07 06:10:41 +0100 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-09 10:42:02 -0700 |
commit | 3361bab0388f7cdad50e1c67e1127801fda05685 (patch) | |
tree | c93f3055631b0df38fb457300992f512685c3d7d /libglusterfs/src | |
parent | 854383198b6f02d85b4209a8e7dd7e7c0c118793 (diff) |
glfsheal: Avoid infinite loop on exit
Make sure we do not get stuck looping forever in event_dispatch_destroy()
by limiting the retries when waiting for other threads, and by giving up
when writing to other thread fails.
This fixes regression tests hanging forever on NetBSD.
BUG: 1129939
Change-Id: I4459cfb1ab7294e8c15a21b592e0154c22abae07
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9825
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-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, |