about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-22 01:38:30 +0000
committerEric Wong <e@80x24.org>2017-03-22 01:39:37 +0000
commit58c38861d6cb540e5a4239bc2d88df3865ffe1c8 (patch)
tree02bf471e227d60d42006133fd17fc9f1eb52fc97
parent67217af099363633adf16a15fb0bddbd9d015176 (diff)
downloadsleepy_penguin-58c38861d6cb540e5a4239bc2d88df3865ffe1c8.tar.gz
We only support modern Rubies, so IO#autoclose= is implicit
and we should not be wasting bytecode checking for it.
-rw-r--r--ext/sleepy_penguin/kqueue.c7
-rw-r--r--lib/sleepy_penguin/kqueue.rb8
-rw-r--r--test/test_kqueue.rb3
3 files changed, 6 insertions, 12 deletions
diff --git a/ext/sleepy_penguin/kqueue.c b/ext/sleepy_penguin/kqueue.c
index 114e78a..430bc88 100644
--- a/ext/sleepy_penguin/kqueue.c
+++ b/ext/sleepy_penguin/kqueue.c
@@ -101,11 +101,10 @@ static struct kq_per_thread *kpt_get(int nchanges, int nevents)
  * Creates a new Kqueue::IO object.  This is a wrapper around the kqueue(2)
  * system call which creates a Ruby IO object around the kqueue descriptor.
  *
- * kqueue descriptors are automatically invalidated across fork, so care
- * must be taken when forking.
+ * kqueue descriptors are automatically invalidated by the OS across fork,
+ * so care must be taken when forking.
  * Setting IO#autoclose=false is recommended for applications which fork
- * after kqueue creation.  Ruby 1.8 does not have IO#autoclose=, so using
- * this class is not recommended under Ruby 1.8
+ * after kqueue creation.
  */
 static VALUE s_new(VALUE klass)
 {
diff --git a/lib/sleepy_penguin/kqueue.rb b/lib/sleepy_penguin/kqueue.rb
index d460669..2620a12 100644
--- a/lib/sleepy_penguin/kqueue.rb
+++ b/lib/sleepy_penguin/kqueue.rb
@@ -1,8 +1,8 @@
 require 'thread'
 require_relative 'kevent'
 
-# The high-level Kqueue interface.  This provides fork-safety under Ruby 1.9
-# and later (but not Ruby 1.8).
+# The high-level Kqueue interface.  This provides fork-safety; as
+# underlying kqueue descriptors are closed by the OS upon fork.
 # This also provides memory protection from bugs due to not storing an
 # external reference to an object, but still requires the user to store
 # their own object references.
@@ -34,10 +34,6 @@ class SleepyPenguin::Kqueue
 
   def __kq_check # :nodoc:
     return if @pid == $$ || @io.closed?
-    unless @io.respond_to?(:autoclose=)
-      raise RuntimeError,
-       "Kqueue is not safe to use without IO#autoclose=, upgrade to Ruby 1.9+"
-    end
 
     # kqueue has (strange) close-on-fork behavior
     objects = @copies.values
diff --git a/test/test_kqueue.rb b/test/test_kqueue.rb
index 6de75f3..ae3203d 100644
--- a/test/test_kqueue.rb
+++ b/test/test_kqueue.rb
@@ -100,5 +100,4 @@ class TestKqueue < Test::Unit::TestCase
   ensure
     [ r1, w1, r2, w2, kq1, kq2 ].compact.each(&:close)
   end
-end if defined?(SleepyPenguin::Kqueue) &&
-       IO.instance_methods.include?(:autoclose=)
+end if defined?(SleepyPenguin::Kqueue)