From 81c54ce285c3c08ee959659b5b38314289185a36 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Sat, 9 Jul 2011 02:20:46 +0000 Subject: [PATCH] Changed debug messages in socket/closesocket. --- src/winsock.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/winsock.c b/src/winsock.c index a1bcb47..d75c122 100644 --- a/src/winsock.c +++ b/src/winsock.c @@ -152,7 +152,7 @@ SOCKET WSAAPI socket(int af, int type, int protocol) { nsock->next = sockets; sockets = nsock; - debug("Socket created (fd=%d)", nsock->fd); + debug("IPX socket created (fd = %d)", nsock->fd); RETURN(nsock->fd); }else{ @@ -161,17 +161,22 @@ SOCKET WSAAPI socket(int af, int type, int protocol) { } int WSAAPI closesocket(SOCKET fd) { - debug("closesocket(%d)", fd); - - if(r_closesocket(fd) == SOCKET_ERROR) { - debug("...failed"); - RETURN(SOCKET_ERROR); - } + int ret = r_closesocket(fd); ipx_socket *ptr = get_socket(fd); ipx_socket *pptr = sockets; - debug("...success"); + if(!ptr) { + /* Not an IPX socket */ + return ret; + } + + if(ret == SOCKET_ERROR) { + debug("closesocket(%d) failed: %s", fd, w32_error(WSAGetLastError())); + RETURN(SOCKET_ERROR); + } + + debug("IPX socket closed (fd = %d)", fd); if(ptr == sockets) { sockets = ptr->next;