diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-10-23 17:49:47 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-10-23 17:49:47 +0000 |
commit | cc9ef11985305b29988ba34022d662f85771c765 (patch) | |
tree | b9fb727b5b878905417abd28c8e13117f8000037 /buffer-poll.c | |
parent | 9ad23472581afc719c65f1f029a11906db5fc94f (diff) | |
download | rtmux-cc9ef11985305b29988ba34022d662f85771c765.tar.gz rtmux-cc9ef11985305b29988ba34022d662f85771c765.tar.bz2 rtmux-cc9ef11985305b29988ba34022d662f85771c765.zip |
Sync OpenBSD patchset 438:
Split the server code handling clients, jobs and windows off into separate
files from server.c (merging server-msg.c into the client file) and rather than
iterating over each set after poll(), allow a callback to be specified when the
fd is added and just walk once over the returned pollfds calling each callback
where needed.
More to come, getting this in so it is tested.
Diffstat (limited to 'buffer-poll.c')
-rw-r--r-- | buffer-poll.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/buffer-poll.c b/buffer-poll.c index 87153d16..63b45f47 100644 --- a/buffer-poll.c +++ b/buffer-poll.c @@ -1,4 +1,4 @@ -/* $Id: buffer-poll.c,v 1.17 2009-10-11 23:55:26 tcunha Exp $ */ +/* $Id: buffer-poll.c,v 1.18 2009-10-23 17:49:47 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,15 +25,15 @@ /* Fill buffers from socket based on poll results. */ int -buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out) +buffer_poll(int fd, int events, struct buffer *in, struct buffer *out) { ssize_t n; - if (pfd->revents & (POLLERR|POLLNVAL)) + if (events & (POLLERR|POLLNVAL)) return (-1); - if (in != NULL && pfd->revents & POLLIN) { + if (in != NULL && events & POLLIN) { buffer_ensure(in, BUFSIZ); - n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in)); + n = read(fd, BUFFER_IN(in), BUFFER_FREE(in)); if (n == 0) return (-1); if (n == -1) { @@ -41,10 +41,10 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out) return (-1); } else buffer_add(in, n); - } else if (pfd->revents & POLLHUP) + } else if (events & POLLHUP) return (-1); - if (out != NULL && BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) { - n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out)); + if (out != NULL && BUFFER_USED(out) > 0 && events & POLLOUT) { + n = write(fd, BUFFER_OUT(out), BUFFER_USED(out)); if (n == -1) { if (errno != EINTR && errno != EAGAIN) return (-1); |