Call sshfwd_unclean_close() in the event of a local socket error on a
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 23 Apr 2012 17:59:53 +0000 (17:59 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 23 Apr 2012 17:59:53 +0000 (17:59 +0000)
forwarded X connection. (I somehow forgot to do this in r9364, despite
making the identical change in portfwd.c.)

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

x11fwd.c

index ba5bbf9..5b4f76c 100644 (file)
--- a/x11fwd.c
+++ b/x11fwd.c
@@ -503,16 +503,20 @@ static int x11_closing(Plug plug, const char *error_msg, int error_code,
 {
     struct X11Private *pr = (struct X11Private *) plug;
 
-    /*
-     * We have no way to communicate down the forwarded connection,
-     * so if an error occurred on the socket, we just ignore it
-     * and treat it like a proper close.
-     *
-     * FIXME: except we could initiate a full close here instead of
-     * just an outgoing EOF? ssh.c currently has no API for that, but
-     * it could.
-     */
-    sshfwd_write_eof(pr->c);
+    if (error_msg) {
+        /*
+         * Socket error. Slam the connection instantly shut.
+         */
+        sshfwd_unclean_close(pr->c);
+    } else {
+        /*
+         * Ordinary EOF received on socket. Send an EOF on the SSH
+         * channel.
+         */
+        if (pr->c)
+            sshfwd_write_eof(pr->c);
+    }
+
     return 1;
 }