Date: Mon, 29 Jun 2026 15:54:20 +0000 From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 667ef98c29f9 - main - Revert "libfetch: Apply timeout to connection attempts" Message-ID: <6a42952c.3986b.3e8adf59@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=667ef98c29f94c34d06f5ff1d5d32c99a04f6082 commit 667ef98c29f94c34d06f5ff1d5d32c99a04f6082 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-06-29 15:53:54 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-06-29 15:53:54 +0000 Revert "libfetch: Apply timeout to connection attempts" This reverts commit d53af4112273f7b234a1cdd6694b3a7ca0aae0eb. --- lib/libfetch/common.c | 47 ++++++----------------------------------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index d1a897b98827..c1888a1518a0 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -593,13 +593,10 @@ fetch_socks5_getenv(char **host, int *port) conn_t * fetch_connect(const char *host, int port, int af, int verbose) { - struct timeval now, timeout, delta; - struct pollfd pfd; struct addrinfo *cais = NULL, *sais = NULL, *cai, *sai; const char *bindaddr; conn_t *conn = NULL; int err = 0, sd = -1; - int deltams; char *sockshost; int socksport; @@ -657,47 +654,15 @@ fetch_connect(const char *host, int port, int af, int verbose) fetch_verbose("failed to bind to %s", bindaddr); goto syserr; } - /* make the socket non-blocking */ - (void)fcntl(sd, F_SETFL, O_NONBLOCK); - /* start the clock */ - if (fetchTimeout > 0) { - gettimeofday(&timeout, NULL); - timeout.tv_sec += fetchTimeout; - deltams = fetchTimeout * 1000; - } /* attempt to connect to server address */ - if ((err = connect(sd, sai->ai_addr, sai->ai_addrlen)) == 0) + while ((err = connect(sd, sai->ai_addr, sai->ai_addrlen)) < 0) { + if (errno == EINTR && fetchRestartCalls) + continue; break; - /* wait for connection */ - if (errno == EINPROGRESS) { - deltams = INFTIM; - pfd.fd = sd; - pfd.events = POLLOUT; - for (;;) { - /* wait for something to happen */ - if (poll(&pfd, 1, deltams) >= 0) - break; - if (errno == EINTR && !fetchRestartCalls) - break; - /* check the clock */ - if (fetchTimeout > 0) { - gettimeofday(&now, NULL); - if (!timercmp(&timeout, &now, >)) { - errno = ETIMEDOUT; - pfd.revents = POLLERR; - break; - } - timersub(&timeout, &now, &delta); - deltams = delta.tv_sec * 1000 + - delta.tv_usec / 1000; - } - } - if (pfd.revents == POLLOUT) { - /* connection established */ - err = 0; - break; - } } + /* success? */ + if (err == 0) + break; /* clean up before next attempt */ close(sd); sd = -1;home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a42952c.3986b.3e8adf59>
