diff options
Diffstat (limited to 'source/nmbd/nmbd.c')
-rw-r--r-- | source/nmbd/nmbd.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index fa4e1c4cfd9..52f9d6d9f03 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -50,55 +50,52 @@ BOOL found_lm_clients = False; time_t StartupTime = 0; -extern struct in_addr ipzero; - /**************************************************************************** ** - 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 /**************************************************************************** ** @@ -337,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 @@ -493,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 */ @@ -662,6 +671,7 @@ static void usage(char *pname) extern FILE *dbf; extern char *optarg; extern BOOL append_log; + extern BOOL AllowDebugChange; BOOL opt_interactive = False; pstring logfile; @@ -754,6 +764,7 @@ static void usage(char *pname) break; case 'd': DEBUGLEVEL = atoi(optarg); + AllowDebugChange = False; break; case 'p': global_nmb_port = atoi(optarg); |