[lvm-devel] [PATCH] replace select with pselect in clvmd

Dongmao Zhang dmzhang at suse.com
Fri Jul 11 05:10:01 UTC 2014


This patch could enhance the SIGTERM respose of clvmd
the SIGINT and SIGTERM may lost when the signal is generated before select.
The SIGINT and SIGTERM are only unblocked during the pselect call after
this patch

reference:http://lwn.net/Articles/176911/

Signed-off-by: Dongmao Zhang <dmzhang at suse.com>
---
 daemons/clvmd/clvmd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 9b865f6..e758658 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -839,9 +839,8 @@ static void main_loop(int cmd_timeout)
 	DEBUGLOG("Using timeout of %d seconds\n", cmd_timeout);
 
 	sigemptyset(&ss);
-	sigaddset(&ss, SIGINT);
-	sigaddset(&ss, SIGTERM);
-	pthread_sigmask(SIG_UNBLOCK, &ss, NULL);
+	/* SIGTERM and SIGINT should be always block unless in pselect */
+	sigaddset(&ss, SIGUSR2);
 	/* Main loop */
 	while (!quit) {
 		fd_set in;
@@ -863,7 +862,7 @@ static void main_loop(int cmd_timeout)
 				FD_SET(thisfd->fd, &in);
 		}
 
-		select_status = select(FD_SETSIZE, &in, NULL, NULL, &tv);
+		select_status = pselect(FD_SETSIZE, &in, NULL, NULL, &tv, &ss);
 
 		if (reread_config) {
 			int saved_errno = errno;
-- 
1.8.4.5




More information about the lvm-devel mailing list