]> andersk Git - nss_nonlocal.git/blobdiff - nonlocal-shadow.c
Guard one-time initialization with memory barriers
[nss_nonlocal.git] / nonlocal-shadow.c
index bfc201c48e85a489f6eb208e8a6494596bd55170..98142e183cfbfc9cc269cde1c1922793ab931a79 100644 (file)
@@ -58,6 +58,7 @@ __nss_shadow_nonlocal_lookup(service_user **ni, const char *fct_name,
 }
 
 
+static bool spent_initialized = false;
 static service_user *spent_startp, *spent_nip;
 static void *spent_fct_start;
 static union {
@@ -82,9 +83,12 @@ _nss_nonlocal_setspent(int stayopen)
     if (status != NSS_STATUS_SUCCESS)
        return status;
 
-    if (spent_fct_start == NULL)
+    if (!spent_initialized) {
        __nss_shadow_nonlocal_lookup(&spent_startp, spent_fct_name,
                                     &spent_fct_start);
+       __sync_synchronize();
+       spent_initialized = true;
+    }
     spent_nip = spent_startp;
     spent_fct.ptr = spent_fct_start;
     return NSS_STATUS_SUCCESS;
This page took 0.095084 seconds and 4 git commands to generate.