]> andersk Git - nss_nonlocal.git/blobdiff - walk_nss.h
Guard one-time initialization with memory barriers
[nss_nonlocal.git] / walk_nss.h
index 93af177121ff0ae4d2791de003153729cd2c5b2f..78d3575539be152e3c624609f3e73e3c2b6ea4ae 100644 (file)
@@ -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 {
     } 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;
This page took 0.025999 seconds and 4 git commands to generate.