Procházet zdrojové kódy

vendor: update fifo to fe870ccf2

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi před 8 roky
rodič
revize
06092267aa

+ 1 - 1
hack/vendor.sh

@@ -137,7 +137,7 @@ clone git github.com/docker/docker-credential-helpers v0.3.0
 
 # containerd
 clone git github.com/docker/containerd 0366d7e9693c930cf18c0f50cc16acec064e96c5
-clone git github.com/tonistiigi/fifo 8c56881ce5e63e19e2dfc495c8af0fb90916467d
+clone git github.com/tonistiigi/fifo fe870ccf293940774c2b44e23f6c71fff8f7547d
 
 # cluster
 clone git github.com/docker/swarmkit 0cf248feec033f46dc09db40d69fd5128082b79a

+ 7 - 6
vendor/src/github.com/tonistiigi/fifo/fifo.go

@@ -1,7 +1,6 @@
 package fifo
 
 import (
-	"context"
 	"io"
 	"os"
 	"runtime"
@@ -9,6 +8,7 @@ import (
 	"syscall"
 
 	"github.com/pkg/errors"
+	"golang.org/x/net/context"
 )
 
 type fifo struct {
@@ -38,7 +38,7 @@ var leakCheckWg *sync.WaitGroup
 func OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.ReadWriteCloser, error) {
 	if _, err := os.Stat(fn); err != nil {
 		if os.IsNotExist(err) && flag&syscall.O_CREAT != 0 {
-			if err := syscall.Mkfifo(fn, uint32(perm&os.ModePerm)); err != nil && !os.IsExist(err) {
+			if err := mkfifo(fn, uint32(perm&os.ModePerm)); err != nil && !os.IsExist(err) {
 				return nil, errors.Wrapf(err, "error creating fifo %v", fn)
 			}
 		} else {
@@ -96,7 +96,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()
@@ -162,17 +162,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:

+ 9 - 3
vendor/src/github.com/tonistiigi/fifo/handle_linux.go

@@ -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 {

+ 5 - 1
vendor/src/github.com/tonistiigi/fifo/handle_nolinux.go

@@ -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
 }

+ 9 - 0
vendor/src/github.com/tonistiigi/fifo/mkfifo_nosolaris.go

@@ -0,0 +1,9 @@
+// +build !solaris
+
+package fifo
+
+import "syscall"
+
+func mkfifo(path string, mode uint32) (err error) {
+	return syscall.Mkfifo(path, mode)
+}

+ 11 - 0
vendor/src/github.com/tonistiigi/fifo/mkfifo_solaris.go

@@ -0,0 +1,11 @@
+// +build solaris
+
+package fifo
+
+import (
+	"golang.org/x/sys/unix"
+)
+
+func mkfifo(path string, mode uint32) (err error) {
+	return unix.Mkfifo(path, mode)
+}