Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-05-03 13:35:08 +0400
committerCorinna Vinschen <corinna@vinschen.de>2001-05-03 13:35:08 +0400
commita6a0193b2fe6f83c7c0970afd5afecf28fba5595 (patch)
tree909bd43eb5c04aab1d3246d390ea4372bc01800b /winsup/cygwin/net.cc
parentb09e3cf8fdb7927bc14af200b418841ebbae070d (diff)
* autoload.cc: Use new definition of LoadDLLinitfunc throughout.
Redefine wrapper for wsock32.dll and ws2_32.dll. (std_dll_init): New function. * autoload.h: Rename LoadDLLinitfunc to LoadDLLinitfuncdef. Add new defines LoadDLLinitfunc and LoadDLLstdfunc. * net.cc (wsock_init): Add guard variable handling. Take care to call WSAStartup only once. Load WSAStartup without using autoload wrapper to eliminate recursion. Eliminate FIONBIO and srandom stuff.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc49
1 files changed, 33 insertions, 16 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 30b090164..72c7010d8 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1928,21 +1928,38 @@ endhostent (void)
extern "C" void
wsock_init ()
{
- int res = WSAStartup ((2<<8) | 2, &wsadata);
-
- debug_printf ("res %d", res);
- debug_printf ("wVersion %d", wsadata.wVersion);
- debug_printf ("wHighVersion %d", wsadata.wHighVersion);
- debug_printf ("szDescription %s", wsadata.szDescription);
- debug_printf ("szSystemStatus %s", wsadata.szSystemStatus);
- debug_printf ("iMaxSockets %d", wsadata.iMaxSockets);
- debug_printf ("iMaxUdpDg %d", wsadata.iMaxUdpDg);
- debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo);
-
- if (FIONBIO != REAL_FIONBIO)
- debug_printf ("**************** FIONBIO != REAL_FIONBIO");
-
- /* FIXME: will resulting random sequence be unpredictable enough? */
- srandom (GetTickCount ());
+ static LONG NO_COPY here = -1L;
+ static int NO_COPY was_in_progress = 0;
+
+ while (InterlockedIncrement (&here))
+ {
+ InterlockedDecrement (&here);
+ Sleep (0);
+ }
+ if (!was_in_progress && (wsock32_handle || ws2_32_handle))
+ {
+ /* Don't use autoload to load WSAStartup to eliminate recursion. */
+ int (*wsastartup) (int, WSADATA *);
+
+ wsastartup = (int (*)(int, WSADATA *))
+ GetProcAddress ((HMODULE) (wsock32_handle ?: ws2_32_handle),
+ "WSAStartup");
+ if (wsastartup)
+ {
+ int res = wsastartup ((2<<8) | 2, &wsadata);
+
+ debug_printf ("res %d", res);
+ debug_printf ("wVersion %d", wsadata.wVersion);
+ debug_printf ("wHighVersion %d", wsadata.wHighVersion);
+ debug_printf ("szDescription %s", wsadata.szDescription);
+ debug_printf ("szSystemStatus %s", wsadata.szSystemStatus);
+ debug_printf ("iMaxSockets %d", wsadata.iMaxSockets);
+ debug_printf ("iMaxUdpDg %d", wsadata.iMaxUdpDg);
+ debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo);
+
+ was_in_progress = 1;
+ }
+ }
+ InterlockedDecrement (&here);
}