From 7182ad9121cb77c55db3cbb9eb5cbd1a9d30f787 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Wed, 6 Oct 1999 19:25:41 +0000 Subject: [PATCH] removed the mutex method --- lib/isc/win32/include/isc/once.h | 8 +---- lib/isc/win32/once.c | 62 +------------------------------- 2 files changed, 2 insertions(+), 68 deletions(-) diff --git a/lib/isc/win32/include/isc/once.h b/lib/isc/win32/include/isc/once.h index f0ec235806..7f20c123fa 100644 --- a/lib/isc/win32/include/isc/once.h +++ b/lib/isc/win32/include/isc/once.h @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: once.h,v 1.1 1999/09/23 18:14:16 tale Exp $ */ +/* $Id: once.h,v 1.2 1999/10/06 19:25:41 tale Exp $ */ #ifndef ISC_ONCE_H #define ISC_ONCE_H 1 @@ -27,19 +27,13 @@ ISC_LANG_BEGINDECLS typedef struct { int status; -#ifndef ISC_ONCE_USE_MUTEX int counter; -#endif } isc_once_t; #define ISC_ONCE_INIT_NEEDED 0 #define ISC_ONCE_INIT_DONE 1 -#ifdef ISC_ONCE_USE_MUTEX -#define ISC_ONCE_INIT { ISC_ONCE_INIT_NEEDED } -#else #define ISC_ONCE_INIT { ISC_ONCE_INIT_NEEDED, 1 } -#endif isc_result_t isc_once_do(isc_once_t *controller, void(*function)(void)); diff --git a/lib/isc/win32/once.c b/lib/isc/win32/once.c index a5ff365d44..693d138e7f 100644 --- a/lib/isc/win32/once.c +++ b/lib/isc/win32/once.c @@ -15,73 +15,15 @@ * SOFTWARE. */ -/* $Id: once.c,v 1.1 1999/09/23 18:14:16 tale Exp $ */ +/* $Id: once.c,v 1.2 1999/10/06 19:25:41 tale Exp $ */ /* Principal Authors: DCL */ -#ifdef ISC_ONCE_USE_MUTEX -#include -#include -#endif - #include #include #include -#ifdef ISC_ONCE_USE_MUTEX - -/* - * XXXDCL someone (me? bob?) should decide which method to use, - * the mutex method or the InterlockedDecrement method. - */ - -isc_result_t -isc_once_do(isc_once_t *controller, void(*function)(void)) - -{ - char mutex_name[64]; - HANDLE mutex; - - REQUIRE(controller != NULL && function != NULL); - - if (controller->status == ISC_ONCE_INIT_NEEDED) { - - /* - * Create a name that is associated only with this process - * and controller. - */ - sprintf(mutex_name, "__isc_once_do_%ld:%p", - getpid(), controller); - - /* - * Create the mutex (or attach to the existing mutex) - * and lock it. - */ - mutex = CreateMutex(NULL, FALSE, mutex_name); - if (mutex == NULL) - return (ISC_R_UNEXPECTED); - if (WaitForSingleObject(mutex, INFINITE) == WAIT_FAILED) - return (ISC_R_UNEXPECTED); - - /* - * Recheck need for initialization now that - * the controller is locked. - */ - if (controller->status == ISC_ONCE_INIT_NEEDED) { - function(); - controller->status = ISC_ONCE_INIT_DONE; - } - - ReleaseMutex(mutex); - CloseHandle(mutex); - } - - return (ISC_R_SUCCESS); -} - -#else /* not ISC_ONCE_USE_MUTEX, use InterlockedDecrement instead */ - isc_result_t isc_once_do(isc_once_t *controller, void(*function)(void)) @@ -106,5 +48,3 @@ isc_once_do(isc_once_t *controller, void(*function)(void)) return (ISC_R_SUCCESS); } - -#endif /* ISC_ONCE_USE_MUTEX */