aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2023-10-17 15:12:10 +0800
committerIan Kent <raven@themaw.net>2023-11-02 08:33:47 +0800
commita2b99f1ff5d4f62926e027df2de5a96aa941391e (patch)
tree0977efad2a1a789629eddfbdd8ec6d6c2c8e7e41
parentb8f436bfaf618cf6476e040dc3031ae47625035a (diff)
downloadautofs-a2b99f1ff5d4f62926e027df2de5a96aa941391e.tar.gz
autofs-5.1.8 - be more careful with cmd pipe at exit
It shouldn't be needed, as everthing should be shutdown by the time the cmd pipe is destroyed, but be more careful at exit anyway. Signed-off-by: Ian Kent <raven@themaw.net>
-rw-r--r--CHANGELOG1
-rw-r--r--daemon/automount.c11
2 files changed, 8 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 23efc053..a87f16eb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -102,6 +102,7 @@
- fix ldap_parse_page_control() check.
- fix typo in create_cmd_pipe_fifo().
- add null check in master_kill().
+- be more careful with cmd pipe at exit.
19/10/2021 autofs-5.1.8
- add xdr_exports().
diff --git a/daemon/automount.c b/daemon/automount.c
index c125e625..6cb3b1be 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1622,19 +1622,18 @@ static void *cmd_pipe_handler(void *arg)
while (1) {
cmd_pipe_mutex_lock();
- if (done) {
- cmd_pipe_mutex_unlock();
+ if (done)
break;
- }
cmd_pipe_mutex_unlock();
errno = 0;
if (ppoll(fds, pollfds, NULL, &signalset) == -1) {
if (errno == EINTR)
continue;
+ cmd_pipe_mutex_lock();
estr = strerror_r(errno, buf, MAX_ERR_BUF);
logerr("poll failed: %s", estr);
- return NULL;
+ break;
}
if (fds[0].revents & POLLIN) {
@@ -1643,6 +1642,7 @@ static void *cmd_pipe_handler(void *arg)
}
}
destroy_cmd_pipe_fifo();
+ cmd_pipe_mutex_unlock();
return NULL;
}
@@ -1673,8 +1673,11 @@ int start_cmd_pipe_handler(void)
void finish_cmd_pipe_handler(void)
{
cmd_pipe_mutex_lock();
+ if (cmd_pipe_thid == -1 || done)
+ goto exit;
done = 1;
pthread_kill(cmd_pipe_thid, SIGPIPE);
+exit:
cmd_pipe_mutex_unlock();
}