Skip to content

Commit

Permalink
libmultipath: tur: protect pthread_cond_timedwait with a loop
Browse files Browse the repository at this point in the history
Defect reported by coverity (413383 Data race condition)

Signed-off-by: Martin Wilck <[email protected]>
Reviewed-by: Benjamin Marzinski <[email protected]>
  • Loading branch information
mwilck committed Jan 9, 2024
1 parent 4e47bd1 commit 5a9476f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libmultipath/checkers/tur.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,12 @@ int libcheck_check(struct checker * c)
}
tur_timeout(&tsp);
pthread_mutex_lock(&ct->lock);
if (ct->state == PATH_PENDING && ct->msgid == MSG_TUR_RUNNING)
r = pthread_cond_timedwait(&ct->active, &ct->lock,
&tsp);

for (r = 0;
r == 0 && ct->state == PATH_PENDING &&
ct->msgid == MSG_TUR_RUNNING;
r = pthread_cond_timedwait(&ct->active, &ct->lock, &tsp));

if (!r) {
tur_status = ct->state;
c->msgid = ct->msgid;
Expand Down

0 comments on commit 5a9476f

Please sign in to comment.