commit:     664684f0f17c0f3570ffd9382037994db1ec66bd
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 31 20:23:15 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 23:12:12 2015 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=664684f0

lockfile: handle EINTR for bug #538314

Use portage._eintr_func_wrapper to handle EINTR from fcntl.lockf. Since
fcntl.lockf raises IOError, make _eintr_func_wrapper handle
EnvironmentError (which both OSError and IOError inherit from).

X-Gentoo-Bug: 538314
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=538314
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/portage/__init__.py | 2 +-
 pym/portage/locks.py    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d96d733..1c85042 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -337,7 +337,7 @@ class _eintr_func_wrapper(object):
                        try:
                                rval = self._func(*args, **kwargs)
                                break
-                       except OSError as e:
+                       except EnvironmentError as e:
                                if e.errno != errno.EINTR:
                                        raise
 

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index fdfe4a5..42ff1e3 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -146,7 +146,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 
        # try for a non-blocking lock, if it's held, throw a message
        # we're waiting on lockfile and use a blocking attempt.
-       locking_method = _default_lock_fn
+       locking_method = portage._eintr_func_wrapper(_default_lock_fn)
        try:
                if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
                        raise IOError(errno.ENOSYS, "Function not implemented")

Reply via email to