Commit cf72a0f7 authored by Christian Beier's avatar Christian Beier

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().
parent f5b96e57
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment