patch 8.0.0957: a terminal job can deadlock when sending many keys
Problem: When term_sendkeys() sends many keys it may get stuck in writing
to the job.
Solution: Make the write non-blocking, buffer keys to be sent.
diff --git a/src/structs.h b/src/structs.h
index 40dfd95..444b30d 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1196,6 +1196,7 @@
typedef struct jobvar_S job_T;
typedef struct readq_S readq_T;
+typedef struct writeq_S writeq_T;
typedef struct jsonq_S jsonq_T;
typedef struct cbq_S cbq_T;
typedef struct channel_S channel_T;
@@ -1512,6 +1513,13 @@
readq_T *rq_prev;
};
+struct writeq_S
+{
+ garray_T wq_ga;
+ writeq_T *wq_next;
+ writeq_T *wq_prev;
+};
+
struct jsonq_S
{
typval_T *jq_value;
@@ -1601,6 +1609,8 @@
#endif
int ch_block_write; /* for testing: 0 when not used, -1 when write
* does not block, 1 simulate blocking */
+ int ch_nonblocking; /* write() is non-blocking */
+ writeq_T ch_writeque; /* header for write queue */
cbq_T ch_cb_head; /* dummy node for per-request callbacks */
char_u *ch_callback; /* call when a msg is not handled */