summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server-fn.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-08-11 17:18:36 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-08-11 17:18:36 +0000
commit935b5746db4dbaa64a95e16e092ba253ec4313c0 (patch)
tree16726ba9f3830ab0a0c9fe91057a200f38455835 /usr.bin/tmux/server-fn.c
parent98b05a003a84406b2feccb22b9cd67bae0c215c7 (diff)
Switch tmux to use imsg. This is the last major change to make the
client-server protocol more resilient and make the protocol versioning work properly. In future, the only things requiring a protocol version bump will be changes in the message structs, and (when both client and server have this change) mixing different versions should nicely report an error message. As a side effect this also makes the code tidier, fixes a problem with the way errors reported during server startup were handled, and supports fd passing (which will be used in future). Looked over by eric@, thanks. Please note that mixing a client with this change with an older server or vice versa may cause tmux to crash or hang - tmux should be completely exited before upgrading.
Diffstat (limited to 'usr.bin/tmux/server-fn.c')
-rw-r--r--usr.bin/tmux/server-fn.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 85be4a4ddfe..88ba0da7e33 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.13 2009/08/08 21:52:43 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.14 2009/08/11 17:18:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -55,18 +55,12 @@ void
server_write_client(
struct client *c, enum msgtype type, const void *buf, size_t len)
{
- struct hdr hdr;
+ struct imsgbuf *ibuf = &c->ibuf;
if (c->flags & CLIENT_BAD)
return;
- log_debug("writing %d to client %d", type, c->fd);
-
- hdr.type = type;
- hdr.size = len;
-
- buffer_write(c->out, &hdr, sizeof hdr);
- if (buf != NULL && len > 0)
- buffer_write(c->out, buf, len);
+ log_debug("writing %d to client %d", type, c->ibuf.fd);
+ imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1, (void *) buf, len);
}
void