about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-11-07 18:15:26 +0000
committerEric Wong <e@80x24.org>2013-11-07 18:15:26 +0000
commit0258cd5dd91241931cca08048ab0a2067e323ee6 (patch)
treeb1ec07e13b4d038a0084890a57815b6c97742c5b
parentd9b7a620f43fe815c5ddbf341a73b51bd0e7da8a (diff)
downloadyahns-0258cd5dd91241931cca08048ab0a2067e323ee6.tar.gz
Simultaneously waiting for both readability and writability is
likely unnecessary.  Sockets become writable much more commonly,
and if we need to read, we'll issue a read the next time it enters
yahns_step (after it becomes writable).

Also, this makes kqueue easier-to-implement as I don't believe it
implements a way to combine EVFILT_READ with EVFILT_WRITE
(especially not safely while relying on EV_ONESHOT behavior).
-rw-r--r--lib/yahns/http_response.rb6
-rw-r--r--lib/yahns/queue_epoll.rb3
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb
index 8a2426b..7207bd1 100644
--- a/lib/yahns/http_response.rb
+++ b/lib/yahns/http_response.rb
@@ -81,9 +81,9 @@ module Yahns::HttpResponse # :nodoc:
         :wait_readable
       else
         @state = :pipelined
-        # may need to wait for readability if SSL,
-        # only need writability if plain TCP
-        :wait_readwrite
+        # we shouldn't start processing the application again until we know
+        # the socket is writable for the response
+        :wait_writable
       end
     else
       # shutdown is needed in case the app forked, we rescue here since
diff --git a/lib/yahns/queue_epoll.rb b/lib/yahns/queue_epoll.rb
index 854aba9..4a10ce0 100644
--- a/lib/yahns/queue_epoll.rb
+++ b/lib/yahns/queue_epoll.rb
@@ -13,7 +13,6 @@ class Yahns::Queue < SleepyPenguin::Epoll::IO # :nodoc:
   QEV_QUIT = Epoll::OUT # Level Trigger for QueueQuitter
   QEV_RD = Epoll::IN | Epoll::ONESHOT
   QEV_WR = Epoll::OUT | Epoll::ONESHOT
-  QEV_RDWR = QEV_RD | QEV_WR
 
   def self.new
     super(SleepyPenguin::Epoll::CLOEXEC)
@@ -59,8 +58,6 @@ class Yahns::Queue < SleepyPenguin::Epoll::IO # :nodoc:
             epoll_ctl(Epoll::CTL_MOD, io, QEV_RD)
           when :wait_writable
             epoll_ctl(Epoll::CTL_MOD, io, QEV_WR)
-          when :wait_readwrite
-            epoll_ctl(Epoll::CTL_MOD, io, QEV_RDWR)
           when :ignore # only used by rack.hijack
             # we cannot call Epoll::CTL_DEL after hijacking, the hijacker
             # may have already closed it  Likewise, io.fileno is not