X-Git-Url: http://andersk.mit.edu/gitweb/nss_nonlocal.git/blobdiff_plain/cbb0e3ea444ff761b58c8f9355af1dfc631bc64b..23ca0ded6f524a412d868f5bdc5bd7c9b6b1cc4e:/walk_nss.h diff --git a/walk_nss.h b/walk_nss.h index 93af177..24cf4c5 100644 --- a/walk_nss.h +++ b/walk_nss.h @@ -24,8 +24,9 @@ */ { - static service_user *startp = NULL; - static void *fct_start = NULL; + static bool initialized = false; + static service_user *startp; + static void *fct_start; service_user *nip; union { @@ -34,10 +35,13 @@ } fct; int old_errno = errno; - if (fct_start == NULL && - w.lookup(&startp, w.fct_name, &fct_start) != 0) { - *w.status = NSS_STATUS_UNAVAIL; - goto walk_nss_out; + if (!initialized) { + if (w.lookup(&startp, w.fct_name, &fct_start) != 0) { + *w.status = NSS_STATUS_UNAVAIL; + goto walk_nss_out; + } + __sync_synchronize(); + initialized = true; } nip = startp; @@ -75,7 +79,8 @@ } goto walk_nss_morebuf; } - } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, 0) == 0); + } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, w.all_values) == + 0); if (w.buf != NULL && *w.status != NSS_STATUS_SUCCESS) { free(*w.buf);