patch 7.4.1826
Problem:    Callbacks are invoked when it's not safe. (Andrew Stewart)
Solution:   When a channel is to be closed don't invoke callbacks right away,
            wait for a safe moment.
diff --git a/src/structs.h b/src/structs.h
index 50901ac..a2b38bf 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1416,6 +1416,9 @@
     char	*ch_hostname;	/* only for socket, allocated */
     int		ch_port;	/* only for socket */
 
+    int		ch_to_be_closed; /* When TRUE reading or writing failed and
+				  * the channel must be closed when it's safe
+				  * to invoke callbacks. */
     int		ch_error;	/* When TRUE an error was reported.  Avoids
 				 * giving pages full of error messages when
 				 * the other side has exited, only mention the