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>
| ... | ... |
@@ -34,7 +34,7 @@ github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3 |
| 34 | 34 |
github.com/google/shlex e7afc7fbc51079733e9468cdfd1efcd7d196cd1d |
| 35 | 35 |
github.com/opentracing-contrib/go-stdlib b1a47cfbdd7543e70e9ef3e73d0802ad306cc1cc |
| 36 | 36 |
github.com/mitchellh/hashstructure 2bca23e0e452137f789efbc8610126fd8b94f73b |
| 37 |
-github.com/gofrs/flock 392e7fae8f1b0bdbd67dad7237d23f618feb6dbb # v0.7.1 |
|
| 37 |
+github.com/gofrs/flock 6caa7350c26b838538005fae7dbee4e69d9398db # v0.7.3 |
|
| 38 | 38 |
github.com/grpc-ecosystem/go-grpc-middleware 3c51f7f332123e8be5a157c0802a228ac85bf9db # v1.2.0 |
| 39 | 39 |
|
| 40 | 40 |
# libnetwork |
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-Copyright (c) 2015, Tim Heckman |
|
| 1 |
+Copyright (c) 2015-2020, Tim Heckman |
|
| 2 | 2 |
All rights reserved. |
| 3 | 3 |
|
| 4 | 4 |
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: |
| 11 | 11 |
this list of conditions and the following disclaimer in the documentation |
| 12 | 12 |
and/or other materials provided with the distribution. |
| 13 | 13 |
|
| 14 |
-* Neither the name of linode-netint nor the names of its |
|
| 15 |
- contributors may be used to endorse or promote products derived from |
|
| 16 |
- this software without specific prior written permission. |
|
| 14 |
+* Neither the name of gofrs nor the names of its contributors may be used |
|
| 15 |
+ to endorse or promote products derived from this software without |
|
| 16 |
+ specific prior written permission. |
|
| 17 | 17 |
|
| 18 | 18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | 19 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
# flock |
| 2 | 2 |
[](https://travis-ci.org/gofrs/flock) |
| 3 |
-[](https://godoc.org/github.com/gofrs/flock) |
|
| 3 |
+[](https://godoc.org/github.com/gofrs/flock) |
|
| 4 | 4 |
[](https://github.com/gofrs/flock/blob/master/LICENSE) |
| 5 | 5 |
[](https://goreportcard.com/report/github.com/gofrs/flock) |
| 6 | 6 |
|
| ... | ... |
@@ -125,3 +125,11 @@ func (f *Flock) setFh() error {
|
| 125 | 125 |
f.fh = fh |
| 126 | 126 |
return nil |
| 127 | 127 |
} |
| 128 |
+ |
|
| 129 |
+// ensure the file handle is closed if no lock is held |
|
| 130 |
+func (f *Flock) ensureFhState() {
|
|
| 131 |
+ if !f.l && !f.r && f.fh != nil {
|
|
| 132 |
+ f.fh.Close() |
|
| 133 |
+ f.fh = nil |
|
| 134 |
+ } |
|
| 135 |
+} |
| ... | ... |
@@ -51,6 +51,7 @@ func (f *Flock) lock(locked *bool, flag int) error {
|
| 51 | 51 |
if err := f.setFh(); err != nil {
|
| 52 | 52 |
return err |
| 53 | 53 |
} |
| 54 |
+ defer f.ensureFhState() |
|
| 54 | 55 |
} |
| 55 | 56 |
|
| 56 | 57 |
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) {
|
| 142 | 142 |
if err := f.setFh(); err != nil {
|
| 143 | 143 |
return false, err |
| 144 | 144 |
} |
| 145 |
+ defer f.ensureFhState() |
|
| 145 | 146 |
} |
| 146 | 147 |
|
| 147 | 148 |
var retried bool |
| ... | ... |
@@ -46,6 +46,7 @@ func (f *Flock) lock(locked *bool, flag uint32) error {
|
| 46 | 46 |
if err := f.setFh(); err != nil {
|
| 47 | 47 |
return err |
| 48 | 48 |
} |
| 49 |
+ defer f.ensureFhState() |
|
| 49 | 50 |
} |
| 50 | 51 |
|
| 51 | 52 |
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) {
|
| 122 | 122 |
if err := f.setFh(); err != nil {
|
| 123 | 123 |
return false, err |
| 124 | 124 |
} |
| 125 |
+ defer f.ensureFhState() |
|
| 125 | 126 |
} |
| 126 | 127 |
|
| 127 | 128 |
_, errNo := lockFileEx(syscall.Handle(f.fh.Fd()), flag|winLockfileFailImmediately, 0, 1, 0, &syscall.Overlapped{})
|