From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 256001F852 for ; Sun, 23 Jan 2022 21:38:25 +0000 (UTC) Received: from localhost ([::1]:56408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBkZ6-0007QF-Bd for e@80x24.org; Sun, 23 Jan 2022 16:38:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBkYz-0007O5-8x for dtas-all@nongnu.org; Sun, 23 Jan 2022 16:38:19 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:40052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBkYx-0000Ac-Hu for dtas-all@nongnu.org; Sun, 23 Jan 2022 16:38:16 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 034B41FA18 for ; Sun, 23 Jan 2022 21:37:47 +0000 (UTC) From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH 6/9] use IO#wait_readable consistently Date: Sun, 23 Jan 2022 21:37:43 +0000 Message-Id: <20220123213746.21085-7-e@80x24.org> In-Reply-To: <20220123213746.21085-1-e@80x24.org> References: <20220123213746.21085-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.71.152.64; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" Since Ruby 2.3, it no longer checks FIONREAD, and we require Ruby 2.3+ nowadays, so drop our IO.select-based workarounds. --- bin/dtas-readahead | 16 ++-------------- lib/dtas/unix_client.rb | 4 ++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/bin/dtas-readahead b/bin/dtas-readahead index d3c6e79..75bfbe8 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -28,18 +28,6 @@ @redir = { err: null, out: null, in: null }.freeze require 'pp' -if RUBY_VERSION.to_r >= '2.3'.to_r - # Old Rubies did FIONREAD, which breaks on SOCK_SEQPACKET - def wait_read(w, timeout) - w.to_io.wait_readable(timeout) - end -else - def wait_read(w, timeout) - r = IO.select([w], nil, nil, timeout) - r ? r[0] : nil - end -end - def seek_to_cur_pos(cur_pid, fp) cur_fd = [] fpst = fp.stat @@ -120,7 +108,7 @@ def do_ra(fp, pos, w) len -= n # stop reading immediately if there's an event - if wait_read(w, 0) + if w.to_io.wait_readable(0) adj = @todo_ra pos += size break @@ -220,7 +208,7 @@ def do_open(path) fp.close if fp && !fp.closed? fp = timeout = nil end - r = wait_read(w, timeout) + r = w.to_io.wait_readable(timeout) p w.res_wait if r rescue EOFError abort "dtas-player exited" diff --git a/lib/dtas/unix_client.rb b/lib/dtas/unix_client.rb index 8aa953c..71f833c 100644 --- a/lib/dtas/unix_client.rb +++ b/lib/dtas/unix_client.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 all contributors +# Copyright (C) all contributors # License: GPL-3.0+ # frozen_string_literal: true require_relative '../dtas' @@ -39,7 +39,7 @@ def req(args, timeout = nil) end def res_wait(timeout = nil) - IO.select([@to_io], nil, nil, timeout) + @to_io.wait_readable(timeout) nr = @to_io.nread nr > 0 or raise EOFError, "unexpected EOF from server" @to_io.recv(nr)