diff options
author | Eric Wong <e@80x24.org> | 2013-10-19 02:47:58 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2013-10-19 02:47:58 +0000 |
commit | 9cd4a50c275bbda9ee23f0351f1eba2289af075f (patch) | |
tree | e7051daa5f7fd691133a9c48e047468df39b9e63 /lib/yahns/queue_epoll.rb | |
parent | 2377d5a1cafa518313b0b597e4c3af65bb57f887 (diff) | |
download | yahns-9cd4a50c275bbda9ee23f0351f1eba2289af075f.tar.gz |
Rack hijacking may close the socket before it yields control back to our epoll event loop. So it's not safe to attempt to use the socket (or even get the .fileno) with :delete/EPOLL_CTL_DEL. So change :delete to :ignore, and only decrement the FD counter to allow yahns to do graceful shutdown. This means we'll potentially waste ~200 bytes of kernel memory due to epoll overhead until the FD is closed by the app hijacking. I'm not sure how Rack servers handle graceful shutdown when hijacking, but maybe they just retrap SIGQUIT...
Diffstat (limited to 'lib/yahns/queue_epoll.rb')
-rw-r--r-- | lib/yahns/queue_epoll.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/yahns/queue_epoll.rb b/lib/yahns/queue_epoll.rb index c9febc4..5cb455b 100644 --- a/lib/yahns/queue_epoll.rb +++ b/lib/yahns/queue_epoll.rb @@ -35,9 +35,8 @@ class Yahns::Queue < SleepyPenguin::Epoll::IO # :nodoc: epoll_ctl(Epoll::CTL_MOD, io, QEV_WR) when :wait_readwrite epoll_ctl(Epoll::CTL_MOD, io, QEV_RDWR) - when :delete # only used by rack.hijack - epoll_ctl(Epoll::CTL_DEL, io, 0) - @fdmap.delete(io) + when :ignore # only used by rack.hijack + @fdmap.decr when nil # this is be the ONLY place where we call IO#close on # things inside the queue |