From 9146b2ef35cbe69f77dcea8e5435498db6823564 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 15 Oct 2013 10:57:56 +0200 Subject: [PATCH] im-collectd: Add mutex to the sync command --- src/cli/one_helper/onehost_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 700fd74f23..970414c86d 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -189,12 +189,19 @@ class OneHostHelper < OpenNebulaHelper::OneHelper end host_errors = Array.new + lock = Mutex.new + ts = hs_threads.map do |t| Thread.new { t.each do |host| sync_cmd = "scp -rp #{REMOTES_LOCATION}/. #{host}:#{remote_dir} 2> /dev/null" `#{sync_cmd} 2>/dev/null` - host_errors << host if !$?.success? + + if !$?.success? + lock.synchronize { + host_errors << host + } + end end } end