about summary refs log tree commit homepage
path: root/lib/yahns/proxy_http_response.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-05-08 02:42:54 +0000
committerEric Wong <e@80x24.org>2015-05-08 02:44:33 +0000
commita25a203038bba9769ada5afd478d6250a44f543b (patch)
tree36f352ffbc6a878a71ac837088a5d793220055d1 /lib/yahns/proxy_http_response.rb
parent9e3217b0522315d2d115e53309f3563e9554ffc9 (diff)
downloadyahns-a25a203038bba9769ada5afd478d6250a44f543b.tar.gz
Reactivating a client socket after the proxied response is
complete requires the object remain visible to the Ruby GC while
no thread is accessing it.  So we must place the object back
into the fdmap to prevent the GC from eating it (and having
epoll return an invalid pointer).
Diffstat (limited to 'lib/yahns/proxy_http_response.rb')
-rw-r--r--lib/yahns/proxy_http_response.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index 4801008..5bb0608 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -228,6 +228,7 @@ module Yahns::HttpResponse # :nodoc:
   end
 
   def proxy_wait_next(qflags)
+    Thread.current[:yahns_fdmap].remember(self)
     # We must allocate a new, empty request object here to avoid a TOCTTOU
     # in the following timeline
     #
@@ -261,7 +262,7 @@ module Yahns::HttpResponse # :nodoc:
     case http_response_done(alive)
     when :wait_readable then proxy_wait_next(Yahns::Queue::QEV_RD)
     when :wait_writable then proxy_wait_next(Yahns::Queue::QEV_WR)
-    when :close then Thread.current[:yahns_fdmap].sync_close(self)
+    when :close then close
     end
 
     nil # close the req_res, too