core: retry acquire of dotlock [GH-3735]
This commit is contained in:
parent
2a973df440
commit
9c684ad2b7
|
@ -19,6 +19,8 @@ BUG FIXES:
|
||||||
- core: Don't lock machines on SSH actions. [GH-3664]
|
- core: Don't lock machines on SSH actions. [GH-3664]
|
||||||
- core: Fixed crash when adding a box from Vagrant Cloud that was the
|
- core: Fixed crash when adding a box from Vagrant Cloud that was the
|
||||||
same name as a real directory. [GH-3732]
|
same name as a real directory. [GH-3732]
|
||||||
|
- core: Parallelization is more stable, doesn't crash due to to
|
||||||
|
bad locks. [GH-3735]
|
||||||
- provisioners/shell: Fix shell provisioner config validation when the
|
- provisioners/shell: Fix shell provisioner config validation when the
|
||||||
`binary` option is set to false [GH-3712]
|
`binary` option is set to false [GH-3712]
|
||||||
- providers/docker: default proxy VM won't use HGFS [GH-3687]
|
- providers/docker: default proxy VM won't use HGFS [GH-3687]
|
||||||
|
|
|
@ -403,17 +403,22 @@ module Vagrant
|
||||||
lock_path = data_dir.join("lock.#{name}.lock")
|
lock_path = data_dir.join("lock.#{name}.lock")
|
||||||
|
|
||||||
@logger.debug("Attempting to acquire process-lock: #{name}")
|
@logger.debug("Attempting to acquire process-lock: #{name}")
|
||||||
lock("dotlock", noop: name == "dotlock") do
|
lock("dotlock", noop: name == "dotlock", retry: true) do
|
||||||
f = File.open(lock_path, "w+")
|
f = File.open(lock_path, "w+")
|
||||||
end
|
end
|
||||||
|
|
||||||
# The file locking fails only if it returns "false." If it
|
# The file locking fails only if it returns "false." If it
|
||||||
# succeeds it returns a 0, so we must explicitly check for
|
# succeeds it returns a 0, so we must explicitly check for
|
||||||
# the proper error case.
|
# the proper error case.
|
||||||
if f.flock(File::LOCK_EX | File::LOCK_NB) === false
|
while f.flock(File::LOCK_EX | File::LOCK_NB) === false
|
||||||
@logger.warn("Process-lock in use: #{name}")
|
@logger.warn("Process-lock in use: #{name}")
|
||||||
raise Errors::EnvironmentLockedError,
|
|
||||||
name: name
|
if !opts[:retry]
|
||||||
|
raise Errors::EnvironmentLockedError,
|
||||||
|
name: name
|
||||||
|
end
|
||||||
|
|
||||||
|
sleep 0.2
|
||||||
end
|
end
|
||||||
|
|
||||||
@logger.info("Acquired process lock: #{name}")
|
@logger.info("Acquired process lock: #{name}")
|
||||||
|
@ -434,7 +439,7 @@ module Vagrant
|
||||||
|
|
||||||
# Clean up the lock file, this requires another lock
|
# Clean up the lock file, this requires another lock
|
||||||
if name != "dotlock"
|
if name != "dotlock"
|
||||||
lock("dotlock") do
|
lock("dotlock", retry: true) do
|
||||||
f.close
|
f.close
|
||||||
File.delete(lock_path)
|
File.delete(lock_path)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue