diff options
author | Christopher Faylor <me@cgf.cx> | 2000-07-03 05:55:17 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-07-03 05:55:17 +0400 |
commit | b6cdb2c3495c80d31d316b7f496f881096079027 (patch) | |
tree | 2d3f579dca648973fa52565aafe110552246095b | |
parent | c8c609ff0adb645f43080999293165b93cb7ba94 (diff) |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 28 |
2 files changed, 32 insertions, 3 deletions
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 <cgf@cygnus.com> + + * 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 <corinna@vinschen.de> * 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)); |