diff options
author | Christian Beier <dontmind@freeshell.org> | 2011-03-03 16:11:38 +0100 |
---|---|---|
committer | Christian Beier <dontmind@freeshell.org> | 2011-03-03 16:11:38 +0100 |
commit | cf72a0f7c35ee791d5b4a81ef799d006e1b16bda (patch) | |
tree | 2d4029c928a844b9b8c335c3b6c0730053f1e694 | |
parent | f5b96e57bfaa05d21efc98f892a1b2b109b17253 (diff) | |
download | libvncserver-cf72a0f7c35ee791d5b4a81ef799d006e1b16bda.zip libvncserver-cf72a0f7c35ee791d5b4a81ef799d006e1b16bda.tar.gz |
Call WSAGetLastError() everywhere errno is read after a Winsock call.
Winsock does NOT update errno for us, we have fetch the last error
manually using WSAGetLastError().
-rw-r--r-- | libvncclient/sockets.c | 9 | ||||
-rw-r--r-- | libvncclient/tls.c | 6 | ||||
-rwxr-xr-x | libvncserver/httpd.c | 3 | ||||
-rw-r--r-- | libvncserver/rfbserver.c | 6 | ||||
-rwxr-xr-x | libvncserver/sockets.c | 3 |
5 files changed, 26 insertions, 1 deletions
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c index 334928e..4183192 100644 --- a/libvncclient/sockets.c +++ b/libvncclient/sockets.c @@ -262,6 +262,9 @@ WriteToRFBServer(rfbClient* client, char *buf, int n) j = write(client->sock, buf + i, (n - i)); if (j <= 0) { if (j < 0) { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif if (errno == EWOULDBLOCK || #ifdef LIBVNCSERVER_ENOENT_WORKAROUND errno == ENOENT || @@ -735,8 +738,12 @@ int WaitForMessage(rfbClient* client,unsigned int usecs) FD_SET(client->sock,&fds); num=select(client->sock+1, &fds, NULL, NULL, &timeout); - if(num<0) + if(num<0) { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif rfbClientLog("Waiting for message failed: %d (%s)\n",errno,strerror(errno)); + } return num; } diff --git a/libvncclient/tls.c b/libvncclient/tls.c index 206dbda..eb89413 100644 --- a/libvncclient/tls.c +++ b/libvncclient/tls.c @@ -62,6 +62,9 @@ PushTLS(gnutls_transport_ptr_t transport, const void *data, size_t len) ret = write(client->sock, data, len); if (ret < 0) { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif if (errno == EINTR) continue; return -1; } @@ -81,6 +84,9 @@ PullTLS(gnutls_transport_ptr_t transport, void *data, size_t len) ret = read(client->sock, data, len); if (ret < 0) { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif if (errno == EINTR) continue; return -1; } diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c index 320e6d2..ad2a51b 100755 --- a/libvncserver/httpd.c +++ b/libvncserver/httpd.c @@ -269,6 +269,9 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) if (got == 0) { rfbErr("httpd: premature connection close\n"); } else { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif if (errno == EAGAIN) { return; } diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index 554c118..73be34c 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -1350,6 +1350,9 @@ rfbBool rfbSendFileTransferChunk(rfbClientPtr cl) n = select(cl->sock + 1, NULL, &wfds, NULL, &tv); if (n<0) { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif rfbLog("rfbSendFileTransferChunk() select failed: %s\n", strerror(errno)); } /* We have space on the transmit queue */ @@ -1369,6 +1372,9 @@ rfbBool rfbSendFileTransferChunk(rfbClientPtr cl) return retval; case -1: /* TODO : send an error msg to the client... */ +#ifdef WIN32 + errno=WSAGetLastError(); +#endif rfbLog("rfbSendFileTransferChunk(): %s\n",strerror(errno)); retval = rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, 0, 0, NULL); close(cl->fileTransfer.fd); diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c index 48d024c..e1c5a7f 100755 --- a/libvncserver/sockets.c +++ b/libvncserver/sockets.c @@ -567,6 +567,9 @@ rfbWriteExact(rfbClientPtr cl, tv.tv_usec = 0; n = select(sock+1, NULL, &fds, NULL /* &fds */, &tv); if (n < 0) { +#ifdef WIN32 + errno=WSAGetLastError(); +#endif if(errno==EINTR) continue; rfbLogPerror("WriteExact: select"); |