diff options
author | Eric Wong <e@80x24.org> | 2013-10-19 23:43:59 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-20 00:09:04 +0000 |
commit | cd84e2ccbdf29b908c7d4711528d61bac05505bb (patch) | |
tree | 03e5cfd47e9a445094ccd559e2dd99095c0b422d /lib/yahns/acceptor.rb | |
parent | d4805769eb3174d25b429fa1faf5392b2669f354 (diff) | |
download | yahns-cd84e2ccbdf29b908c7d4711528d61bac05505bb.tar.gz |
Leaving running threads at exit seems to lead to occasional bugs at finalization on Ruby 2.0.0. This could be a bug with sleepy_penguin or kgio, too, so I'll have to investigate further. For now, we'll just destroy the IOs associated with each queue and let the threads die on their own. This changes the QueueEgg internals a bit and I've removed the unit test for QueueEgg now since the rest of the server already works well (and QueueEgg internals may change even more). Queues/worker threads no longer have their own logger, it seems like excessive configurability/complexity since acceptors do not have their own logger, either. This logger only exists to log bugs in yahns, not the application, so using the server logger is sufficient.
Diffstat (limited to 'lib/yahns/acceptor.rb')
-rw-r--r-- | lib/yahns/acceptor.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/yahns/acceptor.rb b/lib/yahns/acceptor.rb index b5e7b0e..43d5fe8 100644 --- a/lib/yahns/acceptor.rb +++ b/lib/yahns/acceptor.rb @@ -2,8 +2,8 @@ # License: GPLv3 or later (see COPYING for details) module Yahns::Acceptor # :nodoc: def spawn_acceptor(logger, client_class, queue) - accept_flags = Kgio::SOCK_NONBLOCK | Kgio::SOCK_CLOEXEC Thread.new do + accept_flags = Kgio::SOCK_NONBLOCK | Kgio::SOCK_CLOEXEC Thread.current.abort_on_exception = true qev_flags = client_class.superclass::QEV_FLAGS begin @@ -21,8 +21,9 @@ module Yahns::Acceptor # :nodoc: queue.fdmap.desperate_expire_for(self, 5) sleep 1 # let other threads do some work rescue => e - Yahns::Log.exception(logger, "accept loop error", e) unless closed? - end until closed? + break if closed? + Yahns::Log.exception(logger, "accept loop", e) + end while true end end end |