builder/amazon/chroot: block when obtaining lock [GH-689]

This commit is contained in:
Mitchell Hashimoto 2013-12-06 18:28:48 -08:00
parent 2385f087be
commit 2dad0cdca7
3 changed files with 4 additions and 7 deletions

View File

@ -11,6 +11,8 @@ BUG FIXES:
* core: Don't change background color on CLI anymore, making things look
a tad nicer in some terminals.
* builder/amazon/chroot: Block when obtaining file lock to allow
parallel builds. [GH-689]
* builder/vmware: Cleanup of VMX keys works properly so cd-rom won't
get stuck with ISO. [GH-685]

View File

@ -14,13 +14,8 @@ const LOCK_NB = 4
const LOCK_UN = 8
func lockFile(f *os.File) error {
err := syscall.Flock(int(f.Fd()), LOCK_EX|LOCK_NB)
err := syscall.Flock(int(f.Fd()), LOCK_EX)
if err != nil {
errno, ok := err.(syscall.Errno)
if ok && errno == syscall.EWOULDBLOCK {
return errors.New("file already locked")
}
return err
}

View File

@ -39,7 +39,7 @@ func (s *StepFlock) Run(state multistep.StateBag) multistep.StepAction {
// LOCK!
if err := lockFile(f); err != nil {
err := fmt.Errorf("Error creating lock: %s", err)
err := fmt.Errorf("Error obtaining lock: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt