[Yum-devel] [PATCH] Fix locking issue. BZ 865601
Zdenek Pavlas
zpavlas at redhat.com
Mon Dec 17 09:17:41 UTC 2012
> LockError() in utils should certainly deal with non-zero errno (esp.
> EPERM, as that's thrown from a few paths) ... if both it and yummain
> should just treat all non-zero errno's as exit 1, I'm not sure. It
> seems sane at first thought.
Missed that in yummain, we already have:
except Errors.LockError, e:
if e.errno in (errno.EPERM, errno.EACCES, errno.ENOSPC):
logger.critical(_("Can't create lock file; exiting"))
return 1
Adding EINVAL to the list would indeed fix BZ 865601, but:
- This IF should be duplicated in YumUtilBase.waitForLock() (it isn't).
- Converting OSError to LockError seems redundant, and passing our
own PID as locker PID only to make sure it passes the "pid valid"
check is plain ugly.
IMO it would make more sense to catch EEXISTS in _lock(), re-raising
everything else. Updated patch:
commit f1ba4daf26a0882f574d05f0f5f90f3769b02b70
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date: Fri Dec 14 10:43:46 2012 +0100
Fix locking issue. BZ 865601
We should retry on EEXISTS only, all other errors are permanent.
LockError(pid=our_pid) only confuses the caller.
diff --git a/yummain.py b/yummain.py
index a11f26e..fefcd3f 100755
--- a/yummain.py
+++ b/yummain.py
@@ -124,14 +124,13 @@ def main(args):
while True:
try:
base.doLock()
+ except OSError, e:
+ logger.critical(_("Can't create lock file; exiting"))
+ return 1
except Errors.LockError, e:
if exception2msg(e) != lockerr:
lockerr = exception2msg(e)
logger.critical(lockerr)
- if e.errno in (errno.EPERM, errno.EACCES, errno.ENOSPC):
- logger.critical(_("Can't create lock file; exiting"))
- return 1
-
if not base.conf.exit_on_lock:
logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
show_lock_owner(e.pid, logger)
diff --git a/yum/__init__.py b/yum/__init__.py
index 2a82f97..68e3ed3 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2050,8 +2050,7 @@ much more problems).
except OSError, msg:
if not msg.errno == errno.EEXIST:
# Whoa. What the heck happened?
- errmsg = _('Could not create lock at %s: %s ') % (filename, str(msg))
- raise Errors.LockError(msg.errno, errmsg, int(contents))
+ raise
return 0
@staticmethod
diff --git a/utils.py b/utils.py
index e465cf7..321cbad 100755
--- a/utils.py
+++ b/utils.py
@@ -272,6 +272,9 @@ class YumUtilBase(YumBaseCli):
while True:
try:
self.doLock()
+ except OSError, e:
+ logger.critical(_("Can't create lock file; exiting"))
+ os.exit(1)
except Errors.LockError, e:
if exception2msg(e) != lockerr:
lockerr = exception2msg(e)
More information about the Yum-devel
mailing list