diff options
Diffstat (limited to 'libxcb/src/xcb_in.c')
-rw-r--r-- | libxcb/src/xcb_in.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/libxcb/src/xcb_in.c b/libxcb/src/xcb_in.c index 6072cea9a..aaec5c8b4 100644 --- a/libxcb/src/xcb_in.c +++ b/libxcb/src/xcb_in.c @@ -30,6 +30,9 @@ #include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#ifdef _MSC_VER
+#include <X11/Xwinsock.h>
+#endif
#include <errno.h>
#include "xcb.h"
@@ -252,6 +255,37 @@ static void free_reply_list(struct reply_list *head) static int read_block(const int fd, void *buf, const ssize_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)
{
@@ -281,6 +315,7 @@ static int read_block(const int fd, void *buf, const ssize_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)
@@ -663,11 +698,16 @@ void _xcb_in_replies_done(xcb_connection_t *c) 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);
|