Index: ftp.c =================================================================== RCS file: /space2/ncvs/src/contrib/lukemftp/src/ftp.c,v retrieving revision 1.1.1.5 diff -u -p -r1.1.1.5 ftp.c --- ftp.c 3 Nov 2003 17:12:04 -0000 1.1.1.5 +++ ftp.c 9 Apr 2004 20:12:42 -0000 @@ -230,10 +230,7 @@ hookup(char *host, char *port) cause = "socket"; continue; } - while ((error = xconnect(s, res->ai_addr, res->ai_addrlen)) < 0 - && errno == EINTR) { - ; - } + error = xconnect(s, res->ai_addr, res->ai_addrlen); if (error) { /* this "if" clause is to prevent print warning twice */ if (res->ai_next) { @@ -1544,8 +1541,6 @@ initconn(void) while (xconnect(data, (struct sockaddr *)&data_addr.si_su, data_addr.su_len) < 0) { - if (errno == EINTR) - continue; if (activefallback) { (void)close(data); data = -1; Index: util.c =================================================================== RCS file: /space2/ncvs/src/contrib/lukemftp/src/util.c,v retrieving revision 1.1.1.4 diff -u -p -r1.1.1.4 util.c --- util.c 3 Nov 2003 17:12:08 -0000 1.1.1.4 +++ util.c 9 Apr 2004 19:43:46 -0000 @@ -78,6 +78,7 @@ __RCSID("$NetBSD: util.c,v 1.114 2003/08 * FTP User Program -- Misc support routines */ #include +#include #include #include #include @@ -1204,14 +1205,30 @@ isipv6addr(const char *addr) /* - * Internal version of connect(2); sets socket buffer sizes first. + * Internal version of connect(2); sets socket buffer sizes first and + * handles the syscall being interrupted. */ int xconnect(int sock, const struct sockaddr *name, int namelen) { + fd_set connfd; + int error, retval; setupsockbufsize(sock); - return (connect(sock, name, namelen)); + error = connect(sock, name, namelen); + if (error && errno == EINTR) { + FD_ZERO(&connfd); + FD_SET(sock, &connfd); +again: + retval = select(sock + 1, NULL, &connfd, NULL, NULL); + if (retval == -1) { + if (errno == EINTR) + goto again; + return (-1); + } + return (0); + } + return (error); } /*