Skip to contentSkip to conversation

replace select with pselect in clvmd

PATCH New Dongmao Zhang 1 participant 1 message Jul 11, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 replace select with pselect in clvmd

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/

---
 daemons/clvmd/clvmd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
daemons/clvmd/clvmd.c +3 -4
index 9b865f6..e758658 100644
@@ -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;
Signature · 1 line
1.8.4.5