1 # -*- encoding: binary -*-
3 module Rainbows::Epoll::Server
5 Rainbows::Epoll.nr_clients = lambda { @@nr }
6 IN = SleepyPenguin::Epoll::IN | SleepyPenguin::Epoll::ET
7 MAX = Rainbows.server.worker_connections
9 LISTENERS = Rainbows::HttpServer::LISTENERS
10 EP = Rainbows::Epoll::EP
13 LISTENERS.each { |sock| EP.add(sock.extend(self), IN) }
17 # rearms all listeners when there's a free slot
19 THRESH == (@@nr -= 1) and LISTENERS.each { |sock| EP.set(sock, IN) }
23 return EP.delete(self) if @@nr >= MAX
24 while io = kgio_tryaccept
26 # there's a chance the client never even sees epoll for simple apps
28 return EP.delete(self) if @@nr >= MAX