[dm-devel] [PATCH 30/42] Fix race condition in stop_waiter_thread()
Hannes Reinecke
hare at suse.de
Tue Jan 8 13:54:08 UTC 2013
The signal handler might run before we had a chance to
set the 'waiter' context to '0', so better do it previously.
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
libmultipath/waiter.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/libmultipath/waiter.c b/libmultipath/waiter.c
index 076539c..da71543 100644
--- a/libmultipath/waiter.c
+++ b/libmultipath/waiter.c
@@ -45,6 +45,8 @@ void free_waiter (void *data)
void stop_waiter_thread (struct multipath *mpp, struct vectors *vecs)
{
+ pthread_t thread;
+
if (mpp->waiter == (pthread_t)0) {
condlog(3, "%s: event checker thread already stopped",
mpp->alias);
@@ -52,8 +54,9 @@ void stop_waiter_thread (struct multipath *mpp, struct vectors *vecs)
}
condlog(2, "%s: stop event checker thread (%lu)", mpp->alias,
mpp->waiter);
- pthread_cancel(mpp->waiter);
+ thread = mpp->waiter;
mpp->waiter = (pthread_t)0;
+ pthread_cancel(thread);
}
/*
--
1.7.4.2
More information about the dm-devel
mailing list