X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=x11fwd.c;h=5b4f76cdcb0e95c0899b9e088dc4eff1dcd2c668;hb=b73527e641fa09ff57ffd4d20ec4e4045039b890;hp=90824714c169c795a43bf96e55b6a9b99429cade;hpb=a1f3b7a358adaa7c2a98359cd0373aa823eeb14b;p=PuTTY.git diff --git a/x11fwd.c b/x11fwd.c index 90824714..5b4f76cd 100644 --- a/x11fwd.c +++ b/x11fwd.c @@ -503,13 +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. - */ - sshfwd_close(pr->c); - x11_close(pr->s); + 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; } @@ -721,8 +728,7 @@ int x11_send(Socket s, char *data, int len) memset(reply + 8, 0, msgsize); memcpy(reply + 8, message, msglen); sshfwd_write(pr->c, (char *)reply, 8 + msgsize); - sshfwd_close(pr->c); - x11_close(s); + sshfwd_write_eof(pr->c); sfree(reply); sfree(message); return 0; @@ -787,3 +793,8 @@ int x11_send(Socket s, char *data, int len) return sk_write(s, data, len); } + +void x11_send_eof(Socket s) +{ + sk_write_eof(s); +}