]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Prevent duplicate sk_close() calls on the same socket when the
authorSimon Tatham <anakin@pobox.com>
Mon, 29 Jan 2001 14:30:59 +0000 (14:30 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 29 Jan 2001 14:30:59 +0000 (14:30 +0000)
connection dies unexpectedly (CONNABORTED / CONNRESET)

[originally from svn r910]

raw.c
rlogin.c
ssh.c
telnet.c

diff --git a/raw.c b/raw.c
index 27af2c4e01b8c1b9e4286e577639fae1fd4ec769..9cbb606c8f467831b2abe6b07fc7e2fe42a6b715 100644 (file)
--- 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;
index e0552f25b598daaa83886283f4efd1b236d191e0..850d906d210745d84f986db05aba3fec7faba361 100644 (file)
--- 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 4849d91d34e8c57d368a12405f83fa0f5ef6623b..5ad1ea4a69ec2d014763b53217c01b38cee2e42e 100644 (file)
--- 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);
index cd70d9b8a06e6e8373dc8341df231ca6834f0ead..8cb02a03d54c6c6774c901e53c30487e77ad3acc 100644 (file)
--- 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;