public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:2.1.9 commit in: pym/_emerge/
Date: Fri, 18 Mar 2011 21:12:28 +0000 (UTC)	[thread overview]
Message-ID: <2f3235abef72d61cdcdf549a08e645933698a4ff.zmedico@gentoo> (raw)

commit:     2f3235abef72d61cdcdf549a08e645933698a4ff
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 17 21:39:53 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 18 19:50:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2f3235ab

EbuildIpcDaemon: use non-blocking write

This prevents the Scheduler from hanging if the client is killed before
we can send the reply, as reported by David James:

  http://codereview.chromium.org/6713003

This commit depends on ebuild-ipc (the client) opening the other side
of this fifo before it sends its request, which has already been added
in commit eff879ff0ce7dcc1ce68d5f16de1ec73051f8c18.

---
 pym/_emerge/EbuildIpcDaemon.py |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/pym/_emerge/EbuildIpcDaemon.py b/pym/_emerge/EbuildIpcDaemon.py
index efcda93..5dabe34 100644
--- a/pym/_emerge/EbuildIpcDaemon.py
+++ b/pym/_emerge/EbuildIpcDaemon.py
@@ -1,9 +1,12 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
+import logging
 import pickle
 from portage import os
+from portage.localization import _
+from portage.util import writemsg_level
 from _emerge.FifoIpcDaemon import FifoIpcDaemon
 from _emerge.PollConstants import PollConstants
 
@@ -83,7 +86,23 @@ class EbuildIpcDaemon(FifoIpcDaemon):
 
 	def _send_reply(self, reply):
 		# File streams are in unbuffered mode since we do atomic
-		# read and write of whole pickles.
-		output_file = open(self.output_fifo, 'wb', 0)
-		output_file.write(pickle.dumps(reply))
-		output_file.close()
+		# read and write of whole pickles. Use non-blocking mode so
+		# we don't hang if the client is killed before we can send
+		# the reply. We rely on the client opening the other side
+		# of this fifo before it sends its request, since otherwise
+		# we'd have a race condition with this open call raising
+		# ENXIO if the client hasn't opened the fifo yet.
+		try:
+			output_fd = os.open(self.output_fifo,
+				os.O_WRONLY | os.O_NONBLOCK)
+			try:
+				os.write(output_fd, pickle.dumps(reply))
+			finally:
+				os.close(output_fd)
+		except OSError as e:
+			# This probably means that the client has been killed,
+			# which causes open to fail with ENXIO.
+			writemsg_level(
+				"!!! EbuildIpcDaemon %s: %s\n" % \
+				(_('failed to send reply'), e),
+				level=logging.ERROR, noiselevel=-1)



             reply	other threads:[~2011-03-18 21:13 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 21:12 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-05-27  3:36 [gentoo-commits] proj/portage:2.1.9 commit in: pym/_emerge/ Zac Medico
2011-05-27  1:26 Zac Medico
2011-05-27  0:40 Zac Medico
2011-05-26 22:34 Zac Medico
2011-05-26 21:37 Zac Medico
2011-05-26 13:04 Zac Medico
2011-05-26 12:52 Zac Medico
2011-05-26 12:26 Zac Medico
2011-05-26 12:05 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-26  6:18 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-12  5:24 Zac Medico
2011-05-08 20:50 Zac Medico
2011-05-08 20:50 Zac Medico
2011-05-08 20:50 Zac Medico
2011-05-08 20:50 Zac Medico
2011-05-08 20:50 Zac Medico
2011-05-05 18:12 Zac Medico
2011-05-05 16:01 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-05-04 20:03 Zac Medico
2011-04-13  7:52 Zac Medico
2011-04-13  7:52 Zac Medico
2011-04-13  7:52 Zac Medico
2011-04-13  7:52 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-26 19:31 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-18 21:12 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-14 16:24 Zac Medico
2011-03-01 21:54 Zac Medico
2011-03-01 20:55 Zac Medico
2011-03-01 20:55 Zac Medico
2011-03-01 20:55 Zac Medico
2011-02-22 17:41 Zac Medico
2011-02-22  3:16 Zac Medico
2011-02-22  3:14 Zac Medico
2011-02-22  3:14 Zac Medico
2011-02-22  3:14 Zac Medico
2011-02-22  3:14 Zac Medico
2011-02-22  3:14 Zac Medico
2011-02-22  3:14 Zac Medico
2011-02-20  0:04 Zac Medico
2011-02-20  0:04 Zac Medico
2011-02-20  0:04 Zac Medico
2011-02-20  0:04 Zac Medico
2011-02-20  0:04 Zac Medico
2011-02-20  0:04 Zac Medico
2011-02-14 17:02 Zac Medico
2011-02-14 16:45 Zac Medico
2011-02-14 16:35 Zac Medico
2011-02-14 16:04 Zac Medico
2011-02-14  7:49 Zac Medico
2011-02-14  7:49 Zac Medico
2011-02-14  7:49 Zac Medico
2011-02-14  7:49 Zac Medico
2011-02-14  7:49 Zac Medico
2011-02-14  5:04 Zac Medico
2011-02-14  4:31 Zac Medico
2011-02-14  4:31 Zac Medico
2011-02-14  4:31 Zac Medico
2011-02-14  4:31 Zac Medico
2011-02-14  4:31 Zac Medico
2011-02-08 20:48 Zac Medico
2011-02-05  3:37 Zac Medico
2011-02-04 17:47 zmedico
2011-02-04 15:57 zmedico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f3235abef72d61cdcdf549a08e645933698a4ff.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox