]> andersk Git - nss_nonlocal.git/blobdiff - nonlocal-passwd.c
Guard one-time initialization with memory barriers
[nss_nonlocal.git] / nonlocal-passwd.c
index b9a14b544dfde3c7329b575d430b5d983deb14c6..f8e7f96f823ded1760977b01a28025ea8b851f43 100644 (file)
@@ -162,6 +162,7 @@ get_nonlocal_passwd(const char *name, struct passwd *pwd, char **buffer,
 }
 
 
+static bool pwent_initialized = false;
 static service_user *pwent_startp, *pwent_nip;
 static void *pwent_fct_start;
 static union {
@@ -186,9 +187,12 @@ _nss_nonlocal_setpwent(int stayopen)
     if (status != NSS_STATUS_SUCCESS)
        return status;
 
-    if (pwent_fct_start == NULL)
+    if (!pwent_initialized) {
        __nss_passwd_nonlocal_lookup(&pwent_startp, pwent_fct_name,
                                     &pwent_fct_start);
+       __sync_synchronize();
+       pwent_initialized = true;
+    }
     pwent_nip = pwent_startp;
     pwent_fct.ptr = pwent_fct_start;
     return NSS_STATUS_SUCCESS;
This page took 0.026035 seconds and 4 git commands to generate.