From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7CC5C138331 for ; Sun, 22 Apr 2018 21:52:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5FB7FE0880; Sun, 22 Apr 2018 21:52:16 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 27745E0880 for ; Sun, 22 Apr 2018 21:52:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 396FF335C75 for ; Sun, 22 Apr 2018 21:52:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 94B1227F for ; Sun, 22 Apr 2018 21:52:12 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1524421852.30c69adfc0ffa450ff3a4d4d176023db66171ae7.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/AbstractEbuildProcess.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 30c69adfc0ffa450ff3a4d4d176023db66171ae7 X-VCS-Branch: master Date: Sun, 22 Apr 2018 21:52:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e209021c-d9eb-4238-b52c-939d5cae5405 X-Archives-Hash: 9e6a3cbf19f05a14bf1407bee8a91a3b commit: 30c69adfc0ffa450ff3a4d4d176023db66171ae7 Author: Zac Medico gentoo org> AuthorDate: Sat Apr 21 06:36:29 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Apr 22 18:30:52 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=30c69adf AbstractEbuildProcess: use async_lock (bug 614112) Asynchronously lock the build directory. The asynchronous lock delays creation of the pid, and it's possible for the _wait method to be called before the pid is available. Therefore, AbstractEbuildProcess._wait() must wait for the pid to become available before it can call the SpawnProcess._wait() method. Bug: https://bugs.gentoo.org/614112 pym/_emerge/AbstractEbuildProcess.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py index 2aa0c4a35..d481e6046 100644 --- a/pym/_emerge/AbstractEbuildProcess.py +++ b/pym/_emerge/AbstractEbuildProcess.py @@ -25,7 +25,7 @@ class AbstractEbuildProcess(SpawnProcess): __slots__ = ('phase', 'settings',) + \ ('_build_dir', '_build_dir_unlock', '_ipc_daemon', - '_exit_command', '_exit_timeout_id') + '_exit_command', '_exit_timeout_id', '_start_future') _phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',) _phases_interactive_whitelist = ('config',) @@ -130,15 +130,19 @@ class AbstractEbuildProcess(SpawnProcess): # since we're not displaying to a terminal anyway. self.settings['NOCOLOR'] = 'true' + start_ipc_daemon = False if self._enable_ipc_daemon: self.settings.pop('PORTAGE_EBUILD_EXIT_FILE', None) if self.phase not in self._phases_without_builddir: + start_ipc_daemon = True if 'PORTAGE_BUILDDIR_LOCKED' not in self.settings: self._build_dir = EbuildBuildDir( scheduler=self.scheduler, settings=self.settings) - self._build_dir.lock() - self.settings['PORTAGE_IPC_DAEMON'] = "1" - self._start_ipc_daemon() + self._start_future = self._build_dir.async_lock() + self._start_future.add_done_callback( + functools.partial(self._start_post_builddir_lock, + start_ipc_daemon=start_ipc_daemon)) + return else: self.settings.pop('PORTAGE_IPC_DAEMON', None) else: @@ -159,6 +163,19 @@ class AbstractEbuildProcess(SpawnProcess): else: self.settings.pop('PORTAGE_EBUILD_EXIT_FILE', None) + self._start_post_builddir_lock(start_ipc_daemon=start_ipc_daemon) + + def _start_post_builddir_lock(self, lock_future=None, start_ipc_daemon=False): + if lock_future is not None: + if lock_future is not self._start_future: + raise AssertionError('lock_future is not self._start_future') + self._start_future = None + lock_future.result() + + if start_ipc_daemon: + self.settings['PORTAGE_IPC_DAEMON'] = "1" + self._start_ipc_daemon() + if self.fd_pipes is None: self.fd_pipes = {} null_fd = None @@ -375,6 +392,11 @@ class AbstractEbuildProcess(SpawnProcess): Execution of the failsafe code will automatically become a fatal error at the same time as event loop recursion is disabled. """ + # SpawnProcess._wait() requires the pid, so wait here for the + # pid to become available. + while self._start_future is not None: + self.scheduler.run_until_complete(self._start_future) + SpawnProcess._wait(self) if self._build_dir is not None: