aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-02 21:40:43 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-02 21:40:43 +0200
commitbebb2bf3ebb5fdb6ce413e5e1285f97fb18f4789 (patch)
tree02e8ddfcdf719d312502dc06ba1fafd9750dc9e8
parentmds-registry: marshal and unmarshal the slave list (diff)
downloadmds-bebb2bf3ebb5fdb6ce413e5e1285f97fb18f4789.tar.gz
mds-bebb2bf3ebb5fdb6ce413e5e1285f97fb18f4789.tar.bz2
mds-bebb2bf3ebb5fdb6ce413e5e1285f97fb18f4789.tar.xz
mds-registry use timedwait in slaves so we can stop when reexecing of terminating
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-registry/slave.c9
1 files changed, 8 insertions, 1 deletions
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))