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:
![49699333+dependabot[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
Matthieu MOREL

parent
90ed30a55a
commit
615420fa9f
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user