summaryrefslogtreecommitdiffstats
path: root/urpm/sys.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-23 10:49:51 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-23 10:49:51 +0000
commit6aed7e5429cab61514fe2eb3cacad3d11462cd5f (patch)
tree514c973cd20132c03770c87eca82ab248e10446b /urpm/sys.pm
parent0bf8f352836b0e1b584638789558246871912a87 (diff)
downloadurpmi-6aed7e5429cab61514fe2eb3cacad3d11462cd5f.tar
urpmi-6aed7e5429cab61514fe2eb3cacad3d11462cd5f.tar.gz
urpmi-6aed7e5429cab61514fe2eb3cacad3d11462cd5f.tar.bz2
urpmi-6aed7e5429cab61514fe2eb3cacad3d11462cd5f.tar.xz
urpmi-6aed7e5429cab61514fe2eb3cacad3d11462cd5f.zip
- move lock functions to a full blown module
- handle get_exclusive and release_exclusive on existing lock, *but* don't use it for now! (not useful) - remove urpmi_db locking from add_medium and update_media - move rpm_db locking into _read_cachedir_pubkey - update_media: restrict rpm_db exclusive locking to parse_pubkeys - urpmi: move locking rpm_db near its use - handle lock directly in urpmi.addmedia, urpmi.update, urpme, urpmf - log locking/unlocking
Diffstat (limited to 'urpm/sys.pm')
-rw-r--r--urpm/sys.pm44
1 files changed, 0 insertions, 44 deletions
diff --git a/urpm/sys.pm b/urpm/sys.pm
index a6fb4fa7..2a35b3af 100644
--- a/urpm/sys.pm
+++ b/urpm/sys.pm
@@ -190,50 +190,6 @@ sub clean_dir {
mkdir $dir, 0755;
}
-#- lock policy concerning chroot :
-# - lock rpm db in chroot
-# - lock urpmi db in /
-sub _lock {
- my ($urpm, $file, $msg, $b_exclusive) = @_;
-# warn "locking $file $b_exclusive\n";
- #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
- my ($LOCK_SH, $LOCK_EX, $LOCK_NB) = (1, 2, 4);
- if ($b_exclusive) {
- #- lock urpmi database, but keep lock to wait for an urpmi.update to finish.
- } else {
- #- create the .LOCK file if needed (and if possible)
- -e $file or open(my $_f, ">", $file);
-
- #- lock urpmi database, if the LOCK file doesn't exists no share lock.
- }
- my ($sense, $mode) = $b_exclusive ? ('>', $LOCK_EX) : ('<', $LOCK_SH);
- open(my $fh, $sense, $file) or return;
- flock $fh, $mode|$LOCK_NB or $urpm->{fatal}(7, $msg);
-# warn "locked $file $b_exclusive ($fh)\n";
- $fh;
-}
-
-
-sub lock_rpm_db {
- my ($urpm, $b_exclusive) = @_;
- _lock($urpm, "$urpm->{root}/$urpm->{statedir}/.RPMLOCK", N("rpm database locked"), $b_exclusive);
-}
-sub lock_urpmi_db {
- my ($urpm, $b_exclusive) = @_;
- _lock($urpm, "$urpm->{statedir}/.LOCK", N("urpmi database locked"), $b_exclusive);
-}
-
-sub unlock {
- my ($fh) = @_;
-# warn "unlocking $fh\n";
- #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
- my $LOCK_UN = 8;
- #- now everything is finished.
- #- release lock on database.
- flock $fh, $LOCK_UN;
- close $fh;
-}
-
sub syserror {
my ($urpm, $msg, $info) = @_;
$urpm->{error}("$msg [$info] [$!]");