From a9b6bfdddd570753e52dca73169f70864502c38c Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Fri, 14 Aug 2009 21:04:04 +0000 Subject: Sync OpenBSD patchset 243: 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. --- tmux.h | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'tmux.h') diff --git a/tmux.h b/tmux.h index f0676749..cbb6434a 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.409 2009-08-11 14:42:59 nicm Exp $ */ +/* $Id: tmux.h,v 1.410 2009-08-14 21:04:04 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -21,10 +21,11 @@ #include "config.h" -#define PROTOCOL_VERSION -15 +#define PROTOCOL_VERSION 1 #include #include +#include #include #include @@ -34,6 +35,7 @@ #include #include "array.h" +#include "imsg.h" #include "compat.h" @@ -302,23 +304,16 @@ enum msgtype { MSG_SHUTDOWN, MSG_SUSPEND, MSG_UNLOCK, + MSG_VERSION, MSG_WAKEUP, MSG_ENVIRON }; /* - * Message header and data. + * Message data. * * Don't forget to bump PROTOCOL_VERSION if any of these change! - * - * Changing sizeof (struct hdr) or sizeof (struct msg_identify_data) will make - * the tmux client hang even if the protocol version is bumped. */ -struct hdr { - enum msgtype type; - size_t size; -}; - struct msg_print_data { char msg[PRINT_LENGTH]; }; @@ -333,7 +328,6 @@ struct msg_command_data { struct msg_identify_data { char tty[TTY_NAME_MAX]; - int version; char cwd[MAXPATHLEN]; @@ -907,9 +901,7 @@ struct tty_ctx { /* Client connection. */ struct client { - int fd; - struct buffer *in; - struct buffer *out; + struct imsgbuf ibuf; struct environ environ; @@ -957,9 +949,7 @@ ARRAY_DECL(clients, struct client *); /* Client context. */ struct client_ctx { - int srv_fd; - struct buffer *srv_in; - struct buffer *srv_out; + struct imsgbuf ibuf; enum { CCTX_DETACH, -- cgit