|
|
5e9bef |
commit ffb40e6a1b9c3f4b5b08151a04a5922fc5a9b521
|
|
|
5e9bef |
Author: James Antill <james@and.org>
|
|
|
5e9bef |
Date: Wed Jan 29 16:04:18 2014 -0500
|
|
|
5e9bef |
|
|
|
5e9bef |
Don't create lockdir directories, as they are magic now. BZ 975864
|
|
|
5e9bef |
|
|
|
5e9bef |
diff --git a/yum/__init__.py b/yum/__init__.py
|
|
|
5e9bef |
index 222a378..0604d63 100644
|
|
|
5e9bef |
--- a/yum/__init__.py
|
|
|
5e9bef |
+++ b/yum/__init__.py
|
|
|
5e9bef |
@@ -2136,7 +2136,11 @@ much more problems).
|
|
|
5e9bef |
lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
|
|
|
5e9bef |
|
|
|
5e9bef |
mypid=str(os.getpid())
|
|
|
5e9bef |
- while not self._lock(lockfile, mypid, 0644):
|
|
|
5e9bef |
+ while True:
|
|
|
5e9bef |
+ ret = self._lock(lockfile, mypid, 0644)
|
|
|
5e9bef |
+ if ret:
|
|
|
5e9bef |
+ break
|
|
|
5e9bef |
+
|
|
|
5e9bef |
oldpid = self._get_locker(lockfile)
|
|
|
5e9bef |
if not oldpid:
|
|
|
5e9bef |
# Invalid locker: unlink lockfile and retry
|
|
|
5e9bef |
@@ -2147,6 +2151,13 @@ much more problems).
|
|
|
5e9bef |
# Another copy seems to be running.
|
|
|
5e9bef |
msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
|
|
|
5e9bef |
raise Errors.LockError(0, msg, oldpid)
|
|
|
5e9bef |
+
|
|
|
5e9bef |
+ if ret == 2:
|
|
|
5e9bef |
+ # Means lockdir isn't setup, out of bad options just run without
|
|
|
5e9bef |
+ # locks.
|
|
|
5e9bef |
+ return
|
|
|
5e9bef |
+
|
|
|
5e9bef |
+ assert ret == 1
|
|
|
5e9bef |
# We've got the lock, store it so we can auto-unlock on __del__...
|
|
|
5e9bef |
self._lockfile = lockfile
|
|
|
5e9bef |
|
|
|
5e9bef |
@@ -2186,7 +2197,12 @@ much more problems).
|
|
|
5e9bef |
lockdir = os.path.dirname(filename)
|
|
|
5e9bef |
try:
|
|
|
5e9bef |
if not os.path.exists(lockdir):
|
|
|
5e9bef |
- os.makedirs(lockdir, mode=0755)
|
|
|
5e9bef |
+ # We used to os.makedirs(lockdir, mode=0755) ... but that
|
|
|
5e9bef |
+ # causes problems now due to /var/run being a magic systemd dir.
|
|
|
5e9bef |
+ # So we now just give up and run, hopefully nobody runs N
|
|
|
5e9bef |
+ # instances before the magic dir. is activate.
|
|
|
5e9bef |
+ return 2
|
|
|
5e9bef |
+
|
|
|
5e9bef |
fd = os.open(filename, os.O_EXCL|os.O_CREAT|os.O_WRONLY, mode)
|
|
|
5e9bef |
os.write(fd, contents)
|
|
|
5e9bef |
os.close(fd)
|