[PATCH 1/2] libmultipath/checkers/{rbd, tur}: Fix pthread_cond_signal() calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
Cc: Mike Christie <mchristi@xxxxxxxxxx>
---
 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

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux