X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fmain.c;h=85b5147fceaea4e52f35930130ca21d605179335;hb=dcbfd39d8a7df800a55ab0160d890bd61ebc7302;hp=de8ae711e3a6a2ac21ccf6a3b326f83d8d847d7f;hpb=34b8db12ed883e525f49ec77372141c1ca8414bb;p=netatalk.git diff --git a/etc/afpd/main.c b/etc/afpd/main.c index de8ae711..85b5147f 100644 --- a/etc/afpd/main.c +++ b/etc/afpd/main.c @@ -40,6 +40,7 @@ #include "status.h" #include "fork.h" #include "uam_auth.h" +#include "afp_zeroconf.h" #ifdef TRU64 #include @@ -57,6 +58,7 @@ static AFPConfig *configs; static server_child *server_children; static fd_set save_rfds; static int Ipc_fd = -1; +static sig_atomic_t reloadconfig = 0; #ifdef TRU64 void afp_get_cmdline( int *ac, char ***av) @@ -100,50 +102,30 @@ static void afp_goaway(int sig) dsi_kill(sig); switch( sig ) { + case SIGTERM : LOG(log_info, logtype_afpd, "shutting down on signal %d", sig ); + AFPConfig *config; + for (config = configs; config; config = config->next) + if (config->server_cleanup) + config->server_cleanup(config); + afp_exit(0); break; + case SIGUSR1 : - case SIGHUP : - /* w/ a configuration file, we can force a re-read if we want */ nologin++; auth_unload(); - if (sig == SIGHUP || ((nologin + 1) & 1)) { - AFPConfig *config; - - LOG(log_info, logtype_afpd, "re-reading configuration file"); - for (config = configs; config; config = config->next) - if (config->server_cleanup) - config->server_cleanup(config); + LOG(log_info, logtype_afpd, "disallowing logins"); + break; - /* configfree close atp socket used for DDP tickle, there's an issue - * with atp tid. - */ - configfree(configs, NULL); - if (!(configs = configinit(&default_options))) { - LOG(log_error, logtype_afpd, "config re-read: no servers configured"); - afp_exit(EXITERR_CONF); - } - set_fd(Ipc_fd); - } else { - LOG(log_info, logtype_afpd, "disallowing logins"); - } - if (sig == SIGHUP) { - nologin = 0; - } + case SIGHUP : + /* w/ a configuration file, we can force a re-read if we want */ + reloadconfig = 1; break; + default : LOG(log_error, logtype_afpd, "afp_goaway: bad signal" ); } - if ( sig == SIGTERM ) { - AFPConfig *config; - - for (config = configs; config; config = config->next) - if (config->server_cleanup) - config->server_cleanup(config); - - afp_exit(0); - } return; } @@ -277,12 +259,12 @@ int main(int ac, char **av) #endif sigaddset(&sigs, SIGCHLD); - sigprocmask(SIG_BLOCK, &sigs, NULL); + pthread_sigmask(SIG_BLOCK, &sigs, NULL); if (!(configs = configinit(&default_options))) { LOG(log_error, logtype_afpd, "main: no servers configured"); afp_exit(EXITERR_CONF); } - sigprocmask(SIG_UNBLOCK, &sigs, NULL); + pthread_sigmask(SIG_UNBLOCK, &sigs, NULL); /* Register CNID */ cnid_init(); @@ -301,9 +283,34 @@ int main(int ac, char **av) * solution. */ while (1) { rfds = save_rfds; - sigprocmask(SIG_UNBLOCK, &sigs, NULL); + pthread_sigmask(SIG_UNBLOCK, &sigs, NULL); ret = select(FD_SETSIZE, &rfds, NULL, NULL, NULL); - sigprocmask(SIG_BLOCK, &sigs, NULL); + pthread_sigmask(SIG_BLOCK, &sigs, NULL); + int saveerrno = errno; + + if (reloadconfig) { + nologin++; + auth_unload(); + AFPConfig *config; + + LOG(log_info, logtype_afpd, "re-reading configuration file"); + for (config = configs; config; config = config->next) + if (config->server_cleanup) + config->server_cleanup(config); + + /* configfree close atp socket used for DDP tickle, there's an issue + * with atp tid. */ + configfree(configs, NULL); + if (!(configs = configinit(&default_options))) { + LOG(log_error, logtype_afpd, "config re-read: no servers configured"); + afp_exit(EXITERR_CONF); + } + set_fd(Ipc_fd); + nologin = 0; + reloadconfig = 0; + errno = saveerrno; + } + if (ret < 0) { if (errno == EINTR) continue;