aboutsummaryrefslogtreecommitdiff
path: root/libxcb/src/xcb_in.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-07-12 18:20:04 +0000
committermarha <marha@users.sourceforge.net>2009-07-12 18:20:04 +0000
commitda8fe31a7ba4acf109097d5696ad0145b991cdfd (patch)
tree1c74d6f075702a73e557872f2a6f020ea4eb5432 /libxcb/src/xcb_in.c
parent6590f805a12779909cb8504c230fa367148fe38c (diff)
parent529dcfd0858d75cb3c87c73cb0f81dd20bbb9230 (diff)
downloadvcxsrv-da8fe31a7ba4acf109097d5696ad0145b991cdfd.tar.gz
vcxsrv-da8fe31a7ba4acf109097d5696ad0145b991cdfd.tar.bz2
vcxsrv-da8fe31a7ba4acf109097d5696ad0145b991cdfd.zip
Changes for VC compilation
Diffstat (limited to 'libxcb/src/xcb_in.c')
-rw-r--r--libxcb/src/xcb_in.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/libxcb/src/xcb_in.c b/libxcb/src/xcb_in.c
index 2997de4c4..40c32bbbd 100644
--- a/libxcb/src/xcb_in.c
+++ b/libxcb/src/xcb_in.c
@@ -28,9 +28,13 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
#include <stdio.h>
+#ifndef _MSC_VER
+#include <unistd.h>
#include <sys/select.h>
+#else
+#include <X11/Xwinsock.h>
+#endif
#include <errno.h>
#include "xcb.h"
@@ -233,6 +237,37 @@ static void free_reply_list(struct reply_list *head)
static int read_block(const int fd, void *buf, const size_t len)
{
+#ifdef _MSC_VER
+ int done = 0;
+ while(done < len)
+ {
+ int Err;
+ int ret = recv(fd, ((char *) buf) + done, len - done,0);
+ if(ret > 0)
+ done += ret;
+ else
+ Err=WSAGetLastError();
+ if(ret < 0 && Err == WSAEWOULDBLOCK)
+ {
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ do {
+ ret = select(fd + 1, &fds, 0, 0, 0);
+ if (ret==SOCKET_ERROR)
+ {
+ ret=-1;
+ errno = WSAGetLastError();
+ if (errno == WSAEINTR)
+ errno=EINTR;
+ }
+ } while (ret == -1 && errno == EINTR);
+ }
+ if(ret <= 0)
+ return ret;
+ }
+ return len;
+#else
int done = 0;
while(done < len)
{
@@ -252,6 +287,7 @@ static int read_block(const int fd, void *buf, const size_t len)
return ret;
}
return len;
+#endif
}
static int poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error)
@@ -495,11 +531,16 @@ int _xcb_in_expect_reply(xcb_connection_t *c, unsigned int request, enum workaro
int _xcb_in_read(xcb_connection_t *c)
{
- int n = read(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len);
+ int n = recv(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len,0); //MH
if(n > 0)
c->in.queue_len += n;
while(read_packet(c))
/* empty */;
+#ifdef _MSC_VER
+ errno=WSAGetLastError();
+ if (errno==WSAEWOULDBLOCK)
+ errno=EAGAIN;
+#endif
if((n > 0) || (n < 0 && errno == EAGAIN))
return 1;
_xcb_conn_shutdown(c);