@@ -2930,14 +2930,26 @@ channel_close_in(channel_T *channel)
29302930 ch_close_part (channel , PART_IN );
29312931}
29322932
2933+ static void
2934+ remove_from_writeque (writeq_T * wq , writeq_T * entry )
2935+ {
2936+ ga_clear (& entry -> wq_ga );
2937+ wq -> wq_next = entry -> wq_next ;
2938+ if (wq -> wq_next == NULL )
2939+ wq -> wq_prev = NULL ;
2940+ else
2941+ wq -> wq_next -> wq_prev = NULL ;
2942+ }
2943+
29332944/*
29342945 * Clear the read buffer on "channel"/"part".
29352946 */
29362947 static void
29372948channel_clear_one (channel_T * channel , ch_part_T part )
29382949{
2939- jsonq_T * json_head = & channel -> ch_part [part ].ch_json_head ;
2940- cbq_T * cb_head = & channel -> ch_part [part ].ch_cb_head ;
2950+ chanpart_T * ch_part = & channel -> ch_part [part ];
2951+ jsonq_T * json_head = & ch_part -> ch_json_head ;
2952+ cbq_T * cb_head = & ch_part -> ch_cb_head ;
29412953
29422954 while (channel_peek (channel , part ) != NULL )
29432955 vim_free (channel_get (channel , part ));
@@ -2957,10 +2969,13 @@ channel_clear_one(channel_T *channel, ch_part_T part)
29572969 remove_json_node (json_head , json_head -> jq_next );
29582970 }
29592971
2960- free_callback (channel -> ch_part [part ].ch_callback ,
2961- channel -> ch_part [part ].ch_partial );
2962- channel -> ch_part [part ].ch_callback = NULL ;
2963- channel -> ch_part [part ].ch_partial = NULL ;
2972+ free_callback (ch_part -> ch_callback , ch_part -> ch_partial );
2973+ ch_part -> ch_callback = NULL ;
2974+ ch_part -> ch_partial = NULL ;
2975+
2976+ while (ch_part -> ch_writeque .wq_next != NULL )
2977+ remove_from_writeque (& ch_part -> ch_writeque ,
2978+ ch_part -> ch_writeque .wq_next );
29642979}
29652980
29662981/*
@@ -3719,12 +3734,7 @@ channel_send(
37193734 if (entry != NULL )
37203735 {
37213736 /* Remove the entry from the write queue. */
3722- ga_clear (& entry -> wq_ga );
3723- wq -> wq_next = entry -> wq_next ;
3724- if (wq -> wq_next == NULL )
3725- wq -> wq_prev = NULL ;
3726- else
3727- wq -> wq_next -> wq_prev = NULL ;
3737+ remove_from_writeque (wq , entry );
37283738 continue ;
37293739 }
37303740 if (did_use_queue )
0 commit comments