# HG changeset patch
# User Matt Johnston <matt@ucc.asn.au>
# Date 1392644466 -28800
# Node ID a1a97e98b0c16694d19b2f4626d7c64f3e4b3378
# Parent  5608a5a61c2a8c0e634d2e42328a2447185389ea
Read (and enqueue) packets from interactive input even when
we're waiting for a key exchange.

This should hopefully fix the situation where "~." doesn't work to terminate a
client session when a laptop wakes up. The client will be stuck waiting for a
key exchange on a dead connection, so won't have read the escape character

diff -r 5608a5a61c2a -r a1a97e98b0c1 common-channel.c
--- a/common-channel.c	Sat Feb 15 21:42:35 2014 +0800
+++ b/common-channel.c	Mon Feb 17 21:41:06 2014 +0800
@@ -474,8 +474,13 @@
 			continue;
 		}
 
-		/* Stuff to put over the wire */
-		if (channel->transwindow > 0) {
+		/* Stuff to put over the wire. 
+		Avoid queueing data to send if we're in the middle of a 
+		key re-exchange (!dataallowed), but still read from the 
+		FD if there's the possibility of "~."" to kill an 
+		interactive session (the read_mangler) */
+		if (channel->transwindow > 0
+		   && (ses.dataallowed || channel->read_mangler)) {
 
 			if (channel->readfd >= 0) {
 				FD_SET(channel->readfd, readfds);
diff -r 5608a5a61c2a -r a1a97e98b0c1 common-session.c
--- a/common-session.c	Sat Feb 15 21:42:35 2014 +0800
+++ b/common-session.c	Mon Feb 17 21:41:06 2014 +0800
@@ -153,10 +153,9 @@
 		   SIGCHLD in svr-chansession is the only one currently. */
 		FD_SET(ses.signal_pipe[0], &readfd);
 
-		/* set up for channels which require reading/writing */
-		if (ses.dataallowed) {
-			setchannelfds(&readfd, &writefd);
-		}
+		/* set up for channels which can be read/written */
+		setchannelfds(&readfd, &writefd);
+
 		val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout);
 
 		if (exitflag) {
@@ -217,9 +216,7 @@
 
 		/* process pipes etc for the channels, ses.dataallowed == 0
 		 * during rekeying ) */
-		if (ses.dataallowed) {
-			channelio(&readfd, &writefd);
-		}
+		channelio(&readfd, &writefd);
 
 		if (loophandler) {
 			loophandler();