everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: dtas-all@nongnu.org
Subject: [PATCH] unix_server: fix for infinite loop
Date: Sat, 18 Oct 2014 10:18:32 +0000	[thread overview]
Message-ID: <20141018101832.GA11977@dcvr.yhbt.net> (raw)

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


                 reply	other threads:[~2014-10-18 10:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: https://80x24.org/dtas/README

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

  git send-email \
    --in-reply-to=20141018101832.GA11977@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=dtas-all@nongnu.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).