From 5087c62f18fe0695ce7d09e7b3446fcfc6309f51 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 17 Jan 2011 22:49:23 +0100 Subject: [PATCH] Fix detection of socket errors --- src/node_net.cc | 4 ++-- src/platform_win32_winsock.cc | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/node_net.cc b/src/node_net.cc index 2bc0a00a9c..2dc6f9c8d5 100644 --- a/src/node_net.cc +++ b/src/node_net.cc @@ -448,7 +448,7 @@ static Handle Connect(const Arguments& args) { #else // __MINGW32__ int r = connect(_get_osfhandle(fd), addr, addrlen); - if (r == INVALID_SOCKET) { + if (r == SOCKET_ERROR) { int wsaErrno = WSAGetLastError(); if (wsaErrno != WSAEWOULDBLOCK && wsaErrno != WSAEINPROGRESS) { return ThrowException(ErrnoException(wsaErrno, "connect")); @@ -642,7 +642,7 @@ static Handle Accept(const Arguments& args) { #else // __MINGW32__ int peer_handle = accept(_get_osfhandle(fd), (struct sockaddr*) &address_storage, &len); - if (peer_handle == INVALID_SOCKET) { + if (peer_handle == SOCKET_ERROR) { int wsaErrno = WSAGetLastError(); if (wsaErrno == WSAEWOULDBLOCK) return scope.Close(Null()); return ThrowException(ErrnoException(wsaErrno, "accept")); diff --git a/src/platform_win32_winsock.cc b/src/platform_win32_winsock.cc index 701ebfd20c..cecb5a444a 100644 --- a/src/platform_win32_winsock.cc +++ b/src/platform_win32_winsock.cc @@ -229,10 +229,10 @@ int wsa_socketpair(int af, int type, int proto, SOCKET sock[2]) { if ((sock[1] = accept(listen_sock, 0, 0)) == INVALID_SOCKET) goto error; - if (getpeername(sock[0], (SOCKADDR*)&addr1, &addr1_len) == INVALID_SOCKET) + if (getpeername(sock[0], (SOCKADDR*)&addr1, &addr1_len) == SOCKET_ERROR) goto error; - if (getsockname(sock[1], (SOCKADDR*)&addr2, &addr2_len) == INVALID_SOCKET) + if (getsockname(sock[1], (SOCKADDR*)&addr2, &addr2_len) == SOCKET_ERROR) goto error; if (addr1_len != addr2_len @@ -308,10 +308,10 @@ int wsa_sync_async_socketpair(int af, int type, int proto, SOCKET *syncSocket, S if ((sock2 = accept(listen_sock, 0, 0)) == INVALID_SOCKET) goto error; - if (getpeername(sock1, (SOCKADDR*)&addr1, &addr1_len) == INVALID_SOCKET) + if (getpeername(sock1, (SOCKADDR*)&addr1, &addr1_len) == SOCKET_ERROR) goto error; - if (getsockname(sock2, (SOCKADDR*)&addr2, &addr2_len) == INVALID_SOCKET) + if (getsockname(sock2, (SOCKADDR*)&addr2, &addr2_len) == SOCKET_ERROR) goto error; if (addr1_len != addr2_len @@ -425,7 +425,7 @@ inline static void wsa_get_extension_function(SOCKET socket, GUID guid, void **t inline static void wsa_init_extension_functions() { SOCKET dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); - if (dummy == SOCKET_ERROR) { + if (dummy == INVALID_SOCKET) { memset((void*)&wsexf, 0, sizeof(wsexf)); wsa_perror("socket"); return;