synced_folders/nfs: lock around sudo input [GH-2680]

This commit is contained in:
Mitchell Hashimoto 2013-12-30 14:45:40 -08:00
parent 757ad016b1
commit f89c4412b2
2 changed files with 12 additions and 3 deletions

View File

@ -18,6 +18,8 @@ BUG FIXES:
[GH-2714]
- commands/plugin: Fix exception that could happen rarely when installing
a plugin.
- synced\_folders/nfs: sudo will only ask for password one at a time
when using a parallel provider [GH-2680]
## 1.4.1 (December 18, 2013)

View File

@ -1,4 +1,5 @@
require 'fileutils'
require 'thread'
require 'zlib'
require "log4r"
@ -15,6 +16,8 @@ module VagrantPlugins
# will be mounted.
#
class SyncedFolder < Vagrant.plugin("2", :synced_folder)
@@lock = Mutex.new
def initialize(*args)
super
@ -41,9 +44,13 @@ module VagrantPlugins
# and such on the folder itself.
folders.each { |id, opts| prepare_folder(machine, opts) }
# Export the folders
machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
machine.env.host.nfs_export(machine.id, machine_ip, folders)
# Export the folders. We do this with a class-wide lock because
# NFS exporting often requires sudo privilege and we don't want
# overlapping input requests. [GH-2680]
@@lock.synchronize do
machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
machine.env.host.nfs_export(machine.id, machine_ip, folders)
end
# Mount
machine.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")