Skip to content

Commit 7076594

Browse files
committed
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.
1 parent 1c39102 commit 7076594

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/channel.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,17 @@ channel_still_useful(channel_T *channel)
334334
* Close a channel and free all its resources if there is no further action
335335
* possible, there is no callback to be invoked or the associated job was
336336
* killed.
337+
* Return TRUE if the channel was freed.
337338
*/
338-
void
339+
int
339340
channel_may_free(channel_T *channel)
340341
{
341342
if (!channel_still_useful(channel))
343+
{
342344
channel_free(channel);
345+
return TRUE;
346+
}
347+
return FALSE;
343348
}
344349

345350
/*

src/eval.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7747,10 +7747,7 @@ get_dict_tv(char_u **arg, typval_T *rettv, int evaluate)
77477747
channel_unref(channel_T *channel)
77487748
{
77497749
if (channel != NULL && --channel->ch_refcount <= 0)
7750-
{
7751-
channel_may_free(channel);
7752-
return TRUE;
7753-
}
7750+
return channel_may_free(channel);
77547751
return FALSE;
77557752
}
77567753
#endif

src/proto/channel.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ int ch_log_active(void);
44
void ch_log(channel_T *ch, char *msg);
55
void ch_logs(channel_T *ch, char *msg, char *name);
66
channel_T *add_channel(void);
7-
void channel_may_free(channel_T *channel);
7+
int channel_may_free(channel_T *channel);
88
void channel_free(channel_T *channel);
99
void channel_gui_register(channel_T *channel);
1010
void channel_gui_register_all(void);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1451,
746748
/**/
747749
1450,
748750
/**/

0 commit comments

Comments
 (0)