- rfds = save_rfds;
- if (select(FD_SETSIZE, &rfds, NULL, NULL, NULL) < 0) {
- if (errno == EINTR)
- continue;
- syslog(LOG_ERR, "main: can't wait for input: %m");
- break;
- }
-
- for (config = configs; config; config = config->next) {
- if (config->fd < 0)
- continue;
- if (FD_ISSET(config->fd, &rfds))
- config->server_start(config, configs, server_children);
- }
+ rfds = save_rfds;
+ pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);
+ ret = select(FD_SETSIZE, &rfds, NULL, NULL, 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;
+ LOG(log_error, logtype_afpd, "main: can't wait for input: %s", strerror(errno));
+ break;
+ }
+ if (Ipc_fd >=0 && FD_ISSET(Ipc_fd, &rfds)) {
+ server_ipc_read(server_children);
+ }
+ for (config = configs; config; config = config->next) {
+ if (config->fd < 0)
+ continue;
+ if (FD_ISSET(config->fd, &rfds)) {
+ config->server_start(config, configs, server_children);
+ }
+ }