Mercurial > vim
comparison src/channel.c @ 8404:8894d595b786 v7.4.1493
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 5 20:54:36 2016 +0100
patch 7.4.1493
Problem: Wrong callback invoked for zero-id messages.
Solution: Don't use the first one-time callback when the sequence number
doesn't match.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 05 Mar 2016 21:00:05 +0100 |
parents | 3b9a306724ec |
children | 05ec48deb353 |
comparison
equal
deleted
inserted
replaced
8403:40c74c3734d7 | 8404:8894d595b786 |
---|---|
1478 typval_T *listtv = NULL; | 1478 typval_T *listtv = NULL; |
1479 typval_T argv[CH_JSON_MAX_ARGS]; | 1479 typval_T argv[CH_JSON_MAX_ARGS]; |
1480 int seq_nr = -1; | 1480 int seq_nr = -1; |
1481 ch_mode_T ch_mode = channel->ch_part[part].ch_mode; | 1481 ch_mode_T ch_mode = channel->ch_part[part].ch_mode; |
1482 cbq_T *cbhead = &channel->ch_part[part].ch_cb_head; | 1482 cbq_T *cbhead = &channel->ch_part[part].ch_cb_head; |
1483 cbq_T *cbitem = cbhead->cq_next; | 1483 cbq_T *cbitem; |
1484 char_u *callback = NULL; | 1484 char_u *callback = NULL; |
1485 buf_T *buffer = NULL; | 1485 buf_T *buffer = NULL; |
1486 | 1486 |
1487 if (channel->ch_nb_close_cb != NULL) | 1487 if (channel->ch_nb_close_cb != NULL) |
1488 /* this channel is handled elsewhere (netbeans) */ | 1488 /* this channel is handled elsewhere (netbeans) */ |
1489 return FALSE; | 1489 return FALSE; |
1490 | 1490 |
1491 /* use a message-specific callback, part callback or channel callback */ | 1491 /* Use a message-specific callback, part callback or channel callback */ |
1492 for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next) | |
1493 if (cbitem->cq_seq_nr == 0) | |
1494 break; | |
1492 if (cbitem != NULL) | 1495 if (cbitem != NULL) |
1493 callback = cbitem->cq_callback; | 1496 callback = cbitem->cq_callback; |
1494 else if (channel->ch_part[part].ch_callback != NULL) | 1497 else if (channel->ch_part[part].ch_callback != NULL) |
1495 callback = channel->ch_part[part].ch_callback; | 1498 callback = channel->ch_part[part].ch_callback; |
1496 else | 1499 else |
1608 if (seq_nr > 0) | 1611 if (seq_nr > 0) |
1609 { | 1612 { |
1610 int done = FALSE; | 1613 int done = FALSE; |
1611 | 1614 |
1612 /* invoke the one-time callback with the matching nr */ | 1615 /* invoke the one-time callback with the matching nr */ |
1613 while (cbitem != NULL) | 1616 for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next) |
1614 { | |
1615 if (cbitem->cq_seq_nr == seq_nr) | 1617 if (cbitem->cq_seq_nr == seq_nr) |
1616 { | 1618 { |
1617 invoke_one_time_callback(channel, cbhead, cbitem, argv); | 1619 invoke_one_time_callback(channel, cbhead, cbitem, argv); |
1618 done = TRUE; | 1620 done = TRUE; |
1619 break; | 1621 break; |
1620 } | 1622 } |
1621 cbitem = cbitem->cq_next; | |
1622 } | |
1623 if (!done) | 1623 if (!done) |
1624 ch_logn(channel, "Dropping message %d without callback", seq_nr); | 1624 ch_logn(channel, "Dropping message %d without callback", seq_nr); |
1625 } | 1625 } |
1626 else if (callback != NULL || buffer != NULL) | 1626 else if (callback != NULL || buffer != NULL) |
1627 { | 1627 { |