Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] lockfile: handle EINTR for bug #538314
Date: Sat, 31 Jan 2015 20:26:18
Message-Id: 1422735958-801-1-git-send-email-zmedico@gentoo.org
1 Use portage._eintr_func_wrapper to handle EINTR from fcntl.lockf. Since
2 fcntl.lockf raises IOError, make _eintr_func_wrapper handle
3 EnvironmentError (which both OSError and IOError inherit from).
4
5 X-Gentoo-Bug: 538314
6 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=538314
7 ---
8 pym/portage/__init__.py | 2 +-
9 pym/portage/locks.py | 2 +-
10 2 files changed, 2 insertions(+), 2 deletions(-)
11
12 diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
13 index d96d733..1c85042 100644
14 --- a/pym/portage/__init__.py
15 +++ b/pym/portage/__init__.py
16 @@ -337,7 +337,7 @@ class _eintr_func_wrapper(object):
17 try:
18 rval = self._func(*args, **kwargs)
19 break
20 - except OSError as e:
21 + except EnvironmentError as e:
22 if e.errno != errno.EINTR:
23 raise
24
25 diff --git a/pym/portage/locks.py b/pym/portage/locks.py
26 index fdfe4a5..42ff1e3 100644
27 --- a/pym/portage/locks.py
28 +++ b/pym/portage/locks.py
29 @@ -146,7 +146,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
30
31 # try for a non-blocking lock, if it's held, throw a message
32 # we're waiting on lockfile and use a blocking attempt.
33 - locking_method = _default_lock_fn
34 + locking_method = portage._eintr_func_wrapper(_default_lock_fn)
35 try:
36 if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
37 raise IOError(errno.ENOSYS, "Function not implemented")
38 --
39 2.0.5

Replies