diff options
author | Jeremy Allison <jra@samba.org> | 2002-03-02 01:01:11 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-03-02 01:01:11 +0000 |
commit | db5c429cde1c943678a85434ce261b18110dc6f3 (patch) | |
tree | ae7d41e23a728a8fe614aa0a463a16124b2b1b51 | |
parent | 7c68e611a014275c9a878064f9ec04593441be54 (diff) | |
download | samba-db5c429cde1c943678a85434ce261b18110dc6f3.tar.gz samba-db5c429cde1c943678a85434ce261b18110dc6f3.tar.xz samba-db5c429cde1c943678a85434ce261b18110dc6f3.zip |
This code is so obviously correct it really needs to be in 2.2.x.
Jeremy.
-rw-r--r-- | source/nmbd/nmbd.c | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index 4b624a5b2df..52f9d6d9f03 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -51,52 +51,51 @@ BOOL found_lm_clients = False; time_t StartupTime = 0; /**************************************************************************** ** - Catch a sigterm. + Handle a SIGTERM in band. **************************************************************************** */ -static void sig_term(int sig) +static void terminate(void) { - BlockSignals(True,SIGTERM); - - DEBUG(0,("Got SIGTERM: going down...\n")); - - /* Write out wins.dat file if samba is a WINS server */ - wins_write_database(False); - - /* Remove all SELF registered names. */ - release_my_names(); - - /* Announce all server entries as 0 time-to-live, 0 type. */ - announce_my_servers_removed(); + DEBUG(0,("Got SIGTERM: going down...\n")); + + /* Write out wins.dat file if samba is a WINS server */ + wins_write_database(False); - /* If there was an async dns child - kill it. */ - kill_async_dns_child(); + /* Remove all SELF registered names. */ + release_my_names(); - exit(0); + /* Announce all server entries as 0 time-to-live, 0 type. */ + announce_my_servers_removed(); -} /* sig_term */ + /* If there was an async dns child - kill it. */ + kill_async_dns_child(); + + exit(0); +} /**************************************************************************** ** - Catch a sighup. + Catch a SIGTERM signal. **************************************************************************** */ -static VOLATILE sig_atomic_t reload_after_sighup = False; +static VOLATILE sig_atomic_t got_sig_term; -static void sig_hup(int sig) +static void sig_term(int sig) { - BlockSignals( True, SIGHUP ); - - DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) ); - - write_browse_list( 0, True ); - - dump_all_namelists(); + got_sig_term = 1; + sys_select_signal(); +} - reload_after_sighup = True; +/**************************************************************************** ** + Catch a SIGHUP signal. + **************************************************************************** */ - BlockSignals(False,SIGHUP); +static VOLATILE sig_atomic_t reload_after_sighup; -} /* sig_hup */ +static void sig_hup(int sig) +{ + reload_after_sighup = 1; + sys_select_signal(); +} #if DUMP_CORE /**************************************************************************** ** @@ -335,6 +334,15 @@ static void process(void) return; /* + * Handle termination inband. + */ + + if (got_sig_term) { + got_sig_term = 0; + terminate(); + } + + /* * Process all incoming packets * read above. This calls the success and * failure functions registered when response @@ -491,11 +499,14 @@ static void process(void) */ if(reload_after_sighup) { - reload_nmbd_services( True ); - reopen_logs(); - if(reload_interfaces(0)) - return; - reload_after_sighup = False; + DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) ); + write_browse_list( 0, True ); + dump_all_namelists(); + reload_nmbd_services( True ); + reopen_logs(); + if(reload_interfaces(0)) + return; + reload_after_sighup = 0; } /* check for new network interfaces */ |