1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

Solved bug in mad thread manager.

git-svn-id: http://svn.opennebula.org/trunk@81 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Javier Fontán Muiños 2008-07-28 14:54:32 +00:00
parent b76f42a40a
commit a2c38fc76d

View File

@ -83,11 +83,14 @@ class SSHAction
@finished @finished
end end
def run def run(action_mutex, action_cond)
@thread=Thread.new { @thread=Thread.new {
run_actions run_actions
@finished=true @finished=true
} action_mutex.synchronize {
action_cond.signal
}
}
end end
def run_actions def run_actions
@ -122,21 +125,27 @@ module SSHActionController
def send_ssh_action(number, host, action) def send_ssh_action(number, host, action)
@action_mutex.synchronize { @action_mutex.synchronize {
action.run action.run(@action_mutex, @action_cond)
@actions << action @actions << action
@action_cond.signal
} }
end end
def action_finalize(args)
@action_thread.kill!
super(args)
end
def start_action_thread def start_action_thread
@action_thread=Thread.new { @action_thread=Thread.new {
while true while true
done_actions=nil
@action_mutex.synchronize { @action_mutex.synchronize {
@action_cond.wait(mutex) @action_cond.wait(@action_mutex)
done=@actions.delete_if{|a| a.finished } done_actions=@actions.select{|a| a.finished }
@actions-=done_actions if done_actions
} }
if done if done_actions
done.exec_callbacks done_actions.each {|action| action.exec_callbacks }
end end
end end
} }