Revert "InitOnceExecuteOnce not present on XP" mac-installer
authorLuke Howard <lukeh@padl.com>
Mon, 12 Dec 2011 09:30:38 +0000 (20:30 +1100)
committerLuke Howard <lukeh@padl.com>
Mon, 12 Dec 2011 09:31:30 +0000 (20:31 +1100)
This reverts commit 061ae16ba14ef7a70bdb4741a1e04ced4d5d7b09.

There is still a race in this lockless one-time initialization which
could cause an assertion failure. Until we decide whether XP support
for the acceptor is required, back this out.

mech_eap/util.h
mech_eap/util_attr.cpp

index 23d6ff8..4f54d41 100644 (file)
@@ -816,12 +816,14 @@ verifyTokenHeader(OM_uint32 *minor,
 #define GSSEAP_MUTEX_DESTROY(m)         DeleteCriticalSection((m))
 #define GSSEAP_MUTEX_LOCK(m)            EnterCriticalSection((m))
 #define GSSEAP_MUTEX_UNLOCK(m)          LeaveCriticalSection((m))
+#define GSSEAP_ONCE_LEAVE              do { return TRUE; } while (0)
 
 /* Thread-local is handled separately */
 
-/* Once is handled separately because INIT_ONCE is only on Vista and above */
-#define GSSEAP_ONCE_LEAVE
-#define GSSEAP_ONCE_CALLBACK(cb)        void CALLBACK cb(void)
+#define GSSEAP_THREAD_ONCE              INIT_ONCE
+#define GSSEAP_ONCE_CALLBACK(cb)        BOOL CALLBACK cb(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context)
+#define GSSEAP_ONCE(o, i)               InitOnceExecuteOnce((o), (i), NULL, NULL)
+#define GSSEAP_ONCE_INITIALIZER         INIT_ONCE_STATIC_INIT
 
 #else
 
index d3c99d3..3bfe785 100644 (file)
 #include <new>
 
 /* lazy initialisation */
-#ifdef WIN32
-static volatile OM_uint32 gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE;
-#else
 static GSSEAP_THREAD_ONCE gssEapAttrProvidersInitOnce = GSSEAP_ONCE_INITIALIZER;
 static OM_uint32 gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE;
-#endif
 
 GSSEAP_ONCE_CALLBACK(gssEapAttrProvidersInitInternal)
 {
@@ -78,12 +74,7 @@ cleanup:
     GSSEAP_ASSERT(major == GSS_S_COMPLETE);
 #endif
 
-#ifdef WIN32
-    InterlockedCompareExchangeRelease(&gssEapAttrProvidersInitStatus,
-                                      major, GSS_S_UNAVAILABLE);
-#else
     gssEapAttrProvidersInitStatus = major;
-#endif
 
     GSSEAP_ONCE_LEAVE;
 }
@@ -91,12 +82,7 @@ cleanup:
 static OM_uint32
 gssEapAttrProvidersInit(OM_uint32 *minor)
 {
-#ifdef WIN32
-    if (gssEapAttrProvidersInitStatus == GSS_S_UNAVAILABLE)
-        gssEapAttrProvidersInitInternal();
-#else
     GSSEAP_ONCE(&gssEapAttrProvidersInitOnce, gssEapAttrProvidersInitInternal);
-#endif
 
     if (GSS_ERROR(gssEapAttrProvidersInitStatus))
         *minor = GSSEAP_NO_ATTR_PROVIDERS;