From: Eric Wong <e@80x24.org>
To: dtas-all@nongnu.org
Subject: [PATCH 6/9] use IO#wait_readable consistently
Date: Sun, 23 Jan 2022 21:37:43 +0000 [thread overview]
Message-ID: <20220123213746.21085-7-e@80x24.org> (raw)
In-Reply-To: <20220123213746.21085-1-e@80x24.org>
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 <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
# 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)
next prev parent reply other threads:[~2022-01-23 21:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-23 21:37 [PATCH 0/9] various cuts for memory savings Eric Wong
2022-01-23 21:37 ` [PATCH 1/9] deduplicate and freeze pathnames + metadata Eric Wong
2022-01-23 21:37 ` [PATCH 2/9] player: remove omap conversion Eric Wong
2022-01-23 21:37 ` [PATCH 3/9] dtas: drop unnecessary "require 'yaml'" statements Eric Wong
2022-01-23 21:37 ` [PATCH 4/9] dtas-tl prune: cull missing files from tracklist Eric Wong
2022-01-23 21:37 ` [PATCH 5/9] dtas-tl: drop encoding hacks, use binary stdout+stderr Eric Wong
2022-01-23 21:37 ` Eric Wong [this message]
2022-01-23 21:37 ` [PATCH 7/9] get rid of DTAS::Nonblock wrapper for Ruby <= 2.0 Eric Wong
2022-01-23 21:37 ` [PATCH 8/9] unix_accepted: drop Ruby < 2.3 support code Eric Wong
2022-01-23 21:37 ` [PATCH 9/9] do not check IO#closed? before calling IO#close Eric Wong
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=20220123213746.21085-7-e@80x24.org \
--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).