summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-03-27 14:23:20 -0700
committerJeremy Allison <jra@samba.org>2008-03-27 14:23:20 -0700
commitf3d4cb5efa72c8665ed95dad605c7235d9ff568f (patch)
tree6ff4c3e3b1df54a53e144bd760e1145c52b3a64c
parent48e238de9b4acb3af5bd117b53cd3802192bca60 (diff)
downloadsamba-f3d4cb5efa72c8665ed95dad605c7235d9ff568f.tar.gz
samba-f3d4cb5efa72c8665ed95dad605c7235d9ff568f.tar.bz2
samba-f3d4cb5efa72c8665ed95dad605c7235d9ff568f.zip
Fix for termination problems when no interfaces found - bug #5267.
Jeremy. (This used to be commit 4b03f4eb2da7a523967ace3d13e79406ade07d47)
-rw-r--r--source3/nmbd/nmbd.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 00d252940a..9797a7adb6 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -182,11 +182,12 @@ static void reload_interfaces(time_t t)
return;
}
+ try_again:
+
/* the list of probed interfaces has changed, we may need to add/remove
some subnets */
load_interfaces();
- try_again:
/* find any interfaces that need adding */
for (n=iface_count() - 1; n >= 0; n--) {
@@ -278,7 +279,6 @@ static void reload_interfaces(time_t t)
/* We need to wait if there are no subnets... */
if (FIRST_SUBNET == NULL) {
- void (*saved_handler)(int);
DEBUG(0,("reload_interfaces: "
"No subnets to listen to. Waiting..\n"));
@@ -288,19 +288,28 @@ static void reload_interfaces(time_t t)
* cause us to exit.
*/
- saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
+ BlockSignals(false, SIGTERM);
/* We only count IPv4 interfaces here. */
- while (iface_count_v4() == 0) {
+ while (iface_count_v4() == 0 && !got_sig_term) {
sleep(5);
load_interfaces();
}
/*
- * We got an interface, restore our normal term handler.
+ * Handle termination inband.
+ */
+
+ if (got_sig_term) {
+ got_sig_term = 0;
+ terminate();
+ }
+
+ /*
+ * We got an interface, go back to blocking term.
*/
- CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
+ BlockSignals(true, SIGTERM);
goto try_again;
}
}