All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Coddington <ben.coddington@hammerspace.com>
To: Steve Dickson <steved@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 3/4] exportd: stop exiting from a signal handler
Date: Thu, 24 Sep 2026 11:29:03 -0400	[thread overview]
Message-ID: <4513fefc0741f08cfa76777ae10edc6b579ad4db.1790263469.git.bcodding@hammerspace.com> (raw)
In-Reply-To: <cover.1790263469.git.bcodding@hammerspace.com>

Same change as for mountd: use cache_block_signals() and call killer()
from the process loop once cache_stop_signal() is set.

Assisted-by: LLM
Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com>
---
 utils/exportd/exportd.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c
index a08aaaccbc2f..d63195c4ea28 100644
--- a/utils/exportd/exportd.c
+++ b/utils/exportd/exportd.c
@@ -61,14 +61,13 @@ cleanup_lockfiles (void)
 	unlink(etab.lockfn);
 }
 
+/*
+ * Called from main() once cache_process() has seen SIGINT or SIGTERM,
+ * never from a signal handler: see cache_block_signals().
+ */
 static void
 killer (int sig)
 {
-	if (num_threads > 1) {
-		/* play Kronos and eat our children */
-		kill(0, SIGTERM);
-		cache_wait_for_workers("exportd");
-	}
 	cleanup_lockfiles();
 	free_state_path_names(&etab);
 	xlog (L_NOTICE, "Caught signal %d, exiting.", sig);
@@ -76,14 +75,6 @@ killer (int sig)
 	exit(0);
 }
 
-static void
-sig_hup (int UNUSED(sig))
-{
-	/* don't exit on SIGHUP */
-	xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n");
-	return;
-}
-
 inline static void
 set_signals(void)
 {
@@ -96,12 +87,7 @@ set_signals(void)
 	/* WARNING: the following works on Linux and SysV, but not BSD! */
 	sigaction(SIGCHLD, &sa, NULL);
 
-	sa.sa_handler = killer;
-	sigaction(SIGINT, &sa, NULL);
-	sigaction(SIGTERM, &sa, NULL);
-
-	sa.sa_handler = sig_hup;
-	sigaction(SIGHUP, &sa, NULL);
+	cache_block_signals();
 }
 
 static void
@@ -242,8 +228,10 @@ main(int argc, char **argv)
 	v4clients_init();
 
 	/* Process incoming upcalls */
-	while (cache_process(NULL) >= 0)
-		;
+	while (cache_process(NULL) >= 0) {
+		if (cache_stop_signal())
+			killer(cache_stop_signal());
+	}
 
 	xlog(L_ERROR, "%s: process loop terminated unexpectedly(%m). Exiting...\n",
 		progname);
-- 
2.53.0


  parent reply	other threads:[~2026-09-24 15:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 15:29 [PATCH 0/4] mountd/exportd: exit signal handling fixups Benjamin Coddington
2026-09-24 15:29 ` [PATCH 1/4] support/export: take SIGINT/SIGTERM/SIGHUP via signalfd Benjamin Coddington
2026-09-24 15:29 ` [PATCH 2/4] mountd: stop exiting from a signal handler Benjamin Coddington
2026-09-24 15:29 ` Benjamin Coddington [this message]
2026-09-24 15:29 ` [PATCH 4/4] mountd: hold SIGTERM during rpcbind registration instead of ignoring it Benjamin Coddington

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4513fefc0741f08cfa76777ae10edc6b579ad4db.1790263469.git.bcodding@hammerspace.com \
    --to=ben.coddington@hammerspace.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.