diff --git a/CHANGELOG b/CHANGELOG index 5aee44c..9c99966 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ - don't fail on empty master map. - add support for the "%" hack for case insensitive attribute schemas. - fix "nosymlink" option handling and add desription to man page. +- fix don't fail on empty master map. 18/06/2007 autofs-5.0.2 ----------------------- diff --git a/daemon/automount.c b/daemon/automount.c index 9809b9c..7b79f02 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -61,6 +61,8 @@ static size_t kpkt_len; /* Attribute to create detached thread */ pthread_attr_t thread_attr; +/* Attribute to create normal thread */ +pthread_attr_t thread_attr_nodetach; struct master_readmap_cond mrc = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0}; @@ -914,7 +916,7 @@ static void *do_notify_state(void *arg) return NULL; } -static int do_signals(struct master *master, int sig) +static pthread_t do_signals(struct master *master, int sig) { pthread_t thid; int r_sig = sig; @@ -924,7 +926,7 @@ static int do_signals(struct master *master, int sig) if (status) fatal(status); - status = pthread_create(&thid, &thread_attr, do_notify_state, &r_sig); + status = pthread_create(&thid, &thread_attr_nodetach, do_notify_state, &r_sig); if (status) { error(master->default_logging, "mount state notify thread create failed"); @@ -948,7 +950,7 @@ static int do_signals(struct master *master, int sig) pthread_cleanup_pop(1); - return 1; + return thid; } static void *do_read_master(void *arg) @@ -1038,6 +1040,7 @@ static int do_hup_signal(struct master *master, time_t age) /* Deal with all the signal-driven events in the state machine */ static void *statemachine(void *arg) { + pthread_t thid = 0; sigset_t signalset; int sig; @@ -1048,15 +1051,17 @@ static void *statemachine(void *arg) while (1) { sigwait(&signalset, &sig); - - if (master_list_empty(master_list)) - return NULL; - switch (sig) { case SIGTERM: case SIGUSR2: case SIGUSR1: - do_signals(master_list, sig); + thid = do_signals(master_list, sig); + if (thid) { + pthread_join(thid, NULL); + if (master_list_empty(master_list)) + return NULL; + thid = 0; + } break; case SIGHUP: @@ -1171,10 +1176,6 @@ static void handle_mounts_cleanup(void *arg) msg("shut down path %s", path); - /* If we are the last tell the state machine to shutdown */ - if (!submount && master_list_empty(master_list)) - kill(getpid(), SIGTERM); - return; } @@ -1644,6 +1645,14 @@ int main(int argc, char *argv[]) } #endif + if (pthread_attr_init(&thread_attr_nodetach)) { + crit(LOGOPT_ANY, + "%s: failed to init thread attribute struct!", + program); + close(start_pipefd[1]); + exit(1); + } + msg("Starting automounter version %s, master map %s", version, master_list->name); msg("using kernel protocol version %d.%02d", diff --git a/lib/master.c b/lib/master.c index 9f24f7e..da05bb6 100644 --- a/lib/master.c +++ b/lib/master.c @@ -802,7 +802,7 @@ int master_read_master(struct master *master, time_t age, int readall) if (list_empty(&master->mounts)) { master_mutex_unlock(); - error(LOGOPT_ANY, "no mounts in table"); + warn(LOGOPT_ANY, "no mounts in table"); return 1; }