Move _xcb_readn to xcb_in.c and make it static. Minor change to _xcb_read_block to not depend on _xcb_readn.

This commit is contained in:
Jamey Sharp 2006-02-24 00:48:18 -08:00
parent cdf362f33a
commit 3f8d0bd532
3 changed files with 13 additions and 11 deletions

View File

@ -28,6 +28,7 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
@ -68,6 +69,14 @@ static void wake_up_next_reader(XCBConnection *c)
assert(pthreadret == 0);
}
static int readn(const int fd, void *buf, const int buflen, int *count)
{
int n = read(fd, ((char *) buf) + *count, buflen - *count);
if(n > 0)
*count += n;
return n;
}
static int read_packet(XCBConnection *c)
{
XCBGenericRep genrep;
@ -327,7 +336,7 @@ int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workaround
int _xcb_in_read(XCBConnection *c)
{
int n = _xcb_readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len);
int n = readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len);
while(read_packet(c))
/* empty */;
return (n > 0) || (n < 0 && errno == EAGAIN);

View File

@ -217,20 +217,14 @@ int _xcb_set_fd_flags(const int fd)
return 1;
}
int _xcb_readn(const int fd, void *buf, const int buflen, int *count)
{
int n = read(fd, ((char *) buf) + *count, buflen - *count);
if(n > 0)
*count += n;
return n;
}
int _xcb_read_block(const int fd, void *buf, const size_t len)
{
int done = 0;
while(done < len)
{
int ret = _xcb_readn(fd, buf, len, &done);
int ret = read(fd, ((char *) buf) + done, len - done);
if(ret > 0)
done += ret;
if(ret < 0 && errno == EAGAIN)
{
fd_set fds;

View File

@ -72,7 +72,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key);
#define XCB_PAD(i) ((4 - (i & 3)) & 3)
int _xcb_set_fd_flags(const int fd);
int _xcb_readn(const int fd, void *buf, const int buflen, int *count);
int _xcb_read_block(const int fd, void *buf, const size_t len);