No, I take that back: we _do_ have a mechanism for suppressing reads
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index a211213..7deb90c 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -6978,6 +6978,36 @@ static void ssh2_msg_channel_close(Ssh ssh, struct Packet *pktin)
     ssh2_channel_got_eof(c);
 
     /*
+     * And we also send an outgoing EOF, if we haven't already, on the
+     * assumption that CLOSE is a pretty forceful announcement that
+     * the remote side is doing away with the entire channel. (If it
+     * had wanted to send us EOF and continue receiving data from us,
+     * it would have just sent CHANNEL_EOF.)
+     */
+    if (!(c->closes & CLOSES_SENT_EOF)) {
+        /*
+         * Make sure we don't read any more from whatever our local
+         * data source is for this channel.
+         */
+        switch (c->type) {
+          case CHAN_MAINSESSION:
+            ssh->send_ok = 0;     /* stop trying to read from stdin */
+            break;
+          case CHAN_X11:
+           x11_override_throttle(c->u.x11.s, 1);
+           break;
+         case CHAN_SOCKDATA:
+           pfd_override_throttle(c->u.pfd.s, 1);
+           break;
+        }
+
+        /*
+         * Send outgoing EOF.
+         */
+        sshfwd_write_eof(ssh->mainchan);
+    }
+
+    /*
      * Now process the actual close.
      */
     if (!(c->closes & CLOSES_RCVD_CLOSE)) {