--- wine/dlls/winsock/socket.c 2005-11-24 17:00:02.000000000 +0100 +++ mywine/dlls/winsock/socket.c 2005-11-29 20:01:53.000000000 +0100 @@ -830,8 +830,10 @@ int WINAPI WSAStartup(WORD wVersionReque */ INT WINAPI WSACleanup(void) { - if (num_startup) + if (num_startup) { + num_startup -= 1; return 0; + } SetLastError(WSANOTINITIALISED); return SOCKET_ERROR; } --- wine/dlls/winsock/tests/sock.c 2005-11-14 20:31:23.000000000 +0100 +++ mywine/dlls/winsock/tests/sock.c 2005-11-29 14:33:08.000000000 +0100 @@ -709,8 +709,15 @@ static void Init (void) static void Exit (void) { + INT ret, err; TlsFree ( tls ); - ok ( WSACleanup() == 0, "WSACleanup failed\n" ); + ret = WSACleanup(); + err = WSAGetLastError(); + ok ( ret == 0, "WSACleanup failed ret = %d GetLastError is %d\n", ret, err); + ret = WSACleanup(); + err = WSAGetLastError(); + ok ( ret == SOCKET_ERROR && err == WSANOTINITIALISED, + "WSACleanup returned %d GetLastError is %d\n", ret, err); } static void StartServer (LPTHREAD_START_ROUTINE routine,