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:
parent
b76f42a40a
commit
a2c38fc76d
@ -83,11 +83,14 @@ class SSHAction
|
||||
@finished
|
||||
end
|
||||
|
||||
def run
|
||||
def run(action_mutex, action_cond)
|
||||
@thread=Thread.new {
|
||||
run_actions
|
||||
@finished=true
|
||||
}
|
||||
action_mutex.synchronize {
|
||||
action_cond.signal
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def run_actions
|
||||
@ -122,21 +125,27 @@ module SSHActionController
|
||||
|
||||
def send_ssh_action(number, host, action)
|
||||
@action_mutex.synchronize {
|
||||
action.run
|
||||
@actions << action
|
||||
@action_cond.signal
|
||||
action.run(@action_mutex, @action_cond)
|
||||
@actions << action
|
||||
}
|
||||
end
|
||||
|
||||
def action_finalize(args)
|
||||
@action_thread.kill!
|
||||
super(args)
|
||||
end
|
||||
|
||||
def start_action_thread
|
||||
@action_thread=Thread.new {
|
||||
while true
|
||||
done_actions=nil
|
||||
@action_mutex.synchronize {
|
||||
@action_cond.wait(mutex)
|
||||
done=@actions.delete_if{|a| a.finished }
|
||||
@action_cond.wait(@action_mutex)
|
||||
done_actions=@actions.select{|a| a.finished }
|
||||
@actions-=done_actions if done_actions
|
||||
}
|
||||
if done
|
||||
done.exec_callbacks
|
||||
if done_actions
|
||||
done_actions.each {|action| action.exec_callbacks }
|
||||
end
|
||||
end
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user