# HG changeset patch # User Christian Brabandt # Date 1456684204 -3600 # Node ID 190d8084cb3ab72c8863140c185ad285bd0ab969 # Parent 10a72904e59508518ba2174d01227514b95cd907 commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c Author: Bram Moolenaar Date: Sun Feb 28 19:28:59 2016 +0100 patch 7.4.1451 Problem: Vim hangs when a channel has a callback but isn't referenced. Solution: Have channel_unref() only return TRUE when the channel was actually freed. diff --git a/src/channel.c b/src/channel.c --- a/src/channel.c +++ b/src/channel.c @@ -334,12 +334,17 @@ channel_still_useful(channel_T *channel) * Close a channel and free all its resources if there is no further action * possible, there is no callback to be invoked or the associated job was * killed. + * Return TRUE if the channel was freed. */ - void + int channel_may_free(channel_T *channel) { if (!channel_still_useful(channel)) + { channel_free(channel); + return TRUE; + } + return FALSE; } /* diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -7747,10 +7747,7 @@ failret: channel_unref(channel_T *channel) { if (channel != NULL && --channel->ch_refcount <= 0) - { - channel_may_free(channel); - return TRUE; - } + return channel_may_free(channel); return FALSE; } #endif diff --git a/src/proto/channel.pro b/src/proto/channel.pro --- a/src/proto/channel.pro +++ b/src/proto/channel.pro @@ -4,7 +4,7 @@ int ch_log_active(void); void ch_log(channel_T *ch, char *msg); void ch_logs(channel_T *ch, char *msg, char *name); channel_T *add_channel(void); -void channel_may_free(channel_T *channel); +int channel_may_free(channel_T *channel); void channel_free(channel_T *channel); void channel_gui_register(channel_T *channel); void channel_gui_register_all(void); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -744,6 +744,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1451, +/**/ 1450, /**/ 1449,