mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Fix shell bug causing CPU 100%
The SSH sessions loop is trying to IO.select and wait for 0.1 seconds, but the select is often never reached because it only enters if readers/writers exist. So the loop executes unchecked at 100% when waiting for commands. Now we will sleep for 0.1 seconds if we have no waiting IO.
This commit is contained in:
parent
3100b9118b
commit
f2a787cdc9
2 changed files with 6 additions and 2 deletions
|
@ -23,6 +23,8 @@ module Capistrano
|
|||
|
||||
if readers.any? || writers.any?
|
||||
readers, writers, = IO.select(readers, writers, nil, wait)
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
if readers
|
||||
|
@ -50,4 +52,4 @@ module Capistrano
|
|||
sessions
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -199,11 +199,13 @@ HELP
|
|||
# thread and generally gets things ready for the REPL.
|
||||
def setup
|
||||
configuration.logger.level = Capistrano::Logger::INFO
|
||||
wait_for = 0.1
|
||||
|
||||
@mutex = Mutex.new
|
||||
@bgthread = Thread.new do
|
||||
loop do
|
||||
@mutex.synchronize { process_iteration(0.1) }
|
||||
ret = @mutex.synchronize { process_iteration(wait_for) }
|
||||
sleep wait_for if !ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue