autofs-5.0.5 - fix master map source server unavailable handling From: Ian Kent If we get an NSS_STATUS_UNAVAIL from any server when trying to read the master map we have no choice but to not update mounted automounts because we can't know what entries may have come from the server that isn't avialable. So we leave everything the way it is and wait until the next re-read to update our mounts. --- CHANGELOG | 1 + daemon/automount.c | 5 +++-- daemon/lookup.c | 9 +++++++++ include/master.h | 1 + lib/master.c | 9 ++++++++- modules/lookup_file.c | 2 -- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d95542d..fc4e738 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ - add locality as valid ldap master map attribute. - add locality as valid ldap master map attribute fix. - add simple bind authentication. +- fix master map source server unavailable handling. 03/09/2009 autofs-5.0.5 ----------------------- diff --git a/daemon/automount.c b/daemon/automount.c index 7c44d4b..915928b 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -1478,7 +1478,6 @@ static void handle_mounts_cleanup(void *arg) master_free_mapent_sources(ap->entry, 1); master_free_mapent(ap->entry); } - master_mutex_unlock(); if (clean) { if (rmdir(path) == -1) { @@ -1497,7 +1496,9 @@ static void handle_mounts_cleanup(void *arg) */ if (!submount) pthread_kill(state_mach_thid, SIGTERM); - + + master_mutex_unlock(); + return; } diff --git a/daemon/lookup.c b/daemon/lookup.c index a4b9a80..8537861 100644 --- a/daemon/lookup.c +++ b/daemon/lookup.c @@ -157,6 +157,9 @@ int lookup_nss_read_master(struct master *master, time_t age) result = do_read_master(master, "file", age); } + if (result == NSS_STATUS_UNAVAIL) + master->read_fail = 1; + return !result; } else { char *name = master->name; @@ -194,6 +197,9 @@ int lookup_nss_read_master(struct master *master, time_t age) result = do_read_master(master, source, age); master->name = name; + if (result == NSS_STATUS_UNAVAIL) + master->read_fail = 1; + return !result; } } @@ -248,6 +254,9 @@ int lookup_nss_read_master(struct master *master, time_t age) continue; } + if (result == NSS_STATUS_UNAVAIL) + master->read_fail = 1; + status = check_nss_result(this, result); if (status >= 0) { free_sources(&nsslist); diff --git a/include/master.h b/include/master.h index c519e97..0d6aa82 100644 --- a/include/master.h +++ b/include/master.h @@ -56,6 +56,7 @@ struct master { unsigned int recurse; unsigned int depth; unsigned int reading; + unsigned int read_fail; unsigned int default_ghost; unsigned int default_logging; unsigned int default_timeout; diff --git a/lib/master.c b/lib/master.c index 83019aa..196b6b9 100644 --- a/lib/master.c +++ b/lib/master.c @@ -794,6 +794,7 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int g master->recurse = 0; master->depth = 0; master->reading = 0; + master->read_fail = 0; master->default_ghost = ghost; master->default_timeout = timeout; master->default_logging = defaults_get_logging(); @@ -821,7 +822,13 @@ int master_read_master(struct master *master, time_t age, int readall) master_init_scan(); lookup_nss_read_master(master, age); - master_mount_mounts(master, age, readall); + if (!master->read_fail) + master_mount_mounts(master, age, readall); + else { + master->read_fail = 0; + if (!readall) + master_mount_mounts(master, age, readall); + } master_mutex_lock(); diff --git a/modules/lookup_file.c b/modules/lookup_file.c index e43ab2f..6104d0c 100644 --- a/modules/lookup_file.c +++ b/modules/lookup_file.c @@ -656,8 +656,6 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context) if (!status) { warn(ap->logopt, "failed to read included map %s", key); - fclose(f); - return NSS_STATUS_UNAVAIL; } } else { char *s_key;