diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-28 11:26:39 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-28 11:26:39 -0800 |
commit | 2489368a624cff50a330238cf3c3f16eb0bd743c (patch) | |
tree | 782d060210a50cbf96ee3df11781f76a96166298 /lib/rainbows/actor_spawn.rb | |
parent | 6443cc4b87e3ba71ad661d795c3856f95a058a24 (diff) | |
download | rainbows-2489368a624cff50a330238cf3c3f16eb0bd743c.tar.gz |
Diffstat (limited to 'lib/rainbows/actor_spawn.rb')
-rw-r--r-- | lib/rainbows/actor_spawn.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/rainbows/actor_spawn.rb b/lib/rainbows/actor_spawn.rb index 30e62a9..7603734 100644 --- a/lib/rainbows/actor_spawn.rb +++ b/lib/rainbows/actor_spawn.rb @@ -25,17 +25,14 @@ module Rainbows begin ret = IO.select(LISTENERS, nil, nil, 1) and ret.first.each do |l| - next if lock.synchronize { nr >= limit } - begin - Actor.spawn(l.accept_nonblock) do |c| - lock.synchronize { nr += 1 } - begin - process_client(c) - ensure - lock.synchronize { nr -= 1 } - end + lock.synchronize { nr >= limit } and break sleep(0.01) + c = Rainbows.accept(l) and Actor.spawn do + lock.synchronize { nr += 1 } + begin + process_client(c) + ensure + lock.synchronize { nr -= 1 } end - rescue Errno::EAGAIN, Errno::ECONNABORTED end end rescue => e |