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().
pull/1/head
Christian Beier 13 years ago
parent f5b96e57bf
commit cf72a0f7c3

@ -262,6 +262,9 @@ WriteToRFBServer(rfbClient* client, char *buf, int n)
j = write(client->sock, buf + i, (n - i)); j = write(client->sock, buf + i, (n - i));
if (j <= 0) { if (j <= 0) {
if (j < 0) { if (j < 0) {
#ifdef WIN32
errno=WSAGetLastError();
#endif
if (errno == EWOULDBLOCK || if (errno == EWOULDBLOCK ||
#ifdef LIBVNCSERVER_ENOENT_WORKAROUND #ifdef LIBVNCSERVER_ENOENT_WORKAROUND
errno == ENOENT || errno == ENOENT ||
@ -735,8 +738,12 @@ int WaitForMessage(rfbClient* client,unsigned int usecs)
FD_SET(client->sock,&fds); FD_SET(client->sock,&fds);
num=select(client->sock+1, &fds, NULL, NULL, &timeout); 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)); rfbClientLog("Waiting for message failed: %d (%s)\n",errno,strerror(errno));
}
return num; return num;
} }

@ -62,6 +62,9 @@ PushTLS(gnutls_transport_ptr_t transport, const void *data, size_t len)
ret = write(client->sock, data, len); ret = write(client->sock, data, len);
if (ret < 0) if (ret < 0)
{ {
#ifdef WIN32
errno=WSAGetLastError();
#endif
if (errno == EINTR) continue; if (errno == EINTR) continue;
return -1; return -1;
} }
@ -81,6 +84,9 @@ PullTLS(gnutls_transport_ptr_t transport, void *data, size_t len)
ret = read(client->sock, data, len); ret = read(client->sock, data, len);
if (ret < 0) if (ret < 0)
{ {
#ifdef WIN32
errno=WSAGetLastError();
#endif
if (errno == EINTR) continue; if (errno == EINTR) continue;
return -1; return -1;
} }

@ -269,6 +269,9 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
if (got == 0) { if (got == 0) {
rfbErr("httpd: premature connection close\n"); rfbErr("httpd: premature connection close\n");
} else { } else {
#ifdef WIN32
errno=WSAGetLastError();
#endif
if (errno == EAGAIN) { if (errno == EAGAIN) {
return; return;
} }

@ -1350,6 +1350,9 @@ rfbBool rfbSendFileTransferChunk(rfbClientPtr cl)
n = select(cl->sock + 1, NULL, &wfds, NULL, &tv); n = select(cl->sock + 1, NULL, &wfds, NULL, &tv);
if (n<0) { if (n<0) {
#ifdef WIN32
errno=WSAGetLastError();
#endif
rfbLog("rfbSendFileTransferChunk() select failed: %s\n", strerror(errno)); rfbLog("rfbSendFileTransferChunk() select failed: %s\n", strerror(errno));
} }
/* We have space on the transmit queue */ /* We have space on the transmit queue */
@ -1369,6 +1372,9 @@ rfbBool rfbSendFileTransferChunk(rfbClientPtr cl)
return retval; return retval;
case -1: case -1:
/* TODO : send an error msg to the client... */ /* TODO : send an error msg to the client... */
#ifdef WIN32
errno=WSAGetLastError();
#endif
rfbLog("rfbSendFileTransferChunk(): %s\n",strerror(errno)); rfbLog("rfbSendFileTransferChunk(): %s\n",strerror(errno));
retval = rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, 0, 0, NULL); retval = rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, 0, 0, NULL);
close(cl->fileTransfer.fd); close(cl->fileTransfer.fd);

@ -567,6 +567,9 @@ rfbWriteExact(rfbClientPtr cl,
tv.tv_usec = 0; tv.tv_usec = 0;
n = select(sock+1, NULL, &fds, NULL /* &fds */, &tv); n = select(sock+1, NULL, &fds, NULL /* &fds */, &tv);
if (n < 0) { if (n < 0) {
#ifdef WIN32
errno=WSAGetLastError();
#endif
if(errno==EINTR) if(errno==EINTR)
continue; continue;
rfbLogPerror("WriteExact: select"); rfbLogPerror("WriteExact: select");

Loading…
Cancel
Save