vendor: update buildkit to v0.15.1

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-07-25 15:57:49 +02:00
parent d4c4632cf6
commit 0fb0b6db0d
17 changed files with 183 additions and 33 deletions

View File

@ -1,7 +1,7 @@
# flock
[![Go Reference](https://pkg.go.dev/badge/github.com/gofrs/flock.svg)](https://pkg.go.dev/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/main/LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/flock)](https://goreportcard.com/report/github.com/gofrs/flock)
`flock` implements a thread-safe file lock.

View File

@ -163,9 +163,9 @@ func tryCtx(ctx context.Context, fn func() (bool, error), retryDelay time.Durati
}
}
func (f *Flock) setFh() error {
func (f *Flock) setFh(flag int) error {
// open a new os.File instance
fh, err := os.OpenFile(f.path, f.flag, f.perm)
fh, err := os.OpenFile(f.path, flag, f.perm)
if err != nil {
return err
}
@ -176,9 +176,11 @@ func (f *Flock) setFh() error {
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 {
// resetFh resets file handle:
// - tries to close the file (ignore errors)
// - sets fh to nil.
func (f *Flock) resetFh() {
if f.fh == nil {
return
}
@ -187,11 +189,18 @@ func (f *Flock) ensureFhState() {
f.fh = nil
}
// ensure the file handle is closed if no lock is held.
func (f *Flock) ensureFhState() {
if f.l || f.r || f.fh == nil {
return
}
f.resetFh()
}
func (f *Flock) reset() {
f.l = false
f.r = false
_ = f.fh.Close()
f.fh = nil
f.resetFh()
}

View File

@ -50,7 +50,7 @@ func (f *Flock) lock(locked *bool, flag int) error {
}
if f.fh == nil {
if err := f.setFh(); err != nil {
if err := f.setFh(f.flag); err != nil {
return err
}
@ -147,7 +147,7 @@ func (f *Flock) try(locked *bool, flag int) (bool, error) {
}
if f.fh == nil {
if err := f.setFh(); err != nil {
if err := f.setFh(f.flag); err != nil {
return false, err
}
@ -183,6 +183,7 @@ retry:
// This comes from `util-linux/sys-utils/flock.c`:
// > Since Linux 3.4 (commit 55725513)
// > Probably NFSv4 where flock() is emulated by fcntl().
// > https://github.com/util-linux/util-linux/blob/198e920aa24743ef6ace4e07cf6237de527f9261/sys-utils/flock.c#L374-L390
func (f *Flock) reopenFDOnError(err error) (bool, error) {
if !errors.Is(err, unix.EIO) && !errors.Is(err, unix.EBADF) {
return false, nil
@ -197,16 +198,13 @@ func (f *Flock) reopenFDOnError(err error) (bool, error) {
return false, nil
}
_ = f.fh.Close()
f.fh = nil
f.resetFh()
// reopen in read-write mode and set the file handle
fh, err := os.OpenFile(f.path, f.flag, f.perm)
err = f.setFh(f.flag | os.O_RDWR)
if err != nil {
return false, err
}
f.fh = fh
return true, nil
}

View File

@ -112,7 +112,7 @@ func (f *Flock) lock(locked *bool, flag lockType) error {
}
if f.fh == nil {
if err := f.setFh(); err != nil {
if err := f.setFh(f.flag); err != nil {
return err
}
@ -359,7 +359,7 @@ func (f *Flock) try(locked *bool, flag lockType) (bool, error) {
}
if f.fh == nil {
if err := f.setFh(); err != nil {
if err := f.setFh(f.flag); err != nil {
return false, err
}

View File

@ -56,7 +56,7 @@ func (f *Flock) lock(locked *bool, flag uint32) error {
}
if f.fh == nil {
if err := f.setFh(); err != nil {
if err := f.setFh(f.flag); err != nil {
return err
}
@ -136,7 +136,7 @@ func (f *Flock) try(locked *bool, flag uint32) (bool, error) {
}
if f.fh == nil {
if err := f.setFh(); err != nil {
if err := f.setFh(f.flag); err != nil {
return false, err
}