[Xcb] [PATCH] Use recv(2) instead of read(2).
Jamey Sharp
jamey at minilop.net
Thu Apr 22 19:01:04 PDT 2010
This change eases porting XCB to Windows.
The X protocol is only usable over sockets anyway, and for sockets,
read(fd, buf, len) is equivalent to recv(fd, buf, len, 0).
Signed-off-by: Jamey Sharp <jamey at minilop.net>
CC: Alan Coopersmith <alan.coopersmith at oracle.com>
CC: Jeremy Huddleston <jeremyhu at freedesktop.org>
---
This is the only part of Jeetu's patches that might matter for
non-Windows systems. I'd love to get review and testing on the various
platforms XCB supports. I've tested on Linux and CC'd some non-Linux
developers.
Do we have anybody active in the XCB community using one of the BSDs?
Jeetu's patch used MSG_WAITALL, but as far as I can tell, that's
supposed to turn off the non-blocking behavior, and we don't want that.
Anyway it didn't seem to make any difference for me. If anybody can
explain this flag better than the documentation does, I'd appreciate it.
src/xcb_in.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 6dd358c..67fd31f 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -35,6 +35,8 @@
#include "xcb.h"
#include "xcbext.h"
#include "xcbint.h"
+
+#include <sys/socket.h>
#if USE_POLL
#include <poll.h>
#else
@@ -255,7 +257,7 @@ static int read_block(const int fd, void *buf, const ssize_t len)
int done = 0;
while(done < len)
{
- int ret = read(fd, ((char *) buf) + done, len - done);
+ int ret = recv(fd, ((char *) buf) + done, len - done, 0);
if(ret > 0)
done += ret;
if(ret < 0 && errno == EAGAIN)
@@ -663,7 +665,7 @@ 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);
if(n > 0)
c->in.queue_len += n;
while(read_packet(c))
--
1.7.0
More information about the Xcb
mailing list