summaryrefslogtreecommitdiffstats
path: root/buffer-poll.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-11-27 19:23:34 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-11-27 19:23:34 +0000
commit76c8a590db14131928f79123adcab934a3825501 (patch)
tree359cbfac219a68d5137bd3ec02b31ecb33cbd288 /buffer-poll.c
parent97eca99d0bae6c4fdfc38a6f42d42f05c8faac4b (diff)
Big internal reorganisation to move tty control into parent.
Diffstat (limited to 'buffer-poll.c')
-rw-r--r--buffer-poll.c23
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;
+ }
+}