pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/fetch fetch-1.4:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/89a1e7044b2f
branches:  trunk
changeset: 554002:89a1e7044b2f
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Thu Feb 05 23:38:18 2009 +0000

description:
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:

 net/fetch/Makefile      |   4 ++--
 net/fetch/files/fetch.c |  22 ++++++++++++++--------
 2 files changed, 16 insertions(+), 10 deletions(-)

diffs (91 lines):

diff -r b9d2935d2801 -r 89a1e7044b2f net/fetch/Makefile
--- a/net/fetch/Makefile        Thu Feb 05 23:29:14 2009 +0000
+++ b/net/fetch/Makefile        Thu Feb 05 23:38:18 2009 +0000
@@ -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 -r b9d2935d2801 -r 89a1e7044b2f net/fetch/files/fetch.c
--- a/net/fetch/files/fetch.c   Thu Feb 05 23:29:14 2009 +0000
+++ b/net/fetch/files/fetch.c   Thu Feb 05 23:38:18 2009 +0000
@@ -125,12 +125,14 @@
 {
        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 @@
                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 @@
        }
 
        /* timed out or interrupted? */
+       if (fetchLastErrCode == FETCH_TIMEOUT)
+               sigalrm = 1;
        if (sigalrm)
                warnx("transfer timed out");
        if (sigint) {
@@ -704,12 +713,10 @@
        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 @@
        sigaction(SIGALRM, &sa, NULL);
        sa.sa_flags = SA_RESETHAND;
        sigaction(SIGINT, &sa, NULL);
-       fetchRestartCalls = 0;
 
        /* output file */
        if (o_flag) {



Home | Main Index | Thread Index | Old Index