diff options
author | Eric Wong <e@80x24.org> | 2015-03-17 09:03:30 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-03-17 18:34:38 +0000 |
commit | c1396bf85d78504315482b28382b78d9e5e52c9a (patch) | |
tree | 16cf4e7674f2ebbe42014da465a777a5b8a30e08 /lib | |
parent | 7542c8365613d0104b8a3171418bb8c7f1a518cb (diff) | |
download | yahns-c1396bf85d78504315482b28382b78d9e5e52c9a.tar.gz |
We will support "un-hijacking", so the repeated ep_insert/ep_remove sequences in the kernel will get expensive and complicated for our user-land code, too.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/yahns/http_client.rb | 10 | ||||
-rw-r--r-- | lib/yahns/queue_epoll.rb | 11 | ||||
-rw-r--r-- | lib/yahns/queue_kqueue.rb | 6 |
3 files changed, 5 insertions, 22 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 235decd..46ea3ec 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -259,12 +259,12 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: end # allow releasing some memory if rack.hijack is used + # n.b. we no longer issue EPOLL_CTL_DEL because it becomes more expensive + # (and complicated) as our hijack support will allow "un-hijacking" + # the socket. def hijack_cleanup - # we must issue EPOLL_CTL_DEL before hijacking (if we issue it at all), - # because the hijacker may close use before we get back to the epoll worker - # loop. EPOLL_CTL_DEL saves about 200 bytes of unswappable kernel memory, - # so it can matter if we have lots of hijacked sockets. - self.class.queue.queue_del(self) # EPOLL_CTL_DEL + # prevent socket from holding process up + Thread.current[:yahns_fdmap].forget(self) @input = nil # keep env["rack.input"] accessible, though @hs = nil # no need for the HTTP parser anymore end diff --git a/lib/yahns/queue_epoll.rb b/lib/yahns/queue_epoll.rb index 4a10ce0..da90a95 100644 --- a/lib/yahns/queue_epoll.rb +++ b/lib/yahns/queue_epoll.rb @@ -32,17 +32,6 @@ class Yahns::Queue < SleepyPenguin::Epoll::IO # :nodoc: Thread.current[:yahns_fdmap] = @fdmap end - # use only before hijacking, once hijacked, io may be unusable to us - # It is not safe to call this unless it is an unarmed EPOLLONESHOT - # object. - def queue_del(io) - # order does not really matter here, however Epoll::CTL_DEL - # will free up ~200 bytes of unswappable kernel memory, - # so we call it first - epoll_ctl(Epoll::CTL_DEL, io, 0) - @fdmap.forget(io) - end - # returns an array of infinitely running threads def worker_thread(logger, max_events) Thread.new do diff --git a/lib/yahns/queue_kqueue.rb b/lib/yahns/queue_kqueue.rb index ce75793..4e5c133 100644 --- a/lib/yahns/queue_kqueue.rb +++ b/lib/yahns/queue_kqueue.rb @@ -41,12 +41,6 @@ class Yahns::Queue < SleepyPenguin::Kqueue::IO # :nodoc: Thread.current[:yahns_fdmap] = @fdmap end - def queue_del(io) - # do not bother with kevent EV_DELETE, it may be tricky to get right, - # we only did it in epoll since Eric knows the epoll internals well. - @fdmap.forget(io) - end - # returns an array of infinitely running threads def worker_thread(logger, max_events) Thread.new do |