If we're called on to uncleanly close an SSH channel for which we've
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 26 Jan 2012 18:22:28 +0000 (18:22 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
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.

git-svn-id: svn://svn.tartarus.org/sgt/putty@9389 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index b4c634d..505b4ae 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);
 }