linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] Signal handling in clvmd
@ 2009-03-23 17:05 Xinwei Hu
  2009-03-24 11:49 ` Chrissie Caulfield
  0 siblings, 1 reply; 2+ messages in thread
From: Xinwei Hu @ 2009-03-23 17:05 UTC (permalink / raw)
  To: LVM general discussion and development

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

Hi all,

  I'm running into a problem that clvmd sometimes take a long time to shutdown.
The clvmd itself is waiting for select to timeout in main_loop. But
since the SIGINT
(or SIGTERM) is handled in other threads, select is not interrupted as expected.

  The attached patch tries to mask SIGINT and SIGTERM in all other threads,
to make sure the signal is properly handled in the main_loop. This
helps to reduce
the chance that we are waiting meaninglessly.

  Would you please kindly review the patch ?

[-- Attachment #2: sigterm_in_main_thread.diff --]
[-- Type: text/x-patch, Size: 889 bytes --]

Index: LVM2.2.02.39/daemons/clvmd/clvmd.c
===================================================================
--- LVM2.2.02.39.orig/daemons/clvmd/clvmd.c	2009-03-22 23:03:53.000000000 +0800
+++ LVM2.2.02.39/daemons/clvmd/clvmd.c	2009-03-23 04:26:36.000000000 +0800
@@ -348,9 +348,11 @@
 	signal(SIGHUP,  sighup_handler);
 	signal(SIGPIPE, SIG_IGN);
 
-	/* Block SIGUSR2 in the main process */
+	/* Block SIGUSR2/SIGINT/SIGTERM in process */
 	sigemptyset(&ss);
 	sigaddset(&ss, SIGUSR2);
+	sigaddset(&ss, SIGINT);
+	sigaddset(&ss, SIGTERM);
 	sigprocmask(SIG_BLOCK, &ss, NULL);
 
 	/* Initialise the LVM thread variables */
@@ -633,6 +635,11 @@
 {
 	DEBUGLOG("Using timeout of %d seconds\n", cmd_timeout);
 
+	sigset_t ss;
+	sigemptyset(&ss);
+	sigaddset(&ss, SIGINT);
+	sigaddset(&ss, SIGTERM);
+	pthread_sigmask(SIG_UNBLOCK, &ss, NULL);
 	/* Main loop */
 	while (!quit) {
 		fd_set in;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-lvm] Signal handling in clvmd
  2009-03-23 17:05 [linux-lvm] Signal handling in clvmd Xinwei Hu
@ 2009-03-24 11:49 ` Chrissie Caulfield
  0 siblings, 0 replies; 2+ messages in thread
From: Chrissie Caulfield @ 2009-03-24 11:49 UTC (permalink / raw)
  To: LVM general discussion and development

Xinwei Hu wrote:
> Hi all,
> 
>   I'm running into a problem that clvmd sometimes take a long time to shutdown.
> The clvmd itself is waiting for select to timeout in main_loop. But
> since the SIGINT
> (or SIGTERM) is handled in other threads, select is not interrupted as expected.
> 
>   The attached patch tries to mask SIGINT and SIGTERM in all other threads,
> to make sure the signal is properly handled in the main_loop. This
> helps to reduce
> the chance that we are waiting meaninglessly.
> 
>   Would you please kindly review the patch ?

Thank you,

That patch looks good and I've committed it into CVS.

Chrissie

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-24 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 17:05 [linux-lvm] Signal handling in clvmd Xinwei Hu
2009-03-24 11:49 ` Chrissie Caulfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).