Package portage :: Module locks
[hide private]

Module locks

source code

Functions [hide private]
 
lockdir(mydir) source code
 
unlockdir(mylock) source code
 
lockfile(mypath, wantnewlockfile=0, unlinkfile=0, waiting_msg=None, flags=0)
Creates all dirs upto, the given dir.
source code
Integer
_fstat_nlink(fd)
Returns: the current number of hardlinks to the file
source code
 
unlockfile(mytuple) source code
 
hardlock_name(path) source code
 
hardlink_is_mine(link, lock) source code
 
hardlink_lockfile(lockfilename, max_wait=14400)
Does the NFS, hardlink shuffle to ensure locking on the disk.
source code
 
unhardlink_lockfile(lockfilename) source code
 
hardlock_cleanup(path, remove_all_locks=False) source code
Variables [hide private]
  HARDLINK_FD = -2
  _quiet = False

Imports: errno, os, stat, time, types, DirectoryNotFound, FileNotFound, InvalidData, TryAgain, portage_gid, writemsg, _


Function Details [hide private]

lockfile(mypath, wantnewlockfile=0, unlinkfile=0, waiting_msg=None, flags=0)

source code 

Creates all dirs upto, the given dir. Creates a lockfile for the given directory as the file: directoryname+'.portage_lockfile'.

_fstat_nlink(fd)

source code 
Parameters:
  • fd (Integer) - an open file descriptor
Returns: Integer
the current number of hardlinks to the file

hardlink_lockfile(lockfilename, max_wait=14400)

source code 

Does the NFS, hardlink shuffle to ensure locking on the disk. We create a PRIVATE lockfile, that is just a placeholder on the disk. Then we HARDLINK the real lockfile to that private file. If our file can 2 references, then we have the lock. :) Otherwise we lather, rise, and repeat. We default to a 4 hour timeout.