summaryrefslogtreecommitdiff
path: root/net/fetch
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2009-02-05 23:38:18 +0000
committerjoerg <joerg@pkgsrc.org>2009-02-05 23:38:18 +0000
commitd137b223d01d869b1f24caf93f93dfd5e8ffad18 (patch)
tree65d8a9c95b46dfd3c797a4c6cbfb3e5a2a756358 /net/fetch
parent6216f6bf9d3fd034778612309fbb928febb54124 (diff)
downloadpkgsrc-d137b223d01d869b1f24caf93f93dfd5e8ffad18.tar.gz
fetch-1.4:
- restart system calls for SIGINFO, will do the status update on the next return - handle FETCH_TIMEOUT like SIGALRM, and don't print errors about writing the output file - explicitly check for -1 as return from fetchIO_read.
Diffstat (limited to 'net/fetch')
-rw-r--r--net/fetch/Makefile4
-rw-r--r--net/fetch/files/fetch.c22
2 files changed, 16 insertions, 10 deletions
diff --git a/net/fetch/Makefile b/net/fetch/Makefile
index 0565f72a67a..31acf080385 100644
--- a/net/fetch/Makefile
+++ b/net/fetch/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.4 2009/02/05 22:19:57 joerg Exp $
+# $NetBSD: Makefile,v 1.5 2009/02/05 23:38:18 joerg Exp $
#
-DISTNAME= fetch-1.3
+DISTNAME= fetch-1.4
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/net/fetch/files/fetch.c b/net/fetch/files/fetch.c
index 0da7e15f82a..dea2e0292c3 100644
--- a/net/fetch/files/fetch.c
+++ b/net/fetch/files/fetch.c
@@ -125,12 +125,14 @@ sig_handler(int sig)
{
switch (sig) {
case SIGALRM:
+ fetchRestartCalls = 0;
sigalrm = 1;
break;
case SIGINFO:
siginfo = 1;
break;
case SIGINT:
+ fetchRestartCalls = 0;
sigint = 1;
break;
}
@@ -651,19 +653,24 @@ fetch(char *URL, const char *path)
else
size = B_size;
if (siginfo) {
- stat_end(&xs);
+ stat_display(&xs, 1);
siginfo = 0;
}
if ((size = fetchIO_read(f, buf, B_size)) == 0)
break;
+ if (size == -1 && errno == EINTR)
+ continue;
+ if (size == -1)
+ break;
stat_update(&xs, count += size);
- for (ptr = buf; size > 0; ptr += wr, size -= wr)
+ for (ptr = buf; size > 0; ptr += wr, size -= wr) {
if ((wr = fwrite(ptr, 1, size, of)) < size) {
if (ferror(of) && errno == EINTR && !sigint)
clearerr(of);
else
break;
}
+ }
if (size != 0)
break;
}
@@ -693,6 +700,8 @@ fetch(char *URL, const char *path)
}
/* timed out or interrupted? */
+ if (fetchLastErrCode == FETCH_TIMEOUT)
+ sigalrm = 1;
if (sigalrm)
warnx("transfer timed out");
if (sigint) {
@@ -704,12 +713,10 @@ fetch(char *URL, const char *path)
if (f == NULL)
goto failure;
- if (!sigalrm) {
+ if (!sigalrm && ferror(of)) {
/* check the status of our files */
- if (ferror(of))
- warn("%s", path);
- if (ferror(of))
- goto failure;
+ warn("writing to %s failed", path);
+ goto failure;
}
/* did the transfer complete normally? */
@@ -909,7 +916,6 @@ main(int argc, char *argv[])
sigaction(SIGALRM, &sa, NULL);
sa.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sa, NULL);
- fetchRestartCalls = 0;
/* output file */
if (o_flag) {