From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: pi+piham Delivered-To: pi+piham@dcvr.yhbt.net Received: by dcvr.yhbt.net (Postfix, from userid 1000) id 847381F5F1; Sat, 18 Oct 2014 10:28:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-4.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: normalperson@yhbt.net Delivered-To: ew@dcvr.yhbt.net Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 713621F5F1 for ; Sat, 18 Oct 2014 10:18:49 +0000 (UTC) Received: from localhost ([::1]:36180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfR60-0003sF-Ft for normalperson@yhbt.net; Sat, 18 Oct 2014 06:18:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfR5t-0003ry-7C for dtas-all@nongnu.org; Sat, 18 Oct 2014 06:18:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfR5n-0006Bi-0u for dtas-all@nongnu.org; Sat, 18 Oct 2014 06:18:41 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:51921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfR5m-0006Bc-RA for dtas-all@nongnu.org; Sat, 18 Oct 2014 06:18:34 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1CAC61F5DC; Sat, 18 Oct 2014 10:18:33 +0000 (UTC) Date: Sat, 18 Oct 2014 10:18:32 +0000 From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH] unix_server: fix for infinite loop Message-ID: <20141018101832.GA11977@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 64.71.152.64 X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: everything related to dtas List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+normalperson=yhbt.net@nongnu.org Sender: dtas-all-bounces+normalperson=yhbt.net@nongnu.org Occasionally, killing a sink from an external process could result in an infinite loop due to the lack of close notification from __dst_error (in DTAS::Buffer) up to the top-level event loop. Since it is not easy to notify the top-level event loop, we'll detect closed IOs after-the-fact and retry as needed in a cold rescue path. This fixes an occasional error (usually when using a non-parallel make) in the test suite: TestPlayerIntegration#test_sink_killed_during_play: Timeout::Error: execution expired $HOME/dtas/test/player_integration.rb:57:in `sleep' $HOME/dtas/test/player_integration.rb:57:in `block in wait_pid_dead' $HOME/$RUBY/lib/ruby/2.2.0/timeout.rb:91:in `block in timeout' $HOME/$RUBY/lib/ruby/2.2.0/timeout.rb:35:in `block in catch' $HOME/$RUBY/lib/ruby/2.2.0/timeout.rb:35:in `catch' $HOME/$RUBY/lib/ruby/2.2.0/timeout.rb:35:in `catch' $HOME/$RUBY/lib/ruby/2.2.0/timeout.rb:106:in `timeout' $HOME/dtas/test/player_integration.rb:54:in `wait_pid_dead' test/test_player_integration.rb:42:in `test_sink_killed_during_play' --- lib/dtas/unix_server.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/dtas/unix_server.rb b/lib/dtas/unix_server.rb index c3db9f4..4b26555 100644 --- a/lib/dtas/unix_server.rb +++ b/lib/dtas/unix_server.rb @@ -99,7 +99,13 @@ class DTAS::UNIXServer # :nodoc: def run_once # give IO.select one-shot behavior, snapshot and replace the watchlist - r = IO.select(@readers.keys, @writers.keys) or return + begin + r = IO.select(@readers.keys, @writers.keys) or return + rescue IOError + # this only happens when sinks error out + @writers.delete_if { |io| io.to_io.closed? } + retry + end @hot_read = r[0] r[1].each do |io| @writers.delete(io) -- EW