diff options
author | Colin Harrison <colin.harrison-at-virgin.net> | 2008-04-23 10:39:30 +0100 |
---|---|---|
committer | Alan Hourihane <alanh@tungstengraphics.com> | 2008-04-23 10:39:30 +0100 |
commit | 3a2a5375b8aab85697b4f2644ab99c3ccf79e658 (patch) | |
tree | 34855f0ab35f5669877c2d39f4b7f9e95f27a370 | |
parent | ac13a1a34b61247a21da130f0ba9922f35d3dc3b (diff) |
Only call WSAGetLastError() if there has been an
error condition.
-rw-r--r-- | Xtranssock.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Xtranssock.c b/Xtranssock.c index 5ac6a62..8f64429 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -2221,7 +2221,7 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) #ifdef WIN32 { int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); - errno = WSAGetLastError(); + if (ret == SOCKET_ERROR) errno = WSAGetLastError(); return ret; } #else @@ -2248,7 +2248,7 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) { int ret = recv ((SOCKET)ciptr->fd, buf, size, 0); #ifdef WIN32 - errno = WSAGetLastError(); + if (ret == SOCKET_ERROR) errno = WSAGetLastError(); #endif return ret; } @@ -2268,7 +2268,7 @@ TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size) { int ret = send ((SOCKET)ciptr->fd, buf, size, 0); #ifdef WIN32 - errno = WSAGetLastError(); + if (ret == SOCKET_ERROR) errno = WSAGetLastError(); #endif return ret; } @@ -2307,7 +2307,7 @@ TRANS(SocketDisconnect) (XtransConnInfo ciptr) #ifdef WIN32 { int ret = shutdown (ciptr->fd, 2); - errno = WSAGetLastError(); + if (ret == SOCKET_ERROR) errno = WSAGetLastError(); return ret; } #else @@ -2326,7 +2326,7 @@ TRANS(SocketINETClose) (XtransConnInfo ciptr) #ifdef WIN32 { int ret = close (ciptr->fd); - errno = WSAGetLastError(); + if (ret == SOCKET_ERROR) errno = WSAGetLastError(); return ret; } #else |