In unhardlink_lockfile(), make sure not to touch lockfilename unless we really have...
authorZac Medico <zmedico@gentoo.org>
Thu, 14 Sep 2006 06:33:48 +0000 (06:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 14 Sep 2006 06:33:48 +0000 (06:33 -0000)
svn path=/main/trunk/; revision=4446

pym/portage_locks.py

index 4a61f6312e9ff9797378ea757c4ee223703ba175..8e6a9803dcfd3c644b464b7320d829aa9a643a50 100644 (file)
@@ -271,13 +271,16 @@ def hardlink_lockfile(lockfilename, max_wait=14400):
 
 def unhardlink_lockfile(lockfilename):
        myhardlock = hardlock_name(lockfilename)
-       try:
-               if os.path.exists(myhardlock):
-                       os.unlink(myhardlock)
-               if os.path.exists(lockfilename):
+       if hardlink_is_mine(myhardlock, lockfilename):
+               # Make sure not to touch lockfilename unless we really have a lock.
+               try:
                        os.unlink(lockfilename)
+               except OSError:
+                       pass
+       try:
+               os.unlink(myhardlock)
        except OSError:
-               portage_util.writemsg("Something strange happened to our hardlink locks.\n")
+               pass
 
 def hardlock_cleanup(path, remove_all_locks=False):
        mypid  = str(os.getpid())