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>
This commit is contained in:
Kinglong Mee 2018-09-26 05:39:47 -04:00 committed by Amar Tumballi
parent 3108fb24e7
commit 667026f506

View File

@ -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);