changeset 8318:190d8084cb3a v7.4.1451

commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c Author: Bram Moolenaar <Bram@vim.org> 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.
author Christian Brabandt <cb@256bit.org>
date Sun, 28 Feb 2016 19:30:04 +0100
parents 10a72904e595
children 84a0b8e6bce6
files src/channel.c src/eval.c src/proto/channel.pro src/version.c
diffstat 4 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
 
 /*
--- 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
--- 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);
--- 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,