From bebb2bf3ebb5fdb6ce413e5e1285f97fb18f4789 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 2 Aug 2014 21:40:43 +0200 Subject: mds-registry use timedwait in slaves so we can stop when reexecing of terminating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-registry/slave.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c index 27d054a..5a1063f 100644 --- a/src/mds-registry/slave.c +++ b/src/mds-registry/slave.c @@ -73,6 +73,13 @@ static int slave_notify_client(slave_t* slave) */ static void* slave_loop(void* data) { + /* pthread_cond_timedwait is required to handle re-exec and termination because + pthread_cond_timedwait and pthread_cond_wait ignore interruptions via signals. */ + struct timespec timeout = + { + .tv_sec = 1, + .tv_nsec = 0 + }; slave_t* slave = data; if (slave->closed) @@ -87,7 +94,7 @@ static void* slave_loop(void* data) { if ((slave->wait_set->size == 0) || slave->closed) break; - pthread_cond_wait(&slave_cond, &slave_mutex); + pthread_cond_timedwait(&slave_cond, &slave_mutex, &timeout); } if (!(slave->closed) && (slave->wait_set->size == 0)) -- cgit v1.2.3-70-g09d2