From 3ecf5ca92ac64ee29934d6f8ce0b3d62cc3f6fb9 Mon Sep 17 00:00:00 2001 From: espie Date: Sat, 31 Jul 2010 11:17:22 +0000 Subject: [PATCH] keep location open while we grab updateinfo. deal with error fallout and need to forget unneeded stuff (halves number of connections, roughly) --- usr.sbin/pkg_add/OpenBSD/Handle.pm | 16 ++++++++-------- usr.sbin/pkg_add/OpenBSD/PackageLocation.pm | 11 +++++++++-- usr.sbin/pkg_add/OpenBSD/Update.pm | 5 ++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/Handle.pm b/usr.sbin/pkg_add/OpenBSD/Handle.pm index b2d7c495608..ea7e06e7bd8 100644 --- a/usr.sbin/pkg_add/OpenBSD/Handle.pm +++ b/usr.sbin/pkg_add/OpenBSD/Handle.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Handle.pm,v 1.23 2010/06/30 10:51:04 espie Exp $ +# $OpenBSD: Handle.pm,v 1.24 2010/07/31 11:17:22 espie Exp $ # # Copyright (c) 2007-2009 Marc Espie # @@ -38,12 +38,12 @@ sub cleanup $self->{error} //= $error; $self->{errorinfo} //= $errorinfo; if (defined $self->location) { - if (defined $self->{error} && - $self->{error} == ALREADY_INSTALLED) { - $self->location->close_now; - } elsif (defined $self->{error} && - $self->{error} == CANT_INSTALL) { - $self->location->close_with_client_error; + if (defined $self->{error}) { + if ($self->{error} == BAD_PACKAGE) { + $self->location->close_with_client_error; + } else { + $self->location->close_now; + } } $self->location->wipe_info; } @@ -185,7 +185,7 @@ sub get_plist if ($state->verbose >= 2) { $state->say("#1parsing #2", $state->deptree_header($pkg), $pkg); } - my $plist = $location->grabPlist; + my $plist = $location->plist; unless (defined $plist) { $state->say("Can't find CONTENTS from #1", $location->url); $location->close_with_client_error; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm index d6cb3cd9500..201e866ec0a 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocation.pm,v 1.23 2010/07/28 12:19:54 espie Exp $ +# $OpenBSD: PackageLocation.pm,v 1.24 2010/07/31 11:17:22 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -66,7 +66,7 @@ OpenBSD::Auto::cache(pkgname, OpenBSD::Auto::cache(update_info, sub { my $self = shift; - return $self->grabPlist(\&OpenBSD::PackingList::UpdateInfoOnly); + return $self->plist(\&OpenBSD::PackingList::UpdateInfoOnly); }); @@ -204,6 +204,13 @@ sub grabPlist } } +sub forget +{ + my $self = shift; + $self->wipe_info; + $self->close_now; +} + sub wipe_info { my $self = shift; diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 9b193a47bfb..1d7dbdaae3b 100644 --- a/usr.sbin/pkg_add/OpenBSD/Update.pm +++ b/usr.sbin/pkg_add/OpenBSD/Update.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Update.pm,v 1.143 2010/07/26 23:28:06 espie Exp $ +# $OpenBSD: Update.pm,v 1.144 2010/07/31 11:17:22 espie Exp $ # # Copyright (c) 2004-2010 Marc Espie # @@ -158,6 +158,7 @@ sub process_handle } if ($p2->has('arch')) { unless ($p2->{arch}->check($state->{arch})) { + $loc->forget; next; } } @@ -168,12 +169,14 @@ sub process_handle my $r = $plist->signature->compare($p2->signature); if (defined $r && $r > 0 && !$state->defines('downgrade')) { $oldfound = 1; + $loc->forget; next; } if ($plist->match_pkgpath($p2)) { push(@l2, $loc); next } + $loc->forget; } return \@l2; })); -- 2.20.1