From: Eric Wong <e@80x24.org> To: dtas-all@nongnu.org Subject: [PATCH 1/5] pipe: avoid loading sleepy_penguin Date: Sun, 1 Dec 2019 01:26:49 +0000 Message-ID: <20191201012653.21967-2-e@80x24.org> (raw) In-Reply-To: <20191201012653.21967-1-e@80x24.org> The values of F_{GET,SET}PIPE_SZ are architecture-independent and stable in Linux (unlike Ruby :P), so we won't need to bother loading an extra .so here for two constants. --- lib/dtas/pipe.rb | 20 ++++++++++++-------- test/test_sink_pipe_size.rb | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/dtas/pipe.rb b/lib/dtas/pipe.rb index 58d926c..4c3203d 100644 --- a/lib/dtas/pipe.rb +++ b/lib/dtas/pipe.rb @@ -1,10 +1,6 @@ # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true -begin - require 'sleepy_penguin' -rescue LoadError -end require_relative '../dtas' require_relative 'writable_iter' require_relative 'nonblock' @@ -14,6 +10,11 @@ class DTAS::Pipe < DTAS::Nonblock # :nodoc: include DTAS::WritableIter attr_accessor :sink + if RUBY_PLATFORM =~ /linux/i && File.readable?('/proc/sys/fs/pipe-max-size') + F_SETPIPE_SZ = 1031 + F_GETPIPE_SZ = 1032 + end + def self.new _, w = rv = pipe w.writable_iter_init @@ -21,13 +22,16 @@ def self.new end def pipe_size=(nr) - defined?(SleepyPenguin::F_SETPIPE_SZ) and - fcntl(SleepyPenguin::F_SETPIPE_SZ, nr) + fcntl(F_SETPIPE_SZ, nr) if defined?(F_SETPIPE_SZ) + rescue Errno::EINVAL # old kernel + rescue Errno::EPERM + # resizes fail if Linux is close to the pipe limit for the user + # or if the user does not have permissions to resize end def pipe_size - fcntl(SleepyPenguin::F_GETPIPE_SZ) - end if defined?(SleepyPenguin::F_GETPIPE_SZ) + fcntl(F_GETPIPE_SZ) + end if defined?(F_GETPIPE_SZ) # avoid syscall, we never change IO#nonblock= directly def nonblock? diff --git a/test/test_sink_pipe_size.rb b/test/test_sink_pipe_size.rb index 1b6db72..bbe2884 100644 --- a/test/test_sink_pipe_size.rb +++ b/test/test_sink_pipe_size.rb @@ -1,20 +1,17 @@ # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true -begin - require 'sleepy_penguin' - require './test/player_integration' - class TestSinkPipeSizeIntegration < Testcase - include PlayerIntegration +require './test/player_integration' +class TestSinkPipeSizeIntegration < Testcase + include PlayerIntegration - def test_sink_pipe_size_integration - s = client_socket - default_sink_pid(s) - s.req_ok("sink ed default pipe_size=0x1000") - s.req_ok("sink ed default pipe_size=0x10000") - s.req_ok("sink ed default pipe_size=") - s.req_ok("sink ed default pipe_size=4096") - end if SleepyPenguin.const_defined?(:F_SETPIPE_SZ) + def test_sink_pipe_size_integration + s = client_socket + default_sink_pid(s) + s.req_ok("sink ed default pipe_size=0x1000") + s.req_ok("sink ed default pipe_size=0x10000") + s.req_ok("sink ed default pipe_size=") + s.req_ok("sink ed default pipe_size=4096") end -rescue LoadError -end +end if RUBY_PLATFORM =~ /linux/i && + File.readable?('/proc/sys/fs/pipe-max-size')
next prev parent reply other threads:[~2019-12-01 1:27 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-01 1:26 [PATCH 0/5] use fiddle for Linux-specific APIs Eric Wong 2019-12-01 1:26 ` Eric Wong [this message] 2019-12-01 1:26 ` [PATCH 2/5] use fiddle-based eventfd implementation Eric Wong 2019-12-01 1:26 ` [PATCH 3/5] buffer: replace sleepy_penguin with fiddle Eric Wong 2019-12-01 1:26 ` [PATCH 4/5] watchable: use fiddle for inotify support Eric Wong 2019-12-01 1:26 ` [PATCH 5/5] doc: remove "sleepy_penguin" references Eric Wong 2019-12-13 18:16 ` [PATCH 0/5] use fiddle for Linux-specific APIs Eric Wong 2019-12-15 20:39 ` fiddle vs sleepy_penguin vs Perl syscall() bench scripts 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=20191201012653.21967-2-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
everything related to duct tape audio suite (dtas) This inbox may be cloned and mirrored by anyone: git clone --mirror https://80x24.org/dtas-all git clone --mirror http://ou63pmih66umazou.onion/dtas-all # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 dtas-all dtas-all/ https://80x24.org/dtas-all \ dtas-all@nongnu.org public-inbox-index dtas-all Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.audio.dtas nntp://ou63pmih66umazou.onion/inbox.comp.audio.dtas note: .onion URLs require Tor: https://www.torproject.org/ code repositories for the project(s) associated with this inbox: ../../dtas.git AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git