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.
* 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;
}
/*
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
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);
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1451,
/**/
1450,
/**/