From 0ce636d1a31bbf7cf3f504c17b71b52a89c2f38b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 18 Nov 2015 16:07:25 -0800 Subject: [PATCH] core: avoid locking in trap context --- lib/vagrant/ui.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 89f412325..80adf2e88 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -123,9 +123,12 @@ module Vagrant data[i].gsub!("\r", "\\r") end - @lock.synchronize do - safe_puts("#{Time.now.utc.to_i},#{target},#{type},#{data.join(",")}") - end + # Avoid locks in a trap context introduced from Ruby 2.0 + Thread.new do + @lock.synchronize do + safe_puts("#{Time.now.utc.to_i},#{target},#{type},#{data.join(",")}") + end + end.join end end @@ -331,7 +334,6 @@ module Vagrant if @ui.is_a?(Vagrant::UI::MachineReadable) return machine(type, message, { :target => target }) end - # Otherwise, make sure to prefix every line properly lines.map do |line|