Lock around chdir in Subprocess for thread safety

This commit is contained in:
Mitchell Hashimoto 2013-03-21 21:43:50 -07:00
parent c84c609633
commit bd60d6b283
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,5 @@
require 'thread'
require 'childprocess'
require 'log4r'
@ -12,6 +14,8 @@ module Vagrant
# from the subprocess in real time, by simply passing a block to
# the execute method.
class Subprocess
@@chdir_lock = Mutex.new
# The chunk size for reading from subprocess IO.
READ_CHUNK_SIZE = 4096
@ -72,8 +76,10 @@ module Vagrant
# Start the process
begin
Dir.chdir(workdir) do
process.start
@@chdir_lock.synchronize do
Dir.chdir(workdir) do
process.start
end
end
rescue ChildProcess::LaunchError => ex
# Raise our own version of the error so that users of the class

View File

@ -7,6 +7,7 @@ module VagrantPlugins
end
def call(env)
raise "foo"
env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
:name => env[:machine].box.name)