Date: Tue, 15 Sep 2015 06:22:51 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287812 - stable/9/usr.sbin/pkg Message-ID: <201509150622.t8F6MpRO004257@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Tue Sep 15 06:22:50 2015 New Revision: 287812 URL: https://svnweb.freebsd.org/changeset/base/287812 Log: MFC: r281039 Allow fetching pkg(8) even if servers/proxies are not passing Content-length Modified: stable/9/usr.sbin/pkg/pkg.c Directory Properties: stable/9/usr.sbin/pkg/ (props changed) Modified: stable/9/usr.sbin/pkg/pkg.c ============================================================================== --- stable/9/usr.sbin/pkg/pkg.c Tue Sep 15 06:21:33 2015 (r287811) +++ stable/9/usr.sbin/pkg/pkg.c Tue Sep 15 06:22:50 2015 (r287812) @@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <time.h> #include <unistd.h> #include <ucl.h> @@ -182,14 +181,11 @@ fetch_to_fd(const char *url, char *path) /* To store _https._tcp. + hostname + \0 */ int fd; int retry, max_retry; - off_t done, r; - time_t now, last; + ssize_t r; char buf[10240]; char zone[MAXHOSTNAMELEN + 13]; static const char *mirror_type = NULL; - done = 0; - last = 0; max_retry = 3; current = mirrors = NULL; remote = NULL; @@ -239,19 +235,16 @@ fetch_to_fd(const char *url, char *path) } } - while (done < st.size) { - if ((r = fread(buf, 1, sizeof(buf), remote)) < 1) - break; - + while ((r = fread(buf, 1, sizeof(buf), remote)) > 0) { if (write(fd, buf, r) != r) { warn("write()"); goto fetchfail; } + } - done += r; - now = time(NULL); - if (now > last || done == st.size) - last = now; + if (r != 0) { + warn("An error occurred while fetching pkg(8)"); + goto fetchfail; } if (ferror(remote))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509150622.t8F6MpRO004257>