From 707659490d35e8d66e8bbdcfd93b12dc1387d86c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 28 Feb 2016 19:28:59 +0100 Subject: [PATCH] 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. --- src/channel.c | 7 ++++++- src/eval.c | 5 +---- src/proto/channel.pro | 2 +- src/version.c | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/channel.c b/src/channel.c index c6f94ee2b9..5e8c6bd814 100644 --- 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 index 4dd400ad98..a208b2a727 100644 --- 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 index 8dc4ad44d1..5fd7f1405e 100644 --- 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 index d9697a8f96..86ed223177 100644 --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1451, /**/ 1450, /**/