From: Michal Sojka Date: Sat, 19 Feb 2011 22:57:48 +0000 (+0100) Subject: forb: Fix deadlock in executor X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/forb.git/commitdiff_plain/6cab615cbf872ea1207847511eb1eb957cb4b212?hp=bc421a4a4698bffca4b275705a2a17401b788a63 forb: Fix deadlock in executor The first iteration of executor loop waited for the request without actually checking that there is no request in the queue. Therefore, when the client sent the request before the executor called fosa_cond_wait() for the first time, the executor blocked indefinitely. --- diff --git a/src/executor.c b/src/executor.c index 55c240f..08e0068 100644 --- a/src/executor.c +++ b/src/executor.c @@ -150,8 +150,6 @@ int forb_executor_run(forb_executor_t *executor) fosa_mutex_lock(&executor->mutex); while (1) { - fosa_cond_wait(&executor->new_request_in_empty_list, - &executor->mutex); while (!forb_exec_req_nolock_is_empty(executor)) { forb_exec_req_t *exec_req; exec_req = forb_exec_req_nolock_cut_first(executor); @@ -161,6 +159,8 @@ int forb_executor_run(forb_executor_t *executor) fosa_mutex_lock(&executor->mutex); } + fosa_cond_wait(&executor->new_request_in_empty_list, + &executor->mutex); } fosa_mutex_unlock(&executor->mutex); ret: