mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 14:27:09 +00:00
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.
This commit is contained in:
24
tmux.h
24
tmux.h
@ -19,12 +19,13 @@
|
||||
#ifndef TMUX_H
|
||||
#define TMUX_H
|
||||
|
||||
#define PROTOCOL_VERSION -15
|
||||
#define PROTOCOL_VERSION 1
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/tree.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <bitstring.h>
|
||||
#include <getopt.h>
|
||||
@ -37,6 +38,7 @@
|
||||
#include <termios.h>
|
||||
|
||||
#include "array.h"
|
||||
#include "imsg.h"
|
||||
|
||||
extern char *__progname;
|
||||
extern char **environ;
|
||||
@ -303,23 +305,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];
|
||||
};
|
||||
@ -334,7 +329,6 @@ struct msg_command_data {
|
||||
|
||||
struct msg_identify_data {
|
||||
char tty[TTY_NAME_MAX];
|
||||
int version;
|
||||
|
||||
char cwd[MAXPATHLEN];
|
||||
|
||||
@ -908,9 +902,7 @@ struct tty_ctx {
|
||||
|
||||
/* Client connection. */
|
||||
struct client {
|
||||
int fd;
|
||||
struct buffer *in;
|
||||
struct buffer *out;
|
||||
struct imsgbuf ibuf;
|
||||
|
||||
struct environ environ;
|
||||
|
||||
@ -958,9 +950,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,
|
||||
|
Reference in New Issue
Block a user