]>
Commit | Line | Data |
---|---|---|
3d551623 PG |
1 | diff --git a/CHANGELOG b/CHANGELOG |
2 | index 5aee44c..9c99966 100644 | |
3 | --- a/CHANGELOG | |
4 | +++ b/CHANGELOG | |
5 | @@ -17,6 +17,7 @@ | |
6 | - don't fail on empty master map. | |
7 | - add support for the "%" hack for case insensitive attribute schemas. | |
8 | - fix "nosymlink" option handling and add desription to man page. | |
9 | +- fix don't fail on empty master map. | |
10 | ||
11 | 18/06/2007 autofs-5.0.2 | |
12 | ----------------------- | |
13 | diff --git a/daemon/automount.c b/daemon/automount.c | |
14 | index 9809b9c..7b79f02 100644 | |
15 | --- a/daemon/automount.c | |
16 | +++ b/daemon/automount.c | |
17 | @@ -61,6 +61,8 @@ static size_t kpkt_len; | |
18 | ||
19 | /* Attribute to create detached thread */ | |
20 | pthread_attr_t thread_attr; | |
21 | +/* Attribute to create normal thread */ | |
22 | +pthread_attr_t thread_attr_nodetach; | |
23 | ||
24 | struct master_readmap_cond mrc = { | |
25 | PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0}; | |
26 | @@ -914,7 +916,7 @@ static void *do_notify_state(void *arg) | |
27 | return NULL; | |
28 | } | |
29 | ||
30 | -static int do_signals(struct master *master, int sig) | |
31 | +static pthread_t do_signals(struct master *master, int sig) | |
32 | { | |
33 | pthread_t thid; | |
34 | int r_sig = sig; | |
35 | @@ -924,7 +926,7 @@ static int do_signals(struct master *master, int sig) | |
36 | if (status) | |
37 | fatal(status); | |
38 | ||
39 | - status = pthread_create(&thid, &thread_attr, do_notify_state, &r_sig); | |
40 | + status = pthread_create(&thid, &thread_attr_nodetach, do_notify_state, &r_sig); | |
41 | if (status) { | |
42 | error(master->default_logging, | |
43 | "mount state notify thread create failed"); | |
44 | @@ -948,7 +950,7 @@ static int do_signals(struct master *master, int sig) | |
45 | ||
46 | pthread_cleanup_pop(1); | |
47 | ||
48 | - return 1; | |
49 | + return thid; | |
50 | } | |
51 | ||
52 | static void *do_read_master(void *arg) | |
53 | @@ -1038,6 +1040,7 @@ static int do_hup_signal(struct master *master, time_t age) | |
54 | /* Deal with all the signal-driven events in the state machine */ | |
55 | static void *statemachine(void *arg) | |
56 | { | |
57 | + pthread_t thid = 0; | |
58 | sigset_t signalset; | |
59 | int sig; | |
60 | ||
61 | @@ -1048,15 +1051,17 @@ static void *statemachine(void *arg) | |
62 | while (1) { | |
63 | sigwait(&signalset, &sig); | |
64 | ||
65 | - | |
66 | - if (master_list_empty(master_list)) | |
67 | - return NULL; | |
68 | - | |
69 | switch (sig) { | |
70 | case SIGTERM: | |
71 | case SIGUSR2: | |
72 | case SIGUSR1: | |
73 | - do_signals(master_list, sig); | |
74 | + thid = do_signals(master_list, sig); | |
75 | + if (thid) { | |
76 | + pthread_join(thid, NULL); | |
77 | + if (master_list_empty(master_list)) | |
78 | + return NULL; | |
79 | + thid = 0; | |
80 | + } | |
81 | break; | |
82 | ||
83 | case SIGHUP: | |
84 | @@ -1171,10 +1176,6 @@ static void handle_mounts_cleanup(void *arg) | |
85 | ||
86 | msg("shut down path %s", path); | |
87 | ||
88 | - /* If we are the last tell the state machine to shutdown */ | |
89 | - if (!submount && master_list_empty(master_list)) | |
90 | - kill(getpid(), SIGTERM); | |
91 | - | |
92 | return; | |
93 | } | |
94 | ||
95 | @@ -1644,6 +1645,14 @@ int main(int argc, char *argv[]) | |
96 | } | |
97 | #endif | |
98 | ||
99 | + if (pthread_attr_init(&thread_attr_nodetach)) { | |
100 | + crit(LOGOPT_ANY, | |
101 | + "%s: failed to init thread attribute struct!", | |
102 | + program); | |
103 | + close(start_pipefd[1]); | |
104 | + exit(1); | |
105 | + } | |
106 | + | |
107 | msg("Starting automounter version %s, master map %s", | |
108 | version, master_list->name); | |
109 | msg("using kernel protocol version %d.%02d", | |
110 | diff --git a/lib/master.c b/lib/master.c | |
111 | index 9f24f7e..da05bb6 100644 | |
112 | --- a/lib/master.c | |
113 | +++ b/lib/master.c | |
114 | @@ -802,7 +802,7 @@ int master_read_master(struct master *master, time_t age, int readall) | |
115 | ||
116 | if (list_empty(&master->mounts)) { | |
117 | master_mutex_unlock(); | |
118 | - error(LOGOPT_ANY, "no mounts in table"); | |
119 | + warn(LOGOPT_ANY, "no mounts in table"); | |
120 | return 1; | |
121 | } | |
122 |