mirror of https://github.com/docker/cli.git
vendor: github.com/gofrs/flock v0.7.3
full diff: https://github.com/gofrs/flock/compare/v0.7.1...v0.7.3 Relevant changes: - fix: close/Unlock won't close the file descriptor if not locked - fix license text, update year Note that there's also a v0.8.0 release; that release only adds aix support, which is currently of no interest to us, so skipping that version for now. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
15c928eae1
commit
ceffcc527e
|
@ -23,7 +23,7 @@ github.com/docker/go-units 519db1ee28dcc9fd2474ae59fca2
|
||||||
github.com/docker/swarmkit d6592ddefd8a5319aadff74c558b816b1a0b2590
|
github.com/docker/swarmkit d6592ddefd8a5319aadff74c558b816b1a0b2590
|
||||||
github.com/evanphx/json-patch 72bf35d0ff611848c1dc9df0f976c81192392fa5 # v4.1.0
|
github.com/evanphx/json-patch 72bf35d0ff611848c1dc9df0f976c81192392fa5 # v4.1.0
|
||||||
github.com/fvbommel/sortorder a1ddee917217bbd0691affdca9c88d24d3f5c27d # v1.0.1
|
github.com/fvbommel/sortorder a1ddee917217bbd0691affdca9c88d24d3f5c27d # v1.0.1
|
||||||
github.com/gofrs/flock 392e7fae8f1b0bdbd67dad7237d23f618feb6dbb # v0.7.1
|
github.com/gofrs/flock 6caa7350c26b838538005fae7dbee4e69d9398db # v0.7.3
|
||||||
github.com/gogo/googleapis 01e0f9cca9b92166042241267ee2a5cdf5cff46c # v1.3.2
|
github.com/gogo/googleapis 01e0f9cca9b92166042241267ee2a5cdf5cff46c # v1.3.2
|
||||||
github.com/gogo/protobuf 5628607bb4c51c3157aacc3a50f0ab707582b805 # v1.3.1
|
github.com/gogo/protobuf 5628607bb4c51c3157aacc3a50f0ab707582b805 # v1.3.1
|
||||||
github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998
|
github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2015, Tim Heckman
|
Copyright (c) 2015-2020, Tim Heckman
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -11,9 +11,9 @@ modification, are permitted provided that the following conditions are met:
|
||||||
this list of conditions and the following disclaimer in the documentation
|
this list of conditions and the following disclaimer in the documentation
|
||||||
and/or other materials provided with the distribution.
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of linode-netint nor the names of its
|
* Neither the name of gofrs nor the names of its contributors may be used
|
||||||
contributors may be used to endorse or promote products derived from
|
to endorse or promote products derived from this software without
|
||||||
this software without specific prior written permission.
|
specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# flock
|
# flock
|
||||||
[![TravisCI Build Status](https://img.shields.io/travis/gofrs/flock/master.svg?style=flat)](https://travis-ci.org/gofrs/flock)
|
[![TravisCI Build Status](https://img.shields.io/travis/gofrs/flock/master.svg?style=flat)](https://travis-ci.org/gofrs/flock)
|
||||||
[![GoDoc](https://img.shields.io/badge/godoc-go--flock-blue.svg?style=flat)](https://godoc.org/github.com/gofrs/flock)
|
[![GoDoc](https://img.shields.io/badge/godoc-flock-blue.svg?style=flat)](https://godoc.org/github.com/gofrs/flock)
|
||||||
[![License](https://img.shields.io/badge/license-BSD_3--Clause-brightgreen.svg?style=flat)](https://github.com/gofrs/flock/blob/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-BSD_3--Clause-brightgreen.svg?style=flat)](https://github.com/gofrs/flock/blob/master/LICENSE)
|
||||||
[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/flock)](https://goreportcard.com/report/github.com/gofrs/flock)
|
[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/flock)](https://goreportcard.com/report/github.com/gofrs/flock)
|
||||||
|
|
||||||
|
|
|
@ -125,3 +125,11 @@ func (f *Flock) setFh() error {
|
||||||
f.fh = fh
|
f.fh = fh
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure the file handle is closed if no lock is held
|
||||||
|
func (f *Flock) ensureFhState() {
|
||||||
|
if !f.l && !f.r && f.fh != nil {
|
||||||
|
f.fh.Close()
|
||||||
|
f.fh = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ func (f *Flock) lock(locked *bool, flag int) error {
|
||||||
if err := f.setFh(); err != nil {
|
if err := f.setFh(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer f.ensureFhState()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := syscall.Flock(int(f.fh.Fd()), flag); err != nil {
|
if err := syscall.Flock(int(f.fh.Fd()), flag); err != nil {
|
||||||
|
@ -142,6 +143,7 @@ func (f *Flock) try(locked *bool, flag int) (bool, error) {
|
||||||
if err := f.setFh(); err != nil {
|
if err := f.setFh(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
defer f.ensureFhState()
|
||||||
}
|
}
|
||||||
|
|
||||||
var retried bool
|
var retried bool
|
||||||
|
|
|
@ -46,6 +46,7 @@ func (f *Flock) lock(locked *bool, flag uint32) error {
|
||||||
if err := f.setFh(); err != nil {
|
if err := f.setFh(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer f.ensureFhState()
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, errNo := lockFileEx(syscall.Handle(f.fh.Fd()), flag, 0, 1, 0, &syscall.Overlapped{}); errNo > 0 {
|
if _, errNo := lockFileEx(syscall.Handle(f.fh.Fd()), flag, 0, 1, 0, &syscall.Overlapped{}); errNo > 0 {
|
||||||
|
@ -122,6 +123,7 @@ func (f *Flock) try(locked *bool, flag uint32) (bool, error) {
|
||||||
if err := f.setFh(); err != nil {
|
if err := f.setFh(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
defer f.ensureFhState()
|
||||||
}
|
}
|
||||||
|
|
||||||
_, errNo := lockFileEx(syscall.Handle(f.fh.Fd()), flag|winLockfileFailImmediately, 0, 1, 0, &syscall.Overlapped{})
|
_, errNo := lockFileEx(syscall.Handle(f.fh.Fd()), flag|winLockfileFailImmediately, 0, 1, 0, &syscall.Overlapped{})
|
||||||
|
|
Loading…
Reference in New Issue