summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-20 19:31:33 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-20 19:31:33 +0100
commite9d6a298df6108e2044b1f0da5a2712f0c51c7d9 (patch)
tree57f9e821c4878c979bd1d353875d5516875da220
parent17b56c9f8327e6869580e3cfd82efcf8966d797a (diff)
patch 7.4.1623v7.4.1623
Problem: All Channels share the message ID, it keeps getting bigger. Solution: Use a message ID per channel.
-rw-r--r--src/channel.c13
-rw-r--r--src/proto/channel.pro3
-rw-r--r--src/structs.h1
-rw-r--r--src/version.c2
4 files changed, 5 insertions, 14 deletions
diff --git a/src/channel.c b/src/channel.c
index 7fe68d5b45..15c7c74d01 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -2295,17 +2295,6 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
}
/*
- * Return a unique ID to be used in a message.
- */
- int
-channel_get_id(void)
-{
- static int next_id = 1;
-
- return next_id++;
-}
-
-/*
* Read from channel "channel" for as long as there is something to read.
* "part" is PART_SOCK, PART_OUT or PART_ERR.
* The data is put in the read queue.
@@ -2787,7 +2776,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
return;
}
- id = channel_get_id();
+ id = ++channel->ch_last_msg_id;
text = json_encode_nr_expr(id, &argvars[1],
ch_mode == MODE_JS ? JSON_JS : 0);
if (text == NULL)
diff --git a/src/proto/channel.pro b/src/proto/channel.pro
index be11a3ad20..b98fb58017 100644
--- a/src/proto/channel.pro
+++ b/src/proto/channel.pro
@@ -24,10 +24,9 @@ void channel_close(channel_T *channel, int invoke_close_cb);
char_u *channel_peek(channel_T *channel, int part);
void channel_clear(channel_T *channel);
void channel_free_all(void);
-int channel_get_id(void);
void channel_read(channel_T *channel, int part, char *func);
char_u *channel_read_block(channel_T *channel, int part, int timeout);
-int channel_read_json_block(channel_T *channel, int part, int timeout, int id, typval_T **rettv);
+int channel_read_json_block(channel_T *channel, int part, int timeout_arg, int id, typval_T **rettv);
void common_channel_read(typval_T *argvars, typval_T *rettv, int raw);
channel_T *channel_fd2channel(sock_T fd, int *partp);
void channel_handle_events(void);
diff --git a/src/structs.h b/src/structs.h
index 470beff3c5..85223a0ce5 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1380,6 +1380,7 @@ struct channel_S {
channel_T *ch_prev;
int ch_id; /* ID of the channel */
+ int ch_last_msg_id; /* ID of the last message */
chanpart_T ch_part[4]; /* info for socket, out, err and in */
diff --git a/src/version.c b/src/version.c
index 8d4fee47ed..d7277034ac 100644
--- a/src/version.c
+++ b/src/version.c
@@ -749,6 +749,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1623,
+/**/
1622,
/**/
1621,