about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2001-10-26 17:15:17 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2001-10-26 17:15:17 +0000
commitc9e1fd9567071050e673552088265963fbca9930 (patch)
tree9335dece9c800d5c72ed96f8a5afb475073365ab
parent0635160db7005fb0df05d6ce4f190acb4becacbb (diff)
downloadzsh-c9e1fd9567071050e673552088265963fbca9930.tar.gz
zsh-c9e1fd9567071050e673552088265963fbca9930.tar.xz
zsh-c9e1fd9567071050e673552088265963fbca9930.zip
16176: Src/Modules/tcp.c, Src/Modules/zftp.c: after fdclose(),
TCP control fd is no longer valid, but we still need to remove
the session cleanly.
-rw-r--r--ChangeLog6
-rw-r--r--Src/Modules/tcp.c14
-rw-r--r--Src/Modules/zftp.c7
3 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2025a54b9..b57b876f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-10-26  Peter Stephenson  <pws@csr.com>
+
+	* 16176: Src/Modules/tcp.c, Src/Modules/zftp.c: after fdclose(),
+	TCP control fd is no longer valid, but we still need to remove
+	the session cleanly.
+
 2001-10-26  Oliver Kiddle  <opk@zsh.org>
 
 	* 16174: Completion/Unix/Command/_zdump,
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index 1fe813e3f..9109ca7c1 100644
--- a/Src/Modules/tcp.c
+++ b/Src/Modules/tcp.c
@@ -291,19 +291,21 @@ tcp_close(Tcp_session sess)
 {
     int err;
     
-    if (sess && sess->fd != -1)
+    if (sess)
     {  
-	err = close(sess->fd);
-	if (err)
+	if (sess->fd != -1)
 	{
-	    zwarn("connection close failed: %e", NULL, errno);
-	    return -1;
+	    err = close(sess->fd);
+	    if (err)
+	    {
+		zwarn("connection close failed: %e", NULL, errno);
+		return -1;
+	    }
 	}
 	zts_delete(sess);
 	return 0;
     }
 
-    zts_delete(sess);
     return -1;
 }
 
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 8dda5f1a8..9408c7a1f 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -2679,6 +2679,13 @@ zfclose(int leaveparams)
     }
     if (zfsess->cin) {
 	fclose(zfsess->cin);
+	/*
+	 * We fdopen'd the TCP control fd; since we can't fdclose it,
+	 * we need to perform a full fclose, which invalidates the
+	 * TCP fd.
+	 */
+	if (fileno(zfsess->cin) == zfsess->control->fd)
+	    zfsess->control->fd = -1;
 	zfsess->cin = NULL;
     }
     if (zfsess->control) {