summaryrefslogtreecommitdiffstats
path: root/0043-RH-signal-waiter.patch
blob: a1a63ea033ad0f9cbaba9f0c8c058721a5424431 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
 libmultipath/waiter.c |    9 +++++++++
 multipathd/main.c     |    8 ++++++++
 2 files changed, 17 insertions(+)

Index: multipath-tools-130222/libmultipath/waiter.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/waiter.c
+++ multipath-tools-130222/libmultipath/waiter.c
@@ -57,6 +57,7 @@ void stop_waiter_thread (struct multipat
 	thread = mpp->waiter;
 	mpp->waiter = (pthread_t)0;
 	pthread_cancel(thread);
+	pthread_kill(thread, SIGUSR2);
 }
 
 /*
@@ -65,6 +66,7 @@ void stop_waiter_thread (struct multipat
  */
 int waiteventloop (struct event_thread *waiter)
 {
+	sigset_t set, oldset;
 	int event_nr;
 	int r;
 
@@ -97,8 +99,15 @@ int waiteventloop (struct event_thread *
 	dm_task_no_open_count(waiter->dmt);
 
 	/* wait */
+	sigemptyset(&set);
+	sigaddset(&set, SIGUSR2);
+	pthread_sigmask(SIG_UNBLOCK, &set, &oldset);
+
+	pthread_testcancel();
 	r = dm_task_run(waiter->dmt);
+	pthread_testcancel();
 
+	pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 	dm_task_destroy(waiter->dmt);
 	waiter->dmt = NULL;
 
Index: multipath-tools-130222/multipathd/main.c
===================================================================
--- multipath-tools-130222.orig/multipathd/main.c
+++ multipath-tools-130222/multipathd/main.c
@@ -1506,6 +1506,12 @@ sigusr1 (int sig)
 }
 
 static void
+sigusr2 (int sig)
+{
+	condlog(3, "SIGUSR2 received");
+}
+
+static void
 signal_init(void)
 {
 	sigset_t set;
@@ -1513,10 +1519,12 @@ signal_init(void)
 	sigemptyset(&set);
 	sigaddset(&set, SIGHUP);
 	sigaddset(&set, SIGUSR1);
+	sigaddset(&set, SIGUSR2);
 	pthread_sigmask(SIG_BLOCK, &set, NULL);
 
 	signal_set(SIGHUP, sighup);
 	signal_set(SIGUSR1, sigusr1);
+	signal_set(SIGUSR2, sigusr2);
 	signal_set(SIGINT, sigend);
 	signal_set(SIGTERM, sigend);
 	signal(SIGPIPE, SIG_IGN);