Skip to content

Commit e9d6a29

Browse files
committed
patch 7.4.1623
Problem: All Channels share the message ID, it keeps getting bigger. Solution: Use a message ID per channel.
1 parent 17b56c9 commit e9d6a29

4 files changed

Lines changed: 5 additions & 14 deletions

File tree

src/channel.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,17 +2294,6 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
22942294
return FAIL;
22952295
}
22962296

2297-
/*
2298-
* Return a unique ID to be used in a message.
2299-
*/
2300-
int
2301-
channel_get_id(void)
2302-
{
2303-
static int next_id = 1;
2304-
2305-
return next_id++;
2306-
}
2307-
23082297
/*
23092298
* Read from channel "channel" for as long as there is something to read.
23102299
* "part" is PART_SOCK, PART_OUT or PART_ERR.
@@ -2787,7 +2776,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
27872776
return;
27882777
}
27892778

2790-
id = channel_get_id();
2779+
id = ++channel->ch_last_msg_id;
27912780
text = json_encode_nr_expr(id, &argvars[1],
27922781
ch_mode == MODE_JS ? JSON_JS : 0);
27932782
if (text == NULL)

src/proto/channel.pro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ void channel_close(channel_T *channel, int invoke_close_cb);
2424
char_u *channel_peek(channel_T *channel, int part);
2525
void channel_clear(channel_T *channel);
2626
void channel_free_all(void);
27-
int channel_get_id(void);
2827
void channel_read(channel_T *channel, int part, char *func);
2928
char_u *channel_read_block(channel_T *channel, int part, int timeout);
30-
int channel_read_json_block(channel_T *channel, int part, int timeout, int id, typval_T **rettv);
29+
int channel_read_json_block(channel_T *channel, int part, int timeout_arg, int id, typval_T **rettv);
3130
void common_channel_read(typval_T *argvars, typval_T *rettv, int raw);
3231
channel_T *channel_fd2channel(sock_T fd, int *partp);
3332
void channel_handle_events(void);

src/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,7 @@ struct channel_S {
13801380
channel_T *ch_prev;
13811381

13821382
int ch_id; /* ID of the channel */
1383+
int ch_last_msg_id; /* ID of the last message */
13831384

13841385
chanpart_T ch_part[4]; /* info for socket, out, err and in */
13851386

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1623,
751753
/**/
752754
1622,
753755
/**/

0 commit comments

Comments
 (0)