about summary refs log tree commit homepage
path: root/lib/yahns/queue_epoll.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-20 09:25:54 +0000
committerEric Wong <e@80x24.org>2013-10-21 04:09:20 +0000
commitd3335cbaee6c47880b3bb5a372b966842edfeade (patch)
tree8255bc8670535f34ca57e33ac05272bae51c9ace /lib/yahns/queue_epoll.rb
parent92172ac2c4e094cb2d8f8669a1f7666501425263 (diff)
downloadyahns-d3335cbaee6c47880b3bb5a372b966842edfeade.tar.gz
Acceptors require closing the descriptor, first, and then doing a
(nasty) cross-thread exception to kick the thread out of the blocking
accept via Thread#run (pthread_kill SIGVTALRM).  We cannot do what we're
doing with epoll with acceptors because the accept socket is shared
across processes.  We will also NEVER be using non-blocking accept, as
it's more important we fairly distribute connections between tasks when
we're not shutting the server down.

The queue worker threads are much easier to kill off :)  We can simply
inject a new QueueQuitter object as a Level-Triggering epoll watch,
activate it, and let it wreak havok on all the worker threads from a
single event activation.

rb_thread_fd_close is convenient, but expensive with many threads, so be
prepared for more systems without it.  This is for Rubinius compatibility.

Yes, we are actually using Level-Triggered epoll here (despite the
non-shutdown pieces of our code being based around EPOLLONESHOT).
Diffstat (limited to 'lib/yahns/queue_epoll.rb')
-rw-r--r--lib/yahns/queue_epoll.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/yahns/queue_epoll.rb b/lib/yahns/queue_epoll.rb
index 7df1cc0..fab1090 100644
--- a/lib/yahns/queue_epoll.rb
+++ b/lib/yahns/queue_epoll.rb
@@ -6,6 +6,7 @@ class Yahns::Queue < SleepyPenguin::Epoll::IO # :nodoc:
   attr_accessor :fdmap # Yahns::Fdmap
 
   # public
+  QEV_QUIT = Epoll::IN
   QEV_RD = Epoll::IN | Epoll::ONESHOT
   QEV_WR = Epoll::OUT | Epoll::ONESHOT
   QEV_RDWR = QEV_RD | QEV_WR