From: Luke Howard Date: Mon, 12 Dec 2011 09:30:38 +0000 (+1100) Subject: Revert "InitOnceExecuteOnce not present on XP" X-Git-Tag: tr-beta1~46^2~16 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot.git;a=commitdiff_plain;h=c452df276165897c7ed6b18c4bb4d7bcd34a4791 Revert "InitOnceExecuteOnce not present on XP" 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. --- diff --git a/moonshot/mech_eap/util.h b/moonshot/mech_eap/util.h index 23d6ff8..4f54d41 100644 --- a/moonshot/mech_eap/util.h +++ b/moonshot/mech_eap/util.h @@ -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 diff --git a/moonshot/mech_eap/util_attr.cpp b/moonshot/mech_eap/util_attr.cpp index d3c99d3..3bfe785 100644 --- a/moonshot/mech_eap/util_attr.cpp +++ b/moonshot/mech_eap/util_attr.cpp @@ -43,12 +43,8 @@ #include /* 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;