To: vim_dev@googlegroups.com Subject: Patch 7.4.1623 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1623 Problem: All Channels share the message ID, it keeps getting bigger. Solution: Use a message ID per channel. Files: src/channel.c, src/proto/channel.pro, src/structs.h *** ../vim-7.4.1622/src/channel.c 2016-03-20 17:28:31.440893217 +0100 --- src/channel.c 2016-03-20 19:18:05.449533374 +0100 *************** *** 2295,2311 **** } /* - * 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. --- 2295,2300 ---- *************** *** 2787,2793 **** return; } ! id = channel_get_id(); text = json_encode_nr_expr(id, &argvars[1], ch_mode == MODE_JS ? JSON_JS : 0); if (text == NULL) --- 2776,2782 ---- return; } ! id = ++channel->ch_last_msg_id; text = json_encode_nr_expr(id, &argvars[1], ch_mode == MODE_JS ? JSON_JS : 0); if (text == NULL) *** ../vim-7.4.1622/src/proto/channel.pro 2016-03-14 23:27:25.256676749 +0100 --- src/proto/channel.pro 2016-03-20 19:30:54.517651723 +0100 *************** *** 24,33 **** 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); 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); --- 24,32 ---- char_u *channel_peek(channel_T *channel, int part); void channel_clear(channel_T *channel); void channel_free_all(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_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); *** ../vim-7.4.1622/src/structs.h 2016-03-20 16:40:33.214484441 +0100 --- src/structs.h 2016-03-20 19:18:12.649459631 +0100 *************** *** 1380,1385 **** --- 1380,1386 ---- 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 */ *** ../vim-7.4.1622/src/version.c 2016-03-20 18:54:13.832174369 +0100 --- src/version.c 2016-03-20 19:29:05.098773614 +0100 *************** *** 750,751 **** --- 750,753 ---- { /* Add new patch number below this line */ + /**/ + 1623, /**/ -- From "know your smileys": 2B|^2B Message from Shakespeare /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///