From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: "ZSH workers mailing list" <zsh-workers@math.gatech.edu>
Subject: PATCH: 3.1.5-pws-4: zftp problem (OS dependent)
Date: Sat, 09 Jan 1999 17:01:29 +0100 [thread overview]
Message-ID: <9901091601.AA27679@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Andrej Borsenkow""'s message of "Thu, 24 Dec 1998 14:10:17 NFT." <001f01be2f2d$fd08aab0$21c9ca95@mowp.siemens.ru>
"Andrej Borsenkow" wrote:
> It looks, that we can duplicate connected socket. It means, that zfmovefd()
> should be called after connect succeeds. It seems to be safe, as if connect
> fails, we close fd anyway.
OK, this patch moves the zfmovefd() later. It also does it with the
data connection, just to try to keep things simple (though for all I
know that will now break on some OS...).
*** Src/Modules/zftp.c.movefd Sat Dec 19 14:51:48 1998
--- Src/Modules/zftp.c Sat Jan 9 16:54:20 1999
***************
*** 832,838 ****
zwarnnam(name, "Must set preference S or P to transfer data", NULL, 0);
return 1;
}
! zdfd = zfmovefd(socket(AF_INET, SOCK_STREAM, 0));
if (zdfd < 0) {
zwarnnam(name, "can't get data socket: %e", NULL, errno);
return 1;
--- 832,838 ----
zwarnnam(name, "Must set preference S or P to transfer data", NULL, 0);
return 1;
}
! zdfd = socket(AF_INET, SOCK_STREAM, 0);
if (zdfd < 0) {
zwarnnam(name, "can't get data socket: %e", NULL, errno);
return 1;
***************
*** 1029,1034 ****
--- 1029,1041 ----
return 1;
}
zdfd = newfd; /* this is now the actual data fd */
+ } else {
+ /*
+ * We avoided dup'ing zdfd up to this point, to try to keep
+ * things simple, so we now need to move it out of the way
+ * of the user-visible fd's.
+ */
+ zdfd = zfmovefd(zdfd);
}
***************
*** 1671,1677 ****
}
zsock.sin_port = zservp->s_port;
! zcfd = zfmovefd(socket(zsock.sin_family, SOCK_STREAM, 0));
if (zcfd < 0) {
zwarnnam(name, "socket failed: %e", NULL, errno);
zfunsetparam("ZFTP_HOST");
--- 1678,1684 ----
}
zsock.sin_port = zservp->s_port;
! zcfd = socket(zsock.sin_family, SOCK_STREAM, 0);
if (zcfd < 0) {
zwarnnam(name, "socket failed: %e", NULL, errno);
zfunsetparam("ZFTP_HOST");
***************
*** 1679,1690 ****
return 1;
}
- #if defined(F_SETFD) && defined(FD_CLOEXEC)
- /* If the shell execs a program, we don't want this fd left open. */
- len = FD_CLOEXEC;
- fcntl(zcfd, F_SETFD, &len);
- #endif
-
/*
* now connect the socket. manual pages all say things like `this is all
* explained oh-so-wonderfully in some other manual page'. not.
--- 1686,1691 ----
***************
*** 1719,1724 ****
--- 1720,1738 ----
zfsetparam("ZFTP_IP", ztrdup(inet_ntoa(zsock.sin_addr)), ZFPM_READONLY);
/* now we can talk to the control connection */
zcfinish = 0;
+
+
+ /*
+ * Move the fd out of the user-visible range. We need to do
+ * this after the connect() on some systems.
+ */
+ zcfd = zfmovefd(zcfd);
+
+ #if defined(F_SETFD) && defined(FD_CLOEXEC)
+ /* If the shell execs a program, we don't want this fd left open. */
+ len = FD_CLOEXEC;
+ fcntl(zcfd, F_SETFD, &len);
+ #endif
len = sizeof(zsock);
if (getsockname(zcfd, (struct sockaddr *)&zsock, &len) < 0) {
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
prev parent reply other threads:[~1999-01-09 16:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <001501be2eaa$13c41c50$21c9ca95@mowp.siemens.ru>
1998-12-24 11:10 ` Andrej Borsenkow
1999-01-09 16:01 ` Peter Stephenson [this message]
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=9901091601.AA27679@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@math.gatech.edu \
/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).