yahns Ruby server user/dev discussion
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Subject: [PATCH] remove calls to kgio_wait_* able
Date: Mon,  7 Jan 2019 10:43:09 +0000
Message-ID: <20190107104309.14275-1-e@80x24.org> (raw)

IO#wait_readable existed since Ruby 2.0, so we don't need
to use the "kgio_"-prefixed version.
---
 extras/proxy_pass.rb       |  4 ++--
 lib/yahns.rb               |  1 +
 lib/yahns/http_client.rb   | 16 ++++------------
 lib/yahns/http_response.rb |  5 ++---
 lib/yahns/server.rb        |  2 +-
 lib/yahns/server_mp.rb     |  2 +-
 lib/yahns/sigevent_pipe.rb |  4 ----
 7 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/extras/proxy_pass.rb b/extras/proxy_pass.rb
index 310da9e..af6fe01 100644
--- a/extras/proxy_pass.rb
+++ b/extras/proxy_pass.rb
@@ -36,7 +36,7 @@ class UpstreamSocket < Kgio::Socket # :nodoc:
     attr_writer :expiry
 
     # called automatically by kgio_read!
-    def kgio_wait_readable(timeout = nil)
+    def wait_readable(timeout = nil)
       super(timeout || wait_time)
     end
 
@@ -59,7 +59,7 @@ def req_write(buf, timeout)
       @expiry = Time.now + timeout
       case rv = kgio_trywrite(buf)
       when :wait_writable
-        kgio_wait_writable(wait_time)
+        wait_writable(wait_time)
       when nil
         return
       when String
diff --git a/lib/yahns.rb b/lib/yahns.rb
index a0abe49..21464ca 100644
--- a/lib/yahns.rb
+++ b/lib/yahns.rb
@@ -5,6 +5,7 @@
 
 require 'unicorn' # pulls in raindrops, kgio, fcntl, etc, stringio, and logger
 require 'sleepy_penguin'
+require 'io/wait'
 
 # kill off some unicorn internals we don't need
 # we'll probably just make kcar into a server parser so we don't depend
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index 8744053..b6b6035 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -235,25 +235,17 @@ def app_call(input)
     http_response_write(res, opt)
   end
 
-  # called automatically by kgio_write
-  def kgio_wait_writable(timeout = self.class.client_timeout)
-    super timeout
-  end
-
-  # called automatically by kgio_read
-  def kgio_wait_readable(timeout = self.class.client_timeout)
-    super timeout
-  end
-
   # used by StreamInput (and thus TeeInput) for input_buffering {false|:lazy}
   def yahns_read(bytes, buf)
     case rv = kgio_tryread(bytes, buf)
     when String, nil
       return rv
     when :wait_readable
-      kgio_wait_readable or raise Yahns::ClientTimeout, "waiting for read", []
+      wait_readable(self.class.client_timeout) or
+        raise Yahns::ClientTimeout, "waiting for read", []
     when :wait_writable
-      kgio_wait_writable or raise Yahns::ClientTimeout, "waiting for write", []
+      wait_writable(self.class.client_timeout) or
+        raise Yahns::ClientTimeout, "waiting for write", []
     end while true
   end
 
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb
index 865193d..2e719eb 100644
--- a/lib/yahns/http_response.rb
+++ b/lib/yahns/http_response.rb
@@ -46,10 +46,9 @@ def response_start
     @hs.response_start_sent ? ''.freeze : 'HTTP/1.1 '.freeze
   end
 
-  def response_wait_write(rv)
-    # call the kgio_wait_readable or kgio_wait_writable method
-    ok = __send__("kgio_#{rv}") and return ok
+  def response_wait_write(rv) # rv = [:wait_writable | :wait_readable ]
     k = self.class
+    ok = __send__(rv, k.client_timeout) and return ok
     k.logger.info("fd=#{fileno} ip=#@kgio_addr timeout on :#{rv} after "\
                   "#{k.client_timeout}s")
     false
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb
index 2ad65a9..c078ade 100644
--- a/lib/yahns/server.rb
+++ b/lib/yahns/server.rb
@@ -476,7 +476,7 @@ def reap_reexec
   end
 
   def sp_sig_handle(alive)
-    @sev.kgio_wait_readable(alive ? nil : 0.01)
+    @sev.wait_readable(alive ? nil : 0.01)
     @sev.yahns_step
     case sig = @sig_queue.shift
     when :QUIT, :TERM, :INT
diff --git a/lib/yahns/server_mp.rb b/lib/yahns/server_mp.rb
index 8752a08..5467674 100644
--- a/lib/yahns/server_mp.rb
+++ b/lib/yahns/server_mp.rb
@@ -89,7 +89,7 @@ def join
     @logger.info "master process ready"
     daemon_ready
     begin
-      @sev.kgio_wait_readable
+      @sev.wait_readable
       @sev.yahns_step
       reap_all
       case @sig_queue.shift
diff --git a/lib/yahns/sigevent_pipe.rb b/lib/yahns/sigevent_pipe.rb
index f630e72..df4c31a 100644
--- a/lib/yahns/sigevent_pipe.rb
+++ b/lib/yahns/sigevent_pipe.rb
@@ -8,10 +8,6 @@ def initialize
     @to_io, @wr = Kgio::Pipe.new
   end
 
-  def kgio_wait_readable(*args)
-    @to_io.kgio_wait_readable(*args)
-  end
-
   def sev_signal
     @wr.kgio_trywrite(".")
   end
-- 
EW


                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically 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://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190107104309.14275-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=yahns-public@yhbt.net \
    /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

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

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