зеркало из https://github.com/microsoft/docker.git
vendor: update fifo to 14056439
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Родитель
c16860b649
Коммит
bebfcade04
|
@ -97,7 +97,7 @@ github.com/docker/docker-credential-helpers f72c04f1d8e71959a6d103f808c50ccbad79
|
|||
|
||||
# containerd
|
||||
github.com/docker/containerd 52ef1ceb4b660c42cf4ea9013180a5663968d4c7
|
||||
github.com/tonistiigi/fifo b4c3a126bac4051ae3fa83bfcb3c60ab7a9da0dd
|
||||
github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4
|
||||
|
||||
# cluster
|
||||
github.com/docker/swarmkit 2eaae1ab6800f8521236e01bafb2667d2ec5371f
|
||||
|
|
|
@ -97,7 +97,7 @@ func OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.Re
|
|||
case <-ctx.Done():
|
||||
err = ctx.Err()
|
||||
default:
|
||||
err = errors.Errorf("fifo %v was closed before opening", fn)
|
||||
err = errors.Errorf("fifo %v was closed before opening", h.Name())
|
||||
}
|
||||
if file != nil {
|
||||
file.Close()
|
||||
|
@ -163,17 +163,18 @@ func (f *fifo) Write(b []byte) (int, error) {
|
|||
|
||||
// Close the fifo. Next reads/writes will error. This method can also be used
|
||||
// before open(2) has returned and fifo was never opened.
|
||||
func (f *fifo) Close() error {
|
||||
func (f *fifo) Close() (retErr error) {
|
||||
for {
|
||||
select {
|
||||
case <-f.closed:
|
||||
f.handle.Close()
|
||||
return f.err
|
||||
return
|
||||
default:
|
||||
select {
|
||||
case <-f.opened:
|
||||
f.closedOnce.Do(func() {
|
||||
f.err = f.file.Close()
|
||||
retErr = f.file.Close()
|
||||
f.err = retErr
|
||||
close(f.closed)
|
||||
})
|
||||
default:
|
||||
|
|
|
@ -18,6 +18,7 @@ type handle struct {
|
|||
dev uint64
|
||||
ino uint64
|
||||
closeOnce sync.Once
|
||||
name string
|
||||
}
|
||||
|
||||
func getHandle(fn string) (*handle, error) {
|
||||
|
@ -33,9 +34,10 @@ func getHandle(fn string) (*handle, error) {
|
|||
}
|
||||
|
||||
h := &handle{
|
||||
f: f,
|
||||
dev: stat.Dev,
|
||||
ino: stat.Ino,
|
||||
f: f,
|
||||
name: fn,
|
||||
dev: stat.Dev,
|
||||
ino: stat.Ino,
|
||||
}
|
||||
|
||||
// check /proc just in case
|
||||
|
@ -51,6 +53,10 @@ func (h *handle) procPath() string {
|
|||
return fmt.Sprintf("/proc/self/fd/%d", h.f.Fd())
|
||||
}
|
||||
|
||||
func (h *handle) Name() string {
|
||||
return h.name
|
||||
}
|
||||
|
||||
func (h *handle) Path() (string, error) {
|
||||
var stat syscall.Stat_t
|
||||
if err := syscall.Stat(h.procPath(), &stat); err != nil {
|
||||
|
|
|
@ -35,11 +35,15 @@ func (h *handle) Path() (string, error) {
|
|||
return "", errors.Wrapf(err, "path %v could not be statted", h.fn)
|
||||
}
|
||||
if uint64(stat.Dev) != h.dev || stat.Ino != h.ino {
|
||||
return "", errors.Errorf("failed to verify handle %v/%v %v/%v", stat.Dev, h.dev, stat.Ino, h.ino)
|
||||
return "", errors.Errorf("failed to verify handle %v/%v %v/%v for %v", stat.Dev, h.dev, stat.Ino, h.ino, h.fn)
|
||||
}
|
||||
return h.fn, nil
|
||||
}
|
||||
|
||||
func (h *handle) Name() string {
|
||||
return h.fn
|
||||
}
|
||||
|
||||
func (h *handle) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче