From 9b42b44628726615fafe2b7e145cf73acc7cdd66 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 24 Mar 2009 15:35:06 +0000 Subject: (install) fix a circular reference that was causing rpmdb to be opened many times in installer (regression introduced in r253510 when adding new callbacks for the installer) --- urpm/install.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'urpm') diff --git a/urpm/install.pm b/urpm/install.pm index c57688b6..4faab2db 100644 --- a/urpm/install.pm +++ b/urpm/install.pm @@ -224,17 +224,21 @@ sub install { my $fh; #- assume default value for some parameter. $options{delta} ||= 1000; + + #- ensure perl does not create a circular reference below, otherwise all this won't be collected, + # and rpmdb won't be closed: + my ($callback_open_helper, $callback_close_helper) = ($options{callback_open_helper}, $options{callback_close_helper}); $options{callback_open} = sub { my ($_data, $_type, $id) = @_; $index++; - $options{callback_open_helper} and $options{callback_open_helper}->(@_); + $callback_open_helper and $callback_open_helper->(@_); $fh = urpm::sys::open_safe($urpm, '<', $install->{$id} || $upgrade->{$id}); $fh ? fileno $fh : undef; }; $options{callback_close} = sub { my ($urpm, undef, $pkgid) = @_; return unless defined $pkgid; - $options{callback_close_helper} and $options{callback_close_helper}->($db, @_); + $callback_close_helper and $callback_close_helper->($db, @_); get_README_files($urpm, $trans, $urpm->{depslist}[$pkgid]); close $fh if defined $fh; }; -- cgit v1.2.1