From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RwS7B-000815-K2 for garchives@archives.gentoo.org; Sun, 12 Feb 2012 05:36:51 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A3335E0538; Sun, 12 Feb 2012 05:36:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 6D798E0538 for ; Sun, 12 Feb 2012 05:36:35 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D18621B400A for ; Sun, 12 Feb 2012 05:36:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 96D9FE5400 for ; Sun, 12 Feb 2012 05:36:33 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/EbuildIpcDaemon.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: c36768027d04f10f7af4402f642e93144d1b353b Date: Sun, 12 Feb 2012 05:36:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 45ee3632-6c39-4bf2-9a34-08861e6e0ad9 X-Archives-Hash: 0deeadd03823dd78b8c848d5b1663611 commit: c36768027d04f10f7af4402f642e93144d1b353b Author: Zac Medico gentoo org> AuthorDate: Sun Feb 12 05:36:18 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Feb 12 05:36:18 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dc3676802 EbuildIpcDaemon: handle POLLHUP, bug #401919 --- pym/_emerge/EbuildIpcDaemon.py | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/pym/_emerge/EbuildIpcDaemon.py b/pym/_emerge/EbuildIpcDaemon= .py index 5795bfb..8414d20 100644 --- a/pym/_emerge/EbuildIpcDaemon.py +++ b/pym/_emerge/EbuildIpcDaemon.py @@ -5,7 +5,9 @@ import errno import logging import pickle from portage import os +from portage.exception import TryAgain from portage.localization import _ +from portage.locks import lockfile, unlockfile from portage.util import writemsg_level from _emerge.FifoIpcDaemon import FifoIpcDaemon =20 @@ -83,6 +85,28 @@ class EbuildIpcDaemon(FifoIpcDaemon): if reply_hook is not None: reply_hook() =20 + elif event & self.scheduler.IO_HUP: + # This can be triggered due to a race condition which happens when + # the previous _reopen_input() call occurs before the writer has + # closed the pipe (see bug #401919). It's not safe to re-open + # without a lock here, since it's possible that another writer will + # write something to the pipe just before we close it, and in that + # case the write will be lost. Therefore, try for a non-blocking + # lock, and only re-open the pipe if the lock is acquired. + lock_filename =3D os.path.join( + os.path.dirname(self.input_fifo), '.ipc_lock') + try: + lock_obj =3D lockfile(lock_filename, unlinkfile=3DTrue, + flags=3Dos.O_NONBLOCK) + except TryAgain: + # We'll try again when another IO_HUP event arrives. + pass + else: + try: + self._reopen_input() + finally: + unlockfile(lock_obj) + return True =20 def _send_reply(self, reply):