From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: tcp/zftp close
Date: Fri, 26 Oct 2001 14:13:20 +0100 [thread overview]
Message-ID: <11357.1004102000@csr.com> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Fri, 26 Oct 2001 13:02:06 BST." <11058.1004097726@csr.com>
Peter Stephenson wrote:
> Now there's just the matter of
> zfclose:3: connection close failed: bad file number
> to deal with.
This fixes that, but unfortunately invalidates Bart's previous assumption
that a TCP session would always have a valid fd number. Given the comment
in the second hunk, I don't see an alternative, does anyone?
The test
(fileno(zfsess->cin) == zfsess->control->fd)
is the most dire and unjustifiable paranoia.
Index: Src/Modules/tcp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/tcp.c,v
retrieving revision 1.20
diff -u -r1.20 tcp.c
--- Src/Modules/tcp.c 2001/10/26 12:06:39 1.20
+++ Src/Modules/tcp.c 2001/10/26 13:07:00
@@ -291,19 +291,21 @@
{
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;
}
Index: Src/Modules/zftp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zftp.c,v
retrieving revision 1.23
diff -u -r1.23 zftp.c
--- Src/Modules/zftp.c 2001/10/26 12:06:39 1.23
+++ Src/Modules/zftp.c 2001/10/26 13:07:01
@@ -2679,6 +2679,13 @@
}
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) {
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
next prev parent reply other threads:[~2001-10-26 13:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-26 12:02 PATCH: tcp/zftp function name Peter Stephenson
2001-10-26 12:05 ` Peter Stephenson
2001-10-26 13:13 ` Peter Stephenson [this message]
2001-10-26 17:05 ` PATCH: tcp/zftp close Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11357.1004102000@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).