1 diff --git a/CHANGELOG b/CHANGELOG
2 index 6379d18..a9e509d 100644
6 - eliminate NULL proc ping for singleton host or local mounts.
7 - fix incorrect read/write size of startup status token (Matthias Koenig).
8 - fix off-by-one error for lookup of map keys exactly 255 characters long.
9 +- improve handling of server not available.
11 18/06/2007 autofs-5.0.2
12 -----------------------
13 diff --git a/daemon/lookup.c b/daemon/lookup.c
14 index 0be10d3..eb72411 100644
17 @@ -298,8 +298,6 @@ static int do_read_map(struct autofs_point *ap, struct map_source *map, time_t a
19 status = lookup->lookup_read_map(ap, age, lookup->context);
24 * For maps that don't support enumeration return success
25 * and do whatever we must to have autofs function with an
26 @@ -533,6 +531,10 @@ int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time
27 if (result == NSS_STATUS_UNKNOWN)
30 + /* Don't try to update the map cache if it's unavailable */
31 + if (result == NSS_STATUS_UNAVAIL)
34 if (result == NSS_STATUS_SUCCESS) {
36 result = NSS_STATUS_TRYAGAIN;
37 @@ -553,7 +555,7 @@ int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time
39 pthread_cleanup_pop(1);
41 - if (!result || at_least_one)
42 + if (!result || at_least_one)
46 diff --git a/daemon/state.c b/daemon/state.c
47 index cf07aac..5bccfef 100644
50 @@ -432,6 +432,7 @@ static void *do_readmap(void *arg)
51 me = cache_enumerate(mc, me);
53 pthread_cleanup_pop(1);
57 pthread_cleanup_pop(1);
58 diff --git a/include/automount.h b/include/automount.h
59 index fa5cd97..133fd32 100644
60 --- a/include/automount.h
61 +++ b/include/automount.h
62 @@ -121,6 +121,7 @@ struct autofs_point;
63 #define CHE_MISSING 0x0008
64 #define CHE_COMPLETED 0x0010
65 #define CHE_DUPLICATE 0x0020
66 +#define CHE_UNAVAIL 0x0040
69 #define NEGATIVE_TIMEOUT 10
70 diff --git a/modules/lookup_file.c b/modules/lookup_file.c
71 index 550bf5c..a77068a 100644
72 --- a/modules/lookup_file.c
73 +++ b/modules/lookup_file.c
74 @@ -469,11 +469,14 @@ int lookup_read_master(struct master *master, time_t age, void *context)
77 status = lookup_nss_read_master(master, age);
82 "failed to read included master map %s",
85 + return NSS_STATUS_UNAVAIL;
90 @@ -484,6 +487,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
93 MODPREFIX "could not malloc parse buffer");
95 return NSS_STATUS_UNAVAIL;
97 memset(buffer, 0, blen);
98 @@ -721,9 +725,12 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
100 /* Gim'ee some o' that 16k stack baby !! */
101 status = lookup_nss_read_map(ap, inc_source, age);
105 "failed to read included map %s", key);
107 + return NSS_STATUS_UNAVAIL;
112 diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
113 index b8484a2..7effbf1 100644
114 --- a/modules/lookup_ldap.c
115 +++ b/modules/lookup_ldap.c
116 @@ -1755,7 +1755,7 @@ static int lookup_one(struct autofs_point *ap,
117 /* Initialize the LDAP context. */
118 ldap = do_reconnect(ap->logopt, ctxt);
121 + return CHE_UNAVAIL;
124 MODPREFIX "searching for \"%s\" under \"%s\"", query, ctxt->qdn);
125 @@ -1999,6 +1999,21 @@ static int check_map_indirect(struct autofs_point *ap,
126 if (ret == CHE_FAIL) {
127 pthread_setcancelstate(cur_state, NULL);
128 return NSS_STATUS_NOTFOUND;
129 + } else if (ret == CHE_UNAVAIL) {
131 + * If the server is down and the entry exists in the cache
132 + * and belongs to this map return success and use the entry.
134 + struct mapent *exists = cache_lookup(mc, key);
135 + if (exists && exists->source == source) {
136 + pthread_setcancelstate(cur_state, NULL);
137 + return NSS_STATUS_SUCCESS;
141 + MODPREFIX "lookup for %s failed: connection failed", key);
143 + return NSS_STATUS_UNAVAIL;
145 pthread_setcancelstate(cur_state, NULL);
147 diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
148 index fee8b16..628ffcf 100644
149 --- a/modules/lookup_nisplus.c
150 +++ b/modules/lookup_nisplus.c
151 @@ -385,9 +385,18 @@ static int check_map_indirect(struct autofs_point *ap,
152 return NSS_STATUS_NOTFOUND;
156 + * If the server is down and the entry exists in the cache
157 + * and belongs to this map return success and use the entry.
159 + exists = cache_lookup(mc, key);
160 + if (exists && exists->source == source)
161 + return NSS_STATUS_SUCCESS;
164 MODPREFIX "lookup for %s failed: %s",
165 key, nis_sperrno(-ret));
167 return NSS_STATUS_UNAVAIL;
170 diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
171 index 5f4f95f..f5097dc 100644
172 --- a/modules/lookup_yp.c
173 +++ b/modules/lookup_yp.c
174 @@ -239,6 +239,9 @@ int lookup_read_master(struct master *master, time_t age, void *context)
175 MODPREFIX "read of master map %s failed: %s",
176 mapname, yperr_string(err));
178 + if (err == YPERR_PMAP || err == YPERR_YPSERV)
179 + return NSS_STATUS_UNAVAIL;
181 return NSS_STATUS_NOTFOUND;
184 @@ -336,6 +339,9 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
185 MODPREFIX "read of map %s failed: %s",
186 ap->path, yperr_string(err));
188 + if (err == YPERR_PMAP || err == YPERR_YPSERV)
189 + return NSS_STATUS_UNAVAIL;
191 return NSS_STATUS_NOTFOUND;
194 @@ -481,9 +487,18 @@ static int check_map_indirect(struct autofs_point *ap,
195 return NSS_STATUS_NOTFOUND;
199 + * If the server is down and the entry exists in the cache
200 + * and belongs to this map return success and use the entry.
202 + exists = cache_lookup(mc, key);
203 + if (exists && exists->source == source)
204 + return NSS_STATUS_SUCCESS;
207 MODPREFIX "lookup for %s failed: %s",
208 key, yperr_string(-ret));
210 return NSS_STATUS_UNAVAIL;