diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-10-22 17:44:08 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-10-22 17:44:08 +0000 |
commit | 97b9bf2b91e2abaa1c4aa744622929d36f76b503 (patch) | |
tree | de0ccf6ef8df14d389900be4525e0f9484e71029 /usr.sbin | |
parent | 11a93889d733e42af43da4b119a8e69a9116d639 (diff) |
add a hint to close that says how the fd got closed (real error, premature,
normal).
This will get used by parse_problems() to figure out what to report exactly,
e.g., short writes from prematurely closed fd are not real errors...
stuff that can't connect IPv6 and retries as v4 is not either, unless
there's a genuine `can't connect error'.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 45 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 4 |
2 files changed, 33 insertions, 16 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index 60bfab52171..209b51c1d03 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.44 2005/10/22 15:00:47 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.45 2005/10/22 17:44:07 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -76,11 +76,15 @@ sub opened undef; } +# hint: 0 premature close, 1 real error. undef, normal ! + sub close { - my ($self, $object) = @_; + my ($self, $object, $hint) = @_; close($object->{fh}) if defined $object->{fh}; - $self->parse_problems($object->{errors}) if defined $object->{errors}; + $self->parse_problems($object->{errors}, $hint) + if defined $object->{errors}; + undef $object->{errors}; $object->deref(); } @@ -97,7 +101,7 @@ sub make_room } while (@$already >= $self->maxcount()) { my $o = shift @$already; - $self->close($o); + $self->close($o, 0); } } return $already; @@ -143,22 +147,34 @@ sub grabPlist sub parse_problems { - my ($self, $filename) = @_; - CORE::open(my $fh, '<', $filename); + my ($self, $filename, $hint) = @_; + CORE::open(my $fh, '<', $filename) or return; + my $baseurl = $self->{baseurl}; local $_; + my $notyet = 1; while(<$fh>) { next if m/^(?:200|220|221|226|230|227|250|331|500|150)[\s\-]/; next if m/^EPSV command not understood/; - next if m/^Trying [\d\.\:]+\.\.\./; + next if m/^Trying [\da-f\.\:]+\.\.\./; next if m/^Requesting \Q$baseurl\E/; next if m/^Remote system type is\s+/; next if m/^Connected to\s+/; next if m/^remote\:\s+/; next if m/^Using binary mode to transfer files/; next if m/^Retrieving\s+/; - next if m/^\d+\s+bytes received in/; - print STDERR "Error from $baseurl:\n", $_; + next if m/^\d+\s+bytes\s+received\s+in/; + next if m/^ftp: connect to address.*: No route to host/; + + if (defined $hint && $hint == 0) { + next if m/^ftp: -: short write/; + next if m/^421\s+/; + } + if ($notyet) { + print STDERR "Error from $baseurl:\n" if $notyet; + $notyet = 0; + } + print STDERR $_; } CORE::close($fh); unlink $filename; @@ -598,6 +614,7 @@ sub openArchive if (!defined $fh) { $self->{repository}->parse_problems($self->{errors}) if defined $self->{errors}; + undef $self->{errors}; return undef; } require OpenBSD::Ustar; @@ -671,7 +688,7 @@ sub grabPlist if (defined $pkg) { my $plist = $self->plist($code); $pkg->wipe_info(); - $pkg->close(); + $pkg->close(0); return $plist; } else { return undef; @@ -714,7 +731,7 @@ sub openPackage } } # hopeless - $self->close(); + $self->close(1); $self->wipe_info(); return undef; } @@ -748,15 +765,15 @@ sub plist $code); } # hopeless - $self->close(); + $self->close(1); return undef; } sub close { - my $self = shift; - $self->{repository}->close($self); + my ($self, $hint) = @_; + $self->{repository}->close($self, $hint); } sub deref diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 74767dcc1b7..14200634c12 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.207 2005/10/22 15:01:54 espie Exp $ +# $OpenBSD: pkg_add,v 1.208 2005/10/22 17:44:07 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -672,7 +672,7 @@ sub find_updates if (!$handle) { next; } - $handle->close(); + $handle->close(0); my $p2 = $handle->plist(\&OpenBSD::PackingList::UpdateInfoOnly); if (!$p2) { next; |