diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index dcebfeffe..765c4c3fb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +Sun Jul 2 21:50:48 2000 Christopher Faylor + + * dcrt0.cc (user32_init): Add primitive guard against concurrent + attempts to call this function. Also add temporary debugging code to + display a message if the function is called multiple times. + (api32_init): Ditto. + Sun Jul 2 10:39:00 2000 Corinna Vinschen * winsup.h: Define MAX_SID_LEN and new MAX_HOST_NAME. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index ceec8db57..80a3d26c0 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1108,25 +1108,47 @@ gotit: LoadDLLinitfunc (user32) { HANDLE h; + static NO_COPY LONG here = -1L; - if ((h = LoadLibrary ("user32.dll")) != NULL) + while (InterlockedIncrement (&here)) + { + InterlockedDecrement (&here); +small_printf ("Multiple tries to read user32.dll\n"); + Sleep (0); + } + + if (user32_handle) + /* nothing to do */; + else if ((h = LoadLibrary ("user32.dll")) != NULL) user32_handle = h; else if (!user32_handle) api_fatal ("could not load user32.dll, %E"); + InterlockedDecrement (&here); return 0; /* Already done by another thread? */ } LoadDLLinitfunc (advapi32) { HANDLE h; + static NO_COPY LONG here = -1L; - if ((h = LoadLibrary ("advapi32.dll")) != NULL) + while (InterlockedIncrement (&here)) + { + InterlockedDecrement (&here); +small_printf ("Multiple tries to read advapi32.dll\n"); + Sleep (0); + } + + if (advapi32_handle) + /* nothing to do */; + else if ((h = LoadLibrary ("advapi32.dll")) != NULL) advapi32_handle = h; else if (!advapi32_handle) api_fatal ("could not load advapi32.dll, %E"); - return 0; /* Already done by another thread? */ + InterlockedDecrement (&here); + return 0; } static void dummy_autoload (void) __attribute__ ((unused));