[dm-devel] [PATCH 1/2] libmultipath/checkers/{rbd, tur}: Fix pthread_cond_signal() calls
Bart Van Assche
bart.vanassche at sandisk.com
Thu Sep 29 21:28:27 UTC 2016
Calling pthread_cond_signal() without holding the associated
mutex sporadically results in a lost wakeup. Hence call
pthread_cond_signal() while holding the mutex used by
pthread_cond_wait().
Signed-off-by: Bart Van Assche <bart.vanassche at sandisk.com>
Cc: Mike Christie <mchristi at redhat.com>
---
libmultipath/checkers/rbd.c | 2 +-
libmultipath/checkers/tur.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c
index 874bcfa..41259c3 100644
--- a/libmultipath/checkers/rbd.c
+++ b/libmultipath/checkers/rbd.c
@@ -527,8 +527,8 @@ static void *rbd_thread(void *ctx)
/* checker done */
pthread_mutex_lock(&ct->lock);
ct->state = state;
- pthread_mutex_unlock(&ct->lock);
pthread_cond_signal(&ct->active);
+ pthread_mutex_unlock(&ct->lock);
condlog(3, "rbd%d thead finished, state %s", ct->rbd_bus_id,
checker_state_name(state));
diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
index 8c1f633..94e4190 100644
--- a/libmultipath/checkers/tur.c
+++ b/libmultipath/checkers/tur.c
@@ -225,8 +225,8 @@ static void *tur_thread(void *ctx)
/* TUR checker done */
pthread_mutex_lock(&ct->lock);
ct->state = state;
- pthread_mutex_unlock(&ct->lock);
pthread_cond_signal(&ct->active);
+ pthread_mutex_unlock(&ct->lock);
condlog(3, "%d:%d: tur checker finished, state %s",
TUR_DEVT(ct), checker_state_name(state));
--
2.10.0
More information about the dm-devel
mailing list