On Mon, 08 Aug 2016 12:48:49 +0200, Marc Espie wrote:
> Well, unless someone can repair connect, here's a very ugly hack that
> should prevent SIGWINCH from fucking ftp up.
It's not like SIGWINCH is special, let's just handle EADDRINUSE
preceded by EINTR.
- todd
Index: usr.bin/ftp/ftp.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/ftp.c,v
retrieving revision 1.96
diff -u -p -u -r1.96 ftp.c
--- usr.bin/ftp/ftp.c 16 Mar 2016 15:41:11 -0000 1.96
+++ usr.bin/ftp/ftp.c 8 Aug 2016 17:17:51 -0000
@@ -219,9 +219,17 @@ hookup(char *host, char *port)
}
}
#endif /* !SMALL */
- while ((error = connect(s, res->ai_addr, res->ai_addrlen)) < 0
- && errno == EINTR) {
- ;
+ error = 0;
+ while (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+ if (errno == EINTR) {
+ error = errno;
+ continue;
+ }
+ if (errno == EADDRINUSE && error == EINTR) {
+ /* Restarted, not an error. */
+ error = 0;
+ }
+ break;
}
if (error) {
/* this "if" clause is to prevent print warning twice */
@@ -1517,10 +1525,18 @@ reinit:
} else
goto bad;
+ error = 0;
while (connect(data, (struct sockaddr *)&data_addr,
data_addr.su_len) < 0) {
- if (errno == EINTR)
+ if (errno == EINTR) {
+ error = errno;
continue;
+ }
+ if (errno == EADDRINUSE && error == EINTR) {
+ /* Restarted, not an error. */
+ error = 0;
+ break;
+ }
if (activefallback) {
(void)close(data);
data = -1;