diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-27 19:23:34 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-27 19:23:34 +0000 |
commit | 76c8a590db14131928f79123adcab934a3825501 (patch) | |
tree | 359cbfac219a68d5137bd3ec02b31ecb33cbd288 /buffer-poll.c | |
parent | 97eca99d0bae6c4fdfc38a6f42d42f05c8faac4b (diff) | |
download | rtmux-76c8a590db14131928f79123adcab934a3825501.tar.gz rtmux-76c8a590db14131928f79123adcab934a3825501.tar.bz2 rtmux-76c8a590db14131928f79123adcab934a3825501.zip |
Big internal reorganisation to move tty control into parent.
Diffstat (limited to 'buffer-poll.c')
-rw-r--r-- | buffer-poll.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/buffer-poll.c b/buffer-poll.c index 06cbf81f..50785e54 100644 --- a/buffer-poll.c +++ b/buffer-poll.c @@ -1,4 +1,4 @@ -/* $Id: buffer-poll.c,v 1.2 2007-11-07 19:41:17 nicm Exp $ */ +/* $Id: buffer-poll.c,v 1.3 2007-11-27 19:23:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -53,3 +53,24 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out) } return (0); } + +/* Flush buffer output to socket. */ +void +buffer_flush(int fd, struct buffer *in, struct buffer *out) +{ + struct pollfd pfd; + + while (BUFFER_USED(out) > 0) { + pfd.fd = fd; + pfd.events = POLLIN|POLLOUT; + + if (poll(&pfd, 1, INFTIM) == -1) { + if (errno == EAGAIN || errno == EINTR) + continue; + fatal("poll failed"); + } + + if (buffer_poll(&pfd, in, out) != 0) + break; + } +} |