From b47b21989c2dd9c7ce0e973b3730965f9d99b990 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 29 Jan 2001 14:30:59 +0000 Subject: [PATCH] Prevent duplicate sk_close() calls on the same socket when the connection dies unexpectedly (CONNABORTED / CONNRESET) git-svn-id: svn://svn.tartarus.org/sgt/putty@910 cda61777-01e9-0310-a592-d414129be87e --- raw.c | 5 +++-- rlogin.c | 6 +++--- ssh.c | 6 +++--- telnet.c | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/raw.c b/raw.c index 27af2c4e..9cbb606c 100644 --- a/raw.c +++ b/raw.c @@ -27,11 +27,12 @@ static void c_write (char *buf, int len) { static int raw_receive (Socket skt, int urgent, char *data, int len) { if (urgent==3) { /* A socket error has occurred. */ + sk_close(s); s = NULL; connection_fatal(data); len = 0; - } - if (!len) { + return 0; + } else if (!len) { /* Connection has closed. */ sk_close(s); s = NULL; diff --git a/rlogin.c b/rlogin.c index e0552f25..850d906d 100644 --- a/rlogin.c +++ b/rlogin.c @@ -27,11 +27,11 @@ static void c_write (char *buf, int len) { static int rlogin_receive (Socket skt, int urgent, char *data, int len) { if (urgent==3) { /* A socket error has occurred. */ + sk_close(s); s = NULL; connection_fatal(data); - len = 0; - } - if (!len) { + return 0; + } else if (!len) { /* Connection has closed. */ sk_close(s); s = NULL; diff --git a/ssh.c b/ssh.c index 4849d91d..5ad1ea4a 100644 --- a/ssh.c +++ b/ssh.c @@ -1153,11 +1153,11 @@ static int ssh_receive(Socket skt, int urgent, char *data, int len) { if (urgent==3) { /* A socket error has occurred. */ ssh_state = SSH_STATE_CLOSED; + sk_close(s); s = NULL; connection_fatal(data); - len = 0; - } - if (!len) { + return 0; + } else if (!len) { /* Connection has closed. */ ssh_state = SSH_STATE_CLOSED; sk_close(s); diff --git a/telnet.c b/telnet.c index cd70d9b8..8cb02a03 100644 --- a/telnet.c +++ b/telnet.c @@ -468,11 +468,11 @@ static void do_telnet_read (char *buf, int len) { static int telnet_receive(Socket skt, int urgent, char *data, int len) { if (urgent==3) { /* A socket error has occurred. */ + sk_close(s); s = NULL; connection_fatal(data); - len = 0; - } - if (!len) { + return 0; + } else if (!len) { /* Connection has closed. */ sk_close(s); s = NULL; -- 2.11.0