Merge pull request #41530 from thaJeztah/bump_flock

vendor: github.com/gofrs/flock v0.7.3
This commit is contained in:
Sebastiaan van Stijn 2020-10-07 23:51:34 +02:00 committed by GitHub
commit d6b1f2ae7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 6 deletions

View File

@ -34,7 +34,7 @@ github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3
github.com/google/shlex e7afc7fbc51079733e9468cdfd1efcd7d196cd1d
github.com/opentracing-contrib/go-stdlib b1a47cfbdd7543e70e9ef3e73d0802ad306cc1cc
github.com/mitchellh/hashstructure 2bca23e0e452137f789efbc8610126fd8b94f73b
github.com/gofrs/flock 392e7fae8f1b0bdbd67dad7237d23f618feb6dbb # v0.7.1
github.com/gofrs/flock 6caa7350c26b838538005fae7dbee4e69d9398db # v0.7.3
github.com/grpc-ecosystem/go-grpc-middleware 3c51f7f332123e8be5a157c0802a228ac85bf9db # v1.2.0
# libnetwork

View File

@ -1,4 +1,4 @@
Copyright (c) 2015, Tim Heckman
Copyright (c) 2015-2020, Tim Heckman
All rights reserved.
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
and/or other materials provided with the distribution.
* Neither the name of linode-netint nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
* Neither the name of gofrs nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

View File

@ -1,6 +1,6 @@
# 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)
[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/flock)](https://goreportcard.com/report/github.com/gofrs/flock)

View File

@ -125,3 +125,11 @@ func (f *Flock) setFh() error {
f.fh = fh
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
}
}

View File

@ -51,6 +51,7 @@ func (f *Flock) lock(locked *bool, flag int) error {
if err := f.setFh(); err != nil {
return err
}
defer f.ensureFhState()
}
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 {
return false, err
}
defer f.ensureFhState()
}
var retried bool

View File

@ -46,6 +46,7 @@ func (f *Flock) lock(locked *bool, flag uint32) error {
if err := f.setFh(); err != nil {
return err
}
defer f.ensureFhState()
}
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 {
return false, err
}
defer f.ensureFhState()
}
_, errNo := lockFileEx(syscall.Handle(f.fh.Fd()), flag|winLockfileFailImmediately, 0, 1, 0, &syscall.Overlapped{})