moved mutex lock to avoid race condition
This commit is contained in:
parent
8bb4298c3a
commit
db9eed56a1
@ -445,6 +445,7 @@ int verify_work(void *handle, void *work_handle, char *input, char *output) {
|
|||||||
|
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work: going to start worker thread, id=%d",
|
syslog(LOG_DEBUG, "verify (%p) verify_work: going to start worker thread, id=%d",
|
||||||
vwh, vwh->id);
|
vwh, vwh->id);
|
||||||
|
pthread_mutex_lock(vwh->result_mutex);
|
||||||
err = pthread_create(&tid, NULL, &worker_thread, wt);
|
err = pthread_create(&tid, NULL, &worker_thread, wt);
|
||||||
if (-1 == err) {
|
if (-1 == err) {
|
||||||
free(wt->input);
|
free(wt->input);
|
||||||
@ -453,7 +454,6 @@ int verify_work(void *handle, void *work_handle, char *input, char *output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work: waiting for result", vwh);
|
syslog(LOG_DEBUG, "verify (%p) verify_work: waiting for result", vwh);
|
||||||
pthread_mutex_lock(vwh->result_mutex);
|
|
||||||
ts.tv_sec = time(0) + vch->timeout_result;
|
ts.tv_sec = time(0) + vch->timeout_result;
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
|
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user