build(deps): bump github.com/alexflint/go-filemutex from 1.1.0 to 1.2.0
Bumps [github.com/alexflint/go-filemutex](https://github.com/alexflint/go-filemutex) from 1.1.0 to 1.2.0. - [Release notes](https://github.com/alexflint/go-filemutex/releases) - [Commits](https://github.com/alexflint/go-filemutex/compare/v1.1...v1.2.0) --- updated-dependencies: - dependency-name: github.com/alexflint/go-filemutex dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
90ed30a55a
commit
615420fa9f
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.17
|
||||
|
||||
require (
|
||||
github.com/Microsoft/hcsshim v0.9.6
|
||||
github.com/alexflint/go-filemutex v1.1.0
|
||||
github.com/alexflint/go-filemutex v1.2.0
|
||||
github.com/buger/jsonparser v1.1.1
|
||||
github.com/containernetworking/cni v1.0.1
|
||||
github.com/coreos/go-iptables v0.6.0
|
||||
|
5
go.sum
5
go.sum
@ -70,8 +70,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0=
|
||||
github.com/alexflint/go-filemutex v1.1.0 h1:IAWuUuRYL2hETx5b8vCgwnD+xSdlsTQY6s2JjBsqLdg=
|
||||
github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk=
|
||||
github.com/alexflint/go-filemutex v1.2.0 h1:1v0TJPDtlhgpW4nJ+GvxCLSlUDC3+gW0CQQvlmfDR/s=
|
||||
github.com/alexflint/go-filemutex v1.2.0/go.mod h1:mYyQSWvw9Tx2/H2n9qXPb52tTYfE0pZAWcBq5mK025c=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
@ -879,6 +879,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
38
vendor/github.com/alexflint/go-filemutex/filemutex_flock.go
generated
vendored
38
vendor/github.com/alexflint/go-filemutex/filemutex_flock.go
generated
vendored
@ -2,13 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package filemutex
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
mkdirPerm = 0750
|
||||
@ -21,7 +19,7 @@ type FileMutex struct {
|
||||
}
|
||||
|
||||
func New(filename string) (*FileMutex, error) {
|
||||
fd, err := syscall.Open(filename, syscall.O_CREAT|syscall.O_RDONLY, mkdirPerm)
|
||||
fd, err := unix.Open(filename, unix.O_CREAT|unix.O_RDONLY, mkdirPerm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -29,16 +27,13 @@ func New(filename string) (*FileMutex, error) {
|
||||
}
|
||||
|
||||
func (m *FileMutex) Lock() error {
|
||||
if err := syscall.Flock(m.fd, syscall.LOCK_EX); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return unix.Flock(m.fd, unix.LOCK_EX)
|
||||
}
|
||||
|
||||
func (m *FileMutex) TryLock() error {
|
||||
if err := syscall.Flock(m.fd, syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
|
||||
if errno, ok := err.(syscall.Errno); ok {
|
||||
if errno == syscall.EWOULDBLOCK {
|
||||
if err := unix.Flock(m.fd, unix.LOCK_EX|unix.LOCK_NB); err != nil {
|
||||
if errno, ok := err.(unix.Errno); ok {
|
||||
if errno == unix.EWOULDBLOCK {
|
||||
return AlreadyLocked
|
||||
}
|
||||
}
|
||||
@ -48,30 +43,21 @@ func (m *FileMutex) TryLock() error {
|
||||
}
|
||||
|
||||
func (m *FileMutex) Unlock() error {
|
||||
if err := syscall.Flock(m.fd, syscall.LOCK_UN); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return unix.Flock(m.fd, unix.LOCK_UN)
|
||||
}
|
||||
|
||||
func (m *FileMutex) RLock() error {
|
||||
if err := syscall.Flock(m.fd, syscall.LOCK_SH); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return unix.Flock(m.fd, unix.LOCK_SH)
|
||||
}
|
||||
|
||||
func (m *FileMutex) RUnlock() error {
|
||||
if err := syscall.Flock(m.fd, syscall.LOCK_UN); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return unix.Flock(m.fd, unix.LOCK_UN)
|
||||
}
|
||||
|
||||
// Close unlocks the lock and closes the underlying file descriptor.
|
||||
func (m *FileMutex) Close() error {
|
||||
if err := syscall.Flock(m.fd, syscall.LOCK_UN); err != nil {
|
||||
if err := unix.Flock(m.fd, unix.LOCK_UN); err != nil {
|
||||
return err
|
||||
}
|
||||
return syscall.Close(m.fd)
|
||||
return unix.Close(m.fd)
|
||||
}
|
||||
|
81
vendor/github.com/alexflint/go-filemutex/filemutex_windows.go
generated
vendored
81
vendor/github.com/alexflint/go-filemutex/filemutex_windows.go
generated
vendored
@ -6,53 +6,22 @@ package filemutex
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
procLockFileEx = modkernel32.NewProc("LockFileEx")
|
||||
procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
|
||||
)
|
||||
|
||||
const (
|
||||
lockfileFailImmediately = 1
|
||||
lockfileExclusiveLock = 2
|
||||
)
|
||||
|
||||
func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(h), uintptr(flags), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)))
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = error(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func unlockFileEx(h syscall.Handle, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(h), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)), 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = error(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
// see https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
|
||||
var errLockUnlocked syscall.Errno = 0x9E
|
||||
|
||||
// FileMutex is similar to sync.RWMutex, but also synchronizes across processes.
|
||||
// This implementation is based on flock syscall.
|
||||
type FileMutex struct {
|
||||
fd syscall.Handle
|
||||
fd windows.Handle
|
||||
}
|
||||
|
||||
func New(filename string) (*FileMutex, error) {
|
||||
fd, err := syscall.CreateFile(&(syscall.StringToUTF16(filename)[0]), syscall.GENERIC_READ|syscall.GENERIC_WRITE,
|
||||
syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE, nil, syscall.OPEN_ALWAYS, syscall.FILE_ATTRIBUTE_NORMAL, 0)
|
||||
fd, err := windows.CreateFile(&(windows.StringToUTF16(filename)[0]), windows.GENERIC_READ|windows.GENERIC_WRITE,
|
||||
windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE, nil, windows.OPEN_ALWAYS, windows.FILE_ATTRIBUTE_NORMAL, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -60,10 +29,9 @@ func New(filename string) (*FileMutex, error) {
|
||||
}
|
||||
|
||||
func (m *FileMutex) TryLock() error {
|
||||
var ol syscall.Overlapped
|
||||
if err := lockFileEx(m.fd, lockfileFailImmediately|lockfileExclusiveLock, 0, 1, 0, &ol); err != nil {
|
||||
if errno, ok := err.(syscall.Errno); ok {
|
||||
if errno == syscall.Errno(0x21) {
|
||||
if err := windows.LockFileEx(m.fd, windows.LOCKFILE_FAIL_IMMEDIATELY|windows.LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &windows.Overlapped{}); err != nil {
|
||||
if errno, ok := err.(windows.Errno); ok {
|
||||
if errno == windows.ERROR_LOCK_VIOLATION {
|
||||
return AlreadyLocked
|
||||
}
|
||||
}
|
||||
@ -73,42 +41,25 @@ func (m *FileMutex) TryLock() error {
|
||||
}
|
||||
|
||||
func (m *FileMutex) Lock() error {
|
||||
var ol syscall.Overlapped
|
||||
if err := lockFileEx(m.fd, lockfileExclusiveLock, 0, 1, 0, &ol); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return windows.LockFileEx(m.fd, windows.LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &windows.Overlapped{})
|
||||
}
|
||||
|
||||
func (m *FileMutex) Unlock() error {
|
||||
var ol syscall.Overlapped
|
||||
if err := unlockFileEx(m.fd, 0, 1, 0, &ol); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return windows.UnlockFileEx(m.fd, 0, 1, 0, &windows.Overlapped{})
|
||||
}
|
||||
|
||||
func (m *FileMutex) RLock() error {
|
||||
var ol syscall.Overlapped
|
||||
if err := lockFileEx(m.fd, 0, 0, 1, 0, &ol); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return windows.LockFileEx(m.fd, 0, 0, 1, 0, &windows.Overlapped{})
|
||||
}
|
||||
|
||||
func (m *FileMutex) RUnlock() error {
|
||||
var ol syscall.Overlapped
|
||||
if err := unlockFileEx(m.fd, 0, 1, 0, &ol); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return windows.UnlockFileEx(m.fd, 0, 1, 0, &windows.Overlapped{})
|
||||
}
|
||||
|
||||
// Close unlocks the lock and closes the underlying file descriptor.
|
||||
func (m *FileMutex) Close() error {
|
||||
var ol syscall.Overlapped
|
||||
if err := unlockFileEx(m.fd, 0, 1, 0, &ol); err != nil {
|
||||
if err := windows.UnlockFileEx(m.fd, 0, 1, 0, &windows.Overlapped{}); err != nil && err != errLockUnlocked {
|
||||
return err
|
||||
}
|
||||
return syscall.Close(m.fd)
|
||||
return windows.Close(m.fd)
|
||||
}
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -32,7 +32,7 @@ github.com/Microsoft/hcsshim/internal/vmcompute
|
||||
github.com/Microsoft/hcsshim/internal/wclayer
|
||||
github.com/Microsoft/hcsshim/internal/winapi
|
||||
github.com/Microsoft/hcsshim/osversion
|
||||
# github.com/alexflint/go-filemutex v1.1.0
|
||||
# github.com/alexflint/go-filemutex v1.2.0
|
||||
## explicit; go 1.13
|
||||
github.com/alexflint/go-filemutex
|
||||
# github.com/buger/jsonparser v1.1.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user