[yum-commits] Branch 'yum-3_2_X' - 3 commits - Makefile yum/config.py yum/__init__.py
James Antill
james at osuosl.org
Tue Oct 18 13:53:05 UTC 2011
Makefile | 6 +++++
yum/__init__.py | 65 ++++++++++++++++++++++++++++++++------------------------
yum/config.py | 2 -
3 files changed, 45 insertions(+), 28 deletions(-)
New commits:
commit 8be89ce433b44e8049f860bdf6ef6e4561fef63c
Author: James Antill <james at and.org>
Date: Tue Oct 18 09:52:57 2011 -0400
Do complete automated transifx target.
diff --git a/Makefile b/Makefile
index 0622bbe..f73239b 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,12 @@ transifex-push:
tx push -s -t
@echo "You can now git commit -a -m 'Transfix push, yum.pot update'"
+transifex:
+ make transifex-pull
+ git commit -a -m 'Transfix pull, *.po update'
+ make transifex-push
+ git commit -a -m 'Transfix push, yum.pot update'
+
.PHONY: docs test
DOCS = yum rpmUtils callback.py yumcommands.py shell.py output.py cli.py utils.py\
commit 6bc9e3a76f4e06c5bd0d40891edad75d2164c8c9
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Tue Oct 18 11:00:55 2011 +0200
Ignore lock held by a zombie process. BZ 746004, 745281.
add _get_locker() method that reads and verifies pidfile.
make _lock, _unlock, _get_locker static methods.
diff --git a/yum/__init__.py b/yum/__init__.py
index 3ede145..b07bbb2 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1890,32 +1890,16 @@ class YumBase(depsolve.Depsolve):
mypid=str(os.getpid())
while not self._lock(lockfile, mypid, 0644):
- try:
- fd = open(lockfile, 'r')
- except (IOError, OSError), e:
- msg = _("Could not open lock %s: %s") % (lockfile, e)
- raise Errors.LockError(errno.EPERM, msg)
-
- try: oldpid = int(fd.readline())
- except ValueError:
- # bogus data in the pid file. Throw away.
+ oldpid = self._get_locker(lockfile)
+ if not oldpid:
+ # Invalid locker: unlink lockfile and retry
self._unlock(lockfile)
- else:
- if oldpid == os.getpid(): # if we own the lock, we're fine
- break
- try: os.kill(oldpid, 0)
- except OSError, e:
- if e[0] == errno.ESRCH:
- # The pid doesn't exist
- self._unlock(lockfile)
- else:
- # Whoa. What the heck happened?
- msg = _('Unable to check if PID %s is active') % oldpid
- raise Errors.LockError(errno.EPERM, msg, oldpid)
- else:
- # Another copy seems to be running.
- msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
- raise Errors.LockError(0, msg, oldpid)
+ continue
+ if oldpid == os.getpid(): # if we own the lock, we're fine
+ break
+ # Another copy seems to be running.
+ msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
+ raise Errors.LockError(0, msg, oldpid)
# We've got the lock, store it so we can auto-unlock on __del__...
self._lockfile = lockfile
@@ -1950,7 +1934,8 @@ class YumBase(depsolve.Depsolve):
self._unlock(lockfile)
self._lockfile = None
- def _lock(self, filename, contents='', mode=0777):
+ @staticmethod
+ def _lock(filename, contents='', mode=0777):
lockdir = os.path.dirname(filename)
try:
if not os.path.exists(lockdir):
@@ -1966,9 +1951,35 @@ class YumBase(depsolve.Depsolve):
raise Errors.LockError(msg.errno, errmsg, int(contents))
return 0
- def _unlock(self, filename):
+ @staticmethod
+ def _unlock(filename):
misc.unlink_f(filename)
+ @staticmethod
+ def _get_locker(lockfile):
+ try: fd = open(lockfile, 'r')
+ except (IOError, OSError), e:
+ msg = _("Could not open lock %s: %s") % (lockfile, e)
+ raise Errors.LockError(errno.EPERM, msg)
+ try: oldpid = int(fd.readline())
+ except ValueError:
+ return None # Bogus pid
+
+ try:
+ stat = open("/proc/%d/stat" % oldpid).readline()
+ if stat.split()[2] == 'Z':
+ return None # The pid is a zombie
+ except IOError:
+ # process dead or /proc not mounted
+ try: os.kill(oldpid, 0)
+ except OSError, e:
+ if e[0] == errno.ESRCH:
+ return None # The pid doesn't exist
+ # Whoa. What the heck happened?
+ msg = _('Unable to check if PID %s is active') % oldpid
+ raise Errors.LockError(errno.EPERM, msg, oldpid)
+ return oldpid
+
def verifyPkg(self, fo, po, raiseError):
"""Check that the checksum of a remote package matches what we
expect it to be. If the checksum of the package file is
commit 5d7b311e71b0925f4a07bf4ae3c83ccf517034a7
Author: James Antill <james at and.org>
Date: Tue Oct 18 09:51:12 2011 -0400
Turn reset_nice on by default, works around BZ 552279, 742363.
diff --git a/yum/config.py b/yum/config.py
index f9789de..bff59e4 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -720,7 +720,7 @@ class YumConf(StartupConf):
"""
retries = PositiveIntOption(10, names_of_0=["<forever>"])
recent = IntOption(7, range_min=0)
- reset_nice = BoolOption(False)
+ reset_nice = BoolOption(True)
cachedir = Option('/var/cache/yum')
More information about the Yum-commits
mailing list