]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
If we're called on to uncleanly close an SSH channel for which we've
authorSimon Tatham <anakin@pobox.com>
Thu, 26 Jan 2012 18:22:28 +0000 (18:22 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 26 Jan 2012 18:22:28 +0000 (18:22 +0000)
already sent SSH2_MSG_CHANNEL_CLOSE, we should not skip the _whole_ of
sshfwd_unclean_close(), only the part about sending
SSH2_MSG_CHANNEL_CLOSE. It's still important to retag the SSH channel
as CHAN_ZOMBIE and clean up its previous data provider.

[originally from svn r9389]

ssh.c

diff --git a/ssh.c b/ssh.c
index b4c634d310c363930e7ecb5fda19358af1a107b3..505b4ae1dcb811773d9a77d4158bfffbd7bf7715 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -4266,13 +4266,13 @@ void sshfwd_unclean_close(struct ssh_channel *c)
     if (ssh->state == SSH_STATE_CLOSED)
        return;
 
-    if (c->closes & CLOSES_SENT_CLOSE)
-        return;
+    if (!(c->closes & CLOSES_SENT_CLOSE)) {
+        pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_CLOSE);
+        ssh2_pkt_adduint32(pktout, c->remoteid);
+        ssh2_pkt_send(ssh, pktout);
+        c->closes |= CLOSES_SENT_EOF | CLOSES_SENT_CLOSE;
+    }
 
-    pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_CLOSE);
-    ssh2_pkt_adduint32(pktout, c->remoteid);
-    ssh2_pkt_send(ssh, pktout);
-    c->closes |= CLOSES_SENT_EOF | CLOSES_SENT_CLOSE;
     switch (c->type) {
       case CHAN_X11:
         x11_close(c->u.x11.s);
@@ -4283,6 +4283,7 @@ void sshfwd_unclean_close(struct ssh_channel *c)
         break;
     }
     c->type = CHAN_ZOMBIE;
+
     ssh2_channel_check_close(c);
 }