From abdf7e6c46f7173ea81b197d694b2f9e759cd4f1 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 14 Oct 2009 15:18:58 -0700 Subject: [PATCH] Don't try to yum list if locked --- package-updates/package-updates-lib.pl | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/package-updates/package-updates-lib.pl b/package-updates/package-updates-lib.pl index ea9a7bf1d..c42abcab7 100644 --- a/package-updates/package-updates-lib.pl +++ b/package-updates/package-updates-lib.pl @@ -60,7 +60,9 @@ else { sub list_available { local ($nocache) = @_; -if ($nocache || &cache_expired($available_cache_file)) { +local $expired = &cache_expired($available_cache_file); +if ($nocache || $expired == 2 || + $expired == 1 && !&check_available_lock()) { # Get from update system local @rv; local @avail = &packages_available(); @@ -88,6 +90,16 @@ else { } } +# check_available_lock() +# Returns 1 if the package update system is currently locked +sub check_available_lock +{ +if ($software::update_system eq "yum") { + return &check_pid_file("/var/run/yum.pid"); + } +return 0; +} + # filter_duplicates(&packages) # Given a list of package structures, orders them by name and version number, # and removes dupes with the same name @@ -100,16 +112,19 @@ local %done; return grep { !$done{$_->{'name'},$_->{'system'}}++ } @rv; } -sub cache_expired +# cache_expired(file) +# Checks if some cache has expired. Returns 0 if OK, 1 if expired, 2 if +# totally missing. +sub cache_expired { local ($file) = @_; local @st = stat($file); -if (!@st || !$config{'cache_time'} || - time()-$st[9] > $config{'cache_time'}*60*60) { - return 1; - } -return 0; -} +return 2 if (!@st); +if (!$config{'cache_time'} || time()-$st[9] > $config{'cache_time'}*60*60) { + return 1; + } +return 0; +} sub write_cache_file {