diff options
author | Patrik Nyblom <[email protected]> | 2010-09-13 10:52:43 +0200 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2010-09-13 10:52:43 +0200 |
commit | 525fd7b044e78ae54527af6b0a21a2c7d49f78c9 (patch) | |
tree | 9e6a833aa20a436a3e2a2ffa99a4ff60f49db7fb /lib/erl_interface/src | |
parent | e5f1c776df55a965f2f61d9881f17c8bf32e8621 (diff) | |
parent | d9ad7fc091e850d9484e3f1fdf9ede22f9a18e04 (diff) | |
download | otp-525fd7b044e78ae54527af6b0a21a2c7d49f78c9.tar.gz otp-525fd7b044e78ae54527af6b0a21a2c7d49f78c9.tar.bz2 otp-525fd7b044e78ae54527af6b0a21a2c7d49f78c9.zip |
Merge branch 'pan/windows-testcases/OTP-8820' into dev
* pan/windows-testcases/OTP-8820:
Teach Winsock initialization to be thread safe
Make ei_threaded_send synchronized
Increase timeout value in ei_accept_SUITE
Teach ei_accept_SUITE to wait for node publish instead of using random sleeps
Teach port suite to not use unix-specific commands and not leave them running
Add line macros to gen_udp_SUITE:connect
Diffstat (limited to 'lib/erl_interface/src')
-rw-r--r-- | lib/erl_interface/src/connect/ei_connect.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/erl_interface/src/connect/ei_connect.c b/lib/erl_interface/src/connect/ei_connect.c index e191f3fbf0..99ccba0686 100644 --- a/lib/erl_interface/src/connect/ei_connect.c +++ b/lib/erl_interface/src/connect/ei_connect.c @@ -366,16 +366,16 @@ static int initWinSock(void) WORD wVersionRequested; WSADATA wsaData; int i; - /* FIXME problem for threaded ? */ - static int initialized = 0; + + static LONG volatile initialized = 0; wVersionRequested = MAKEWORD(1, 1); - if (!initialized) { - initialized = 1; + if (InterlockedCompareExchange((LPLONG) &initialized,1L,0L) == 0L) { /* FIXME not terminate, just a message?! */ if ((i = WSAStartup(wVersionRequested, &wsaData))) { EI_TRACE_ERR1("ei_connect_init", "ERROR: can't initialize windows sockets: %d",i); + initialized = 2L; return 0; } @@ -383,10 +383,14 @@ static int initWinSock(void) EI_TRACE_ERR0("initWinSock","ERROR: this version of windows " "sockets not supported"); WSACleanup(); + initialized = 2L; return 0; } + initialized = 3L; + } else while (initialized < 2) { + SwitchToThread(); } - return 1; + return (int) (initialized - 2); } #endif |