1 |
commit: cdf04882ce380579814b9cfe63ee593dbfba5ef9 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 27 06:09:27 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 27 06:09:27 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cdf04882 |
7 |
|
8 |
MergeProcess: add fallback setcpv call |
9 |
|
10 |
It's important that this metadata access happens in the parent process, |
11 |
since closing of file descriptors in the subprocess can prevent access |
12 |
to open database connections such as that used by the sqlite metadata |
13 |
cache module. |
14 |
|
15 |
--- |
16 |
pym/portage/dbapi/_MergeProcess.py | 22 +++++++++++++++++++--- |
17 |
1 files changed, 19 insertions(+), 3 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py |
20 |
index ea7c3e6..afb2e08 100644 |
21 |
--- a/pym/portage/dbapi/_MergeProcess.py |
22 |
+++ b/pym/portage/dbapi/_MergeProcess.py |
23 |
@@ -30,6 +30,21 @@ class MergeProcess(SpawnProcess): |
24 |
'_buf', '_elog_keys') |
25 |
|
26 |
def _start(self): |
27 |
+ # Portage should always call setcpv prior to this |
28 |
+ # point, but here we have a fallback as a convenience |
29 |
+ # for external API consumers. It's important that |
30 |
+ # this metadata access happens in the parent process, |
31 |
+ # since closing of file descriptors in the subprocess |
32 |
+ # can prevent access to open database connections such |
33 |
+ # as that used by the sqlite metadata cache module. |
34 |
+ cpv = "%s/%s" % (self.mycat, self.mypkg) |
35 |
+ settings = self.settings |
36 |
+ if cpv != settings.mycpv or \ |
37 |
+ "IUSE" not in settings.configdict["pkg"]: |
38 |
+ settings.reload() |
39 |
+ settings.reset() |
40 |
+ settings.setcpv(cpv, mydb=self.mydbapi) |
41 |
+ |
42 |
self._handle_self_reinstall() |
43 |
super(MergeProcess, self)._start() |
44 |
|
45 |
@@ -116,9 +131,10 @@ class MergeProcess(SpawnProcess): |
46 |
fcntl.fcntl(elog_reader_fd, fcntl.F_GETFL) | os.O_NONBLOCK) |
47 |
blockers = None |
48 |
if self.blockers is not None: |
49 |
- # Query blockers in the main process, since metadata cache |
50 |
- # queries may not work for some databases from within a |
51 |
- # subprocess. For example, sqlite is known to misbehave. |
52 |
+ # Query blockers in the main process, since closing |
53 |
+ # of file descriptors in the subprocess can prevent |
54 |
+ # access to open database connections such as that |
55 |
+ # used by the sqlite metadata cache module. |
56 |
blockers = self.blockers() |
57 |
mylink = self.dblink(self.mycat, self.mypkg, settings=self.settings, |
58 |
treetype=self.treetype, vartree=self.vartree, |