yahns Ruby server user/dev discussion
 help / color / Atom feed
* [PATCH] sigevent_*: fixup non-eventfd path
@ 2019-04-02  3:13 Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2019-04-02  3:13 UTC (permalink / raw)
  To: yahns-public

And slightly cleanup the Kgio::DefaultWaiters include for
the eventfd path, too.

Fixes: 96825e8ca734cfbb ("remove calls to kgio_wait_* able")
---
 lib/yahns/sigevent_efd.rb  |  1 -
 lib/yahns/sigevent_pipe.rb | 18 +++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/yahns/sigevent_efd.rb b/lib/yahns/sigevent_efd.rb
index 1250cf4..264097d 100644
--- a/lib/yahns/sigevent_efd.rb
+++ b/lib/yahns/sigevent_efd.rb
@@ -3,7 +3,6 @@
 # License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
 # frozen_string_literal: true
 class Yahns::Sigevent < SleepyPenguin::EventFD # :nodoc:
-  include Kgio::DefaultWaiters
   def self.new
     super(0, :CLOEXEC)
   end
diff --git a/lib/yahns/sigevent_pipe.rb b/lib/yahns/sigevent_pipe.rb
index df4c31a..5d9b441 100644
--- a/lib/yahns/sigevent_pipe.rb
+++ b/lib/yahns/sigevent_pipe.rb
@@ -5,16 +5,24 @@
 class Yahns::Sigevent # :nodoc:
   attr_reader :to_io
   def initialize
-    @to_io, @wr = Kgio::Pipe.new
+    @to_io, @wr = IO.pipe
+  end
+
+  def wait_readable(*args)
+    @to_io.wait_readable(*args)
+  end
+
+  def fileno
+    @to_io.fileno
   end
 
   def sev_signal
-    @wr.kgio_trywrite(".")
+    @wr.write_nonblock(".", exception: false)
   end
 
   def yahns_step
     # 11 byte strings -> no malloc on YARV
-    while String === @to_io.kgio_tryread(11)
+    while String === @to_io.read_nonblock(11, exception: false)
     end
     :wait_readable
   end
@@ -23,4 +31,8 @@ def close
     @to_io.close
     @wr.close
   end
+
+  def closed?
+    @to_io.closed?
+  end
 end
-- 
EW


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] sigevent_*: fixup non-eventfd path
@ 2019-04-02  3:10 Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2019-04-02  3:10 UTC (permalink / raw)
  To: yahns-public

And slightly cleanup the Kgio::DefaultWaiters include for
the eventfd path, too.

Fixes: 96825e8ca734cfbb ("remove calls to kgio_wait_* able")
---
 lib/yahns/sigevent_efd.rb  |  1 -
 lib/yahns/sigevent_pipe.rb | 18 +++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/yahns/sigevent_efd.rb b/lib/yahns/sigevent_efd.rb
index 1250cf4..264097d 100644
--- a/lib/yahns/sigevent_efd.rb
+++ b/lib/yahns/sigevent_efd.rb
@@ -3,7 +3,6 @@
 # License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
 # frozen_string_literal: true
 class Yahns::Sigevent < SleepyPenguin::EventFD # :nodoc:
-  include Kgio::DefaultWaiters
   def self.new
     super(0, :CLOEXEC)
   end
diff --git a/lib/yahns/sigevent_pipe.rb b/lib/yahns/sigevent_pipe.rb
index df4c31a..5d9b441 100644
--- a/lib/yahns/sigevent_pipe.rb
+++ b/lib/yahns/sigevent_pipe.rb
@@ -5,16 +5,24 @@
 class Yahns::Sigevent # :nodoc:
   attr_reader :to_io
   def initialize
-    @to_io, @wr = Kgio::Pipe.new
+    @to_io, @wr = IO.pipe
+  end
+
+  def wait_readable(*args)
+    @to_io.wait_readable(*args)
+  end
+
+  def fileno
+    @to_io.fileno
   end
 
   def sev_signal
-    @wr.kgio_trywrite(".")
+    @wr.write_nonblock(".", exception: false)
   end
 
   def yahns_step
     # 11 byte strings -> no malloc on YARV
-    while String === @to_io.kgio_tryread(11)
+    while String === @to_io.read_nonblock(11, exception: false)
     end
     :wait_readable
   end
@@ -23,4 +31,8 @@ def close
     @to_io.close
     @wr.close
   end
+
+  def closed?
+    @to_io.closed?
+  end
 end
-- 
EW


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02  3:13 [PATCH] sigevent_*: fixup non-eventfd path Eric Wong
  -- strict thread matches above, loose matches on Subject: below --
2019-04-02  3:10 Eric Wong

yahns Ruby server user/dev discussion

Archives are clonable:
	git clone --mirror https://yhbt.net/yahns-public
	git clone --mirror http://ou63pmih66umazou.onion/yahns-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.yahns
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.yahns

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox