aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.c27
-rw-r--r--tmux.h3
2 files changed, 28 insertions, 2 deletions
diff --git a/client.c b/client.c
index 1dec0613..c997f7b9 100644
--- a/client.c
+++ b/client.c
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.7 2007-09-27 20:53:13 nicm Exp $ */
+/* $Id: client.c,v 1.8 2007-09-28 19:04:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -125,6 +125,31 @@ retry:
}
int
+client_flush(struct client_ctx *cctx)
+{
+ struct pollfd pfd;
+
+ /* XXX error response! */
+ while (BUFFER_USED(cctx->srv_out) > 0) {
+ pfd.fd = cctx->srv_fd;
+ pfd.events = POLLIN|POLLOUT;
+
+ if (poll(&pfd, 1, INFTIM) == -1) {
+ if (errno == EAGAIN || errno == EINTR)
+ continue;
+ fatal("poll failed");
+ }
+
+ if (buffer_poll(&pfd, cctx->srv_in, cctx->srv_out) != 0) {
+ log_warnx("lost server");
+ return (1);
+ }
+ }
+
+ return (0);
+}
+
+int
client_main(struct client_ctx *cctx)
{
struct pollfd pfds[2];
diff --git a/tmux.h b/tmux.h
index 4eccbc32..901c2cdd 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.18 2007-09-27 10:09:37 nicm Exp $ */
+/* $Id: tmux.h,v 1.19 2007-09-28 19:04:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -455,6 +455,7 @@ int op_list_windows(char *, int, char **);
/* client.c */
int client_init(char *, struct client_ctx *, int);
+int client_flush(struct client_ctx *);
int client_main(struct client_ctx *);
void client_write_server(struct client_ctx *, enum hdrtype, void *, size_t);
void client_fill_sessid(struct sessid *, char [MAXNAMELEN]);