summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorKinglong Mee <mijinlong@open-fs.com>2018-09-26 05:39:47 -0400
committerAmar Tumballi <amarts@redhat.com>2018-10-09 05:47:43 +0000
commit667026f506d71bc5e5e740477bdc546f08c413ee (patch)
treeb0ada9fa93d7ba75655e476db5052b35cb5eb87f /libglusterfs/src
parent3108fb24e72ab3f60ef0aa9cf3ffd8a3a33ce424 (diff)
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 <mijinlong@open-fs.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/syncop.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index ec646425d74..18ce6cf73af 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);