aboutsummaryrefslogtreecommitdiff
path: root/nscd/nscd_initgroups.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/nscd_initgroups.c')
-rw-r--r--nscd/nscd_initgroups.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c
index 513d35d..c33c76d 100644
--- a/nscd/nscd_initgroups.c
+++ b/nscd/nscd_initgroups.c
@@ -46,17 +46,19 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
gid_t **groupsp, long int limit)
{
size_t userlen = strlen (user) + 1;
+ int gc_cycle;
+
+ /* If the mapping is available, try to search there instead of
+ communicating with the nscd. */
+ struct mapped_database *mapped;
+ mapped = __nscd_get_map_ref (GETFDGR, "group", &map_handle, &gc_cycle);
+
+ retry:;
const initgr_response_header *initgr_resp = NULL;
char *respdata = NULL;
int retval = -1;
int sock = -1;
- int gc_cycle;
- /* If the mapping is available, try to search there instead of
- communicating with the nscd. */
- struct mapped_database *mapped = __nscd_get_map_ref (GETFDGR, "group",
- &map_handle, &gc_cycle);
- retry:
if (mapped != NO_MAPPING)
{
const struct datahead *found = __nscd_cache_search (INITGROUPS, user,
@@ -148,11 +150,20 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
if (sock != -1)
close_not_cancel_no_status (sock);
out:
- if (__nscd_drop_map_ref (mapped, gc_cycle) != 0)
- /* When we come here this means there has been a GC cycle while we
- were looking for the data. This means the data might have been
- inconsistent. Retry. */
- goto retry;
+ if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0 && retval != -1)
+ {
+ /* When we come here this means there has been a GC cycle while we
+ were looking for the data. This means the data might have been
+ inconsistent. Retry if possible. */
+ if ((gc_cycle & 1) != 0)
+ {
+ /* nscd is just running gc now. Disable using the mapping. */
+ __nscd_unmap (mapped);
+ mapped = NO_MAPPING;
+ }
+
+ goto retry;
+ }
return retval;
}