autofs/SOURCES/autofs-5.1.6-move-readall-into-struct-master.patch

204 lines
6.5 KiB
Diff
Raw Normal View History

2021-05-18 06:36:15 +00:00
autofs-5.1.6 - move readall into struct master
From: Ian Kent <raven@themaw.net>
The lookup modules may need to know if the master map is being re-read
vis a HUP signal or is being read for the first time.
This is indicated by the readall variable so move it into the master
map structure so it's accessable to lookup modules.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 28 +++++++++++++++++-----------
include/master.h | 5 +++--
lib/master.c | 15 ++++++++-------
4 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4d83df2..4a6c042 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -103,6 +103,7 @@ xx/xx/2018 autofs-5.1.5
- refactor sss getautomntent().
- improve sss getautomntent() error handling.
- sss introduce calculate_retry_count() function.
+- move readall into struct master.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/daemon/automount.c b/daemon/automount.c
index 019bd81..9660f3f 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1465,7 +1465,6 @@ static void *do_read_master(void *arg)
struct master *master;
unsigned int logopt;
time_t age;
- int readall = 1;
int status;
status = pthread_mutex_lock(&mrc.mutex);
@@ -1496,8 +1495,11 @@ static void *do_read_master(void *arg)
info(logopt, "re-reading master map %s", master->name);
- status = master_read_master(master, age, readall);
+ master->readall = 1;
+ status = master_read_master(master, age);
+
+ master->readall = 0;
master->reading = 0;
return NULL;
@@ -2196,7 +2198,7 @@ static void do_master_list_reset(struct master *master)
master_mutex_unlock();
}
-static int do_master_read_master(struct master *master, int wait)
+static int do_master_read_master(struct master *master, time_t *age, int wait)
{
sigset_t signalset;
/* Wait must be at least 1 second */
@@ -2204,7 +2206,6 @@ static int do_master_read_master(struct master *master, int wait)
unsigned int elapsed = 0;
int max_wait = wait;
int ret = 0;
- time_t age;
sigemptyset(&signalset);
sigaddset(&signalset, SIGTERM);
@@ -2217,8 +2218,8 @@ static int do_master_read_master(struct master *master, int wait)
do_master_list_reset(master);
- age = monotonic_time(NULL);
- if (master_read_master(master, age, 0)) {
+ *age = monotonic_time(NULL);
+ if (master_read_master(master, *age)) {
ret = 1;
break;
}
@@ -2692,14 +2693,14 @@ int main(int argc, char *argv[])
dh_tirpc = dlopen("libtirpc.so.3", RTLD_NOW);
#endif
- master_read = master_read_master(master_list, age, 0);
+ master_read = master_read_master(master_list, age);
if (!master_read) {
/*
* Read master map, waiting until it is available, unless
* a signal is received, in which case exit returning an
* error.
*/
- if (!do_master_read_master(master_list, master_wait)) {
+ if (!do_master_read_master(master_list, &age, master_wait)) {
logmsg("%s: warning: could not read at least one "
"map source after waiting, continuing ...",
program);
@@ -2707,9 +2708,14 @@ int main(int argc, char *argv[])
* Failed to read master map, continue with what
* we have anyway.
*/
- do_master_list_reset(master_list);
- age = monotonic_time(NULL);
- master_read_master(master_list, age, 1);
+ master_mutex_lock();
+ master_list->readall = 1;
+ master_mount_mounts(master_list, age);
+ master_list->readall = 0;
+
+ if (list_empty(&master_list->mounts))
+ warn(master_list->logopt, "no mounts in table");
+ master_mutex_unlock();
}
}
diff --git a/include/master.h b/include/master.h
index e1d272f..f689297 100644
--- a/include/master.h
+++ b/include/master.h
@@ -63,6 +63,7 @@ struct master {
unsigned int depth;
unsigned int reading;
unsigned int read_fail;
+ unsigned int readall;
unsigned int default_ghost;
unsigned int default_logging;
unsigned int default_timeout;
@@ -118,11 +119,11 @@ void master_remove_mapent(struct master_mapent *);
void master_free_mapent_sources(struct master_mapent *, unsigned int);
void master_free_mapent(struct master_mapent *);
struct master *master_new(const char *, unsigned int, unsigned int);
-int master_read_master(struct master *, time_t, int);
+int master_read_master(struct master *, time_t);
int master_submount_list_empty(struct autofs_point *ap);
int master_notify_submount(struct autofs_point *, const char *path, enum states);
void master_notify_state_change(struct master *, int);
-int master_mount_mounts(struct master *, time_t, int);
+int master_mount_mounts(struct master *, time_t);
int dump_map(struct master *, const char *, const char *);
int master_show_mounts(struct master *);
unsigned int master_get_logopt(void);
diff --git a/lib/master.c b/lib/master.c
index fedf807..d87d7e2 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -951,6 +951,7 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int f
master->depth = 0;
master->reading = 0;
master->read_fail = 0;
+ master->readall = 0;
master->default_ghost = flags & DAEMON_FLAGS_GHOST;
master->default_timeout = timeout;
master->default_logging = defaults_get_logging();
@@ -1126,7 +1127,7 @@ again:
}
}
-int master_read_master(struct master *master, time_t age, int readall)
+int master_read_master(struct master *master, time_t age)
{
unsigned int logopt = master->logopt;
struct mapent_cache *nc;
@@ -1157,15 +1158,15 @@ int master_read_master(struct master *master, time_t age, int readall)
master_add_amd_mount_section_mounts(master, age);
if (!master->read_fail)
- master_mount_mounts(master, age, readall);
+ master_mount_mounts(master, age);
else {
master->read_fail = 0;
- /* HUP signal sets readall == 1 only */
- if (!readall) {
+ /* HUP signal sets master->readall == 1 only */
+ if (!master->readall) {
master_mutex_unlock();
return 0;
} else
- master_mount_mounts(master, age, readall);
+ master_mount_mounts(master, age);
}
if (list_empty(&master->mounts))
@@ -1452,7 +1453,7 @@ static void check_update_map_sources(struct master_mapent *entry, int readall)
return;
}
-int master_mount_mounts(struct master *master, time_t age, int readall)
+int master_mount_mounts(struct master *master, time_t age)
{
struct mapent_cache *nc = master->nc;
struct list_head *p, *head;
@@ -1536,7 +1537,7 @@ cont:
st_mutex_unlock();
if (!ret)
- check_update_map_sources(this, readall);
+ check_update_map_sources(this, master->readall);
else if (ret == -1 && save_errno == EBADF) {
if (!master_do_mount(this)) {
list_del_init(&this->list);