From 667026f506d71bc5e5e740477bdc546f08c413ee Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Wed, 26 Sep 2018 05:39:47 -0400 Subject: syncop: check syncenv status before pthread_cond_timedwait() to avoid 600s timeout If a syncenv_task starts after syncenv_destroy, the syncenv_task enters a 600s timeout cond timedwait, and syncenv_destroy must waits it timeout. Change-Id: I972a2b231e50cbebd3c71707800e58033e40c29d updates: bz#1626313 Signed-off-by: Kinglong Mee --- libglusterfs/src/syncop.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index ec646425d7..18ce6cf73a 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -587,10 +587,6 @@ syncenv_task(struct syncproc *proc) pthread_mutex_lock(&env->mutex); { while (list_empty(&env->runq)) { - sleep_till.tv_sec = time(NULL) + SYNCPROC_IDLE_TIME; - ret = pthread_cond_timedwait(&env->cond, &env->mutex, &sleep_till); - if (!list_empty(&env->runq)) - break; /* If either of the conditions are met then exit * the current thread: * 1. syncenv has to scale down(procs > procmin) @@ -612,6 +608,9 @@ syncenv_task(struct syncproc *proc) pthread_cond_broadcast(&env->cond); goto unlock; } + + sleep_till.tv_sec = time(NULL) + SYNCPROC_IDLE_TIME; + ret = pthread_cond_timedwait(&env->cond, &env->mutex, &sleep_till); } task = list_entry(env->runq.next, struct synctask, all_tasks); -- cgit