about summary refs log tree commit homepage
path: root/lib/dtas/pipe.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-02 20:37:38 +0000
committerEric Wong <e@80x24.org>2019-01-02 20:37:38 +0000
commit44baf906e73c13577186e3135be4356b33b8be43 (patch)
treeea17d5da3893b176c637927388659b526c44bb8e /lib/dtas/pipe.rb
parent8f8140f68ff2daab5feeb134d1f4e77f4329fa0f (diff)
downloaddtas-44baf906e73c13577186e3135be4356b33b8be43.tar.gz
Eliminate loading of the io_splice RubyGem to reduce memory overhead.
Extra DSOs are wasteful and io_splice is being phased oiut for
sleepy_penguin, which encapsulates more Linux-specific functionality
anyways.

cf. https://udrepper.livejournal.com/8790.html
Diffstat (limited to 'lib/dtas/pipe.rb')
-rw-r--r--lib/dtas/pipe.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/dtas/pipe.rb b/lib/dtas/pipe.rb
index f9d5149..97cbd71 100644
--- a/lib/dtas/pipe.rb
+++ b/lib/dtas/pipe.rb
@@ -2,7 +2,7 @@
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 begin
-  require 'io/splice'
+  require 'sleepy_penguin'
 rescue LoadError
 end
 require_relative '../dtas'
@@ -20,12 +20,15 @@ class DTAS::Pipe < DTAS::Nonblock # :nodoc:
     rv
   end
 
-  # create no-op methods for non-Linux
-  unless method_defined?(:pipe_size=)
-    def pipe_size=(_)
-    end
+  def pipe_size=(nr)
+    defined?(SleepyPenguin::F_SETPIPE_SZ) and
+      fcntl(SleepyPenguin::F_SETPIPE_SZ, nr)
   end
 
+  def pipe_size
+    fcntl(SleepyPenguin::F_GETPIPE_SZ)
+  end if defined?(SleepyPenguin::F_GETPIPE_SZ)
+
   # avoid syscall, we never change IO#nonblock= directly
   def nonblock?
     false