lib/rainbows/thread_pool.rb in rainbows-0.2.0 vs lib/rainbows/thread_pool.rb in rainbows-0.3.0
- old
+ new
@@ -25,15 +25,14 @@
include Base
def worker_loop(worker)
init_worker_process(worker)
- RACK_DEFAULTS["rack.multithread"] = true
pool = (1..worker_connections).map { new_worker_thread }
m = 0
- while LISTENERS.first && master_pid == Process.ppid
+ while G.alive && master_pid == Process.ppid
pool.each do |thr|
worker.tmp.chmod(m = 0 == m ? 1 : 0)
# if any worker dies, something is serious wrong, bail
thr.join(timeout) and break
end
@@ -43,24 +42,23 @@
def new_worker_thread
Thread.new {
begin
begin
- ret = IO.select(LISTENERS, nil, nil, timeout) or next
- ret.first.each do |sock|
- begin
- process_client(sock.accept_nonblock)
- rescue Errno::EAGAIN, Errno::ECONNABORTED
- end
- end
+ ret = IO.select(LISTENERS, nil, nil, 1) and
+ ret.first.each do |sock|
+ begin
+ process_client(sock.accept_nonblock)
+ rescue Errno::EAGAIN, Errno::ECONNABORTED
+ end
+ end
rescue Errno::EINTR
- next
rescue Errno::EBADF, TypeError
- return
+ break
end
rescue Object => e
- listen_loop_error(e) if LISTENERS.first
- end while ! Thread.current[:quit] && LISTENERS.first
+ listen_loop_error(e)
+ end while G.alive
}
end
end
end