diff options
Diffstat (limited to 'lib/yahns/server.rb')
-rw-r--r-- | lib/yahns/server.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb index 9a72ef5..fea310c 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -307,6 +307,15 @@ class Yahns::Server # :nodoc: $0 = ([ File.basename(s[0]), tag ]).concat(s[:argv]).join(' ') end + def qegg_vivify(qegg, fdmap) + queue = qegg.vivify(fdmap) + qegg.worker_threads.times do + @wthr << queue.worker_thread(@logger, qegg.max_events) + end + @queues << queue + queue + end + # spins up processing threads of the server def fdmap_init thresh = @config.value(:client_expire_threshold) @@ -314,16 +323,8 @@ class Yahns::Server # :nodoc: # keeps track of all connections, like ObjectSpace, but only for IOs fdmap = Yahns::Fdmap.new(@logger, thresh) - # initialize queues (epoll/kqueue) and associated worker threads + # once initialize queues (epoll/kqueue) and associated worker threads queues = {} - @config.qeggs.each do |name, qe| - queue = qe.vivify(fdmap) - qe.worker_threads.times do - @wthr << queue.worker_thread(@logger, qe.max_events) - end - @queues << queue - queues[qe] = queue - end # spin up applications (which are preload: false) @config.app_ctx.each(&:after_fork_init) @@ -334,7 +335,7 @@ class Yahns::Server # :nodoc: qegg = ctx.qegg || @config.qeggs[:default] # acceptors feed the the queues - l.spawn_acceptor(@logger, ctx, queues[qegg]) + l.spawn_acceptor(@logger, ctx, queues[qegg] ||= qegg_vivify(qegg, fdmap)) end fdmap end |