Browse code

Revendor Microsoft/go-winio @ v0.4.6

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2018/01/10 06:41:16
Showing 2 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 # the following lines are in sorted order, FYI
2 2
 github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
3 3
 github.com/Microsoft/hcsshim v0.6.8
4
-github.com/Microsoft/go-winio v0.4.5
4
+github.com/Microsoft/go-winio v0.4.6
5 5
 github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76
6 6
 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
7 7
 github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
... ...
@@ -22,6 +22,7 @@ import (
22 22
 
23 23
 const (
24 24
 	cERROR_PIPE_BUSY      = syscall.Errno(231)
25
+	cERROR_NO_DATA        = syscall.Errno(232)
25 26
 	cERROR_PIPE_CONNECTED = syscall.Errno(535)
26 27
 	cERROR_SEM_TIMEOUT    = syscall.Errno(121)
27 28
 
... ...
@@ -254,6 +255,36 @@ func (l *win32PipeListener) makeServerPipe() (*win32File, error) {
254 254
 	return f, nil
255 255
 }
256 256
 
257
+func (l *win32PipeListener) makeConnectedServerPipe() (*win32File, error) {
258
+	p, err := l.makeServerPipe()
259
+	if err != nil {
260
+		return nil, err
261
+	}
262
+
263
+	// Wait for the client to connect.
264
+	ch := make(chan error)
265
+	go func(p *win32File) {
266
+		ch <- connectPipe(p)
267
+	}(p)
268
+
269
+	select {
270
+	case err = <-ch:
271
+		if err != nil {
272
+			p.Close()
273
+			p = nil
274
+		}
275
+	case <-l.closeCh:
276
+		// Abort the connect request by closing the handle.
277
+		p.Close()
278
+		p = nil
279
+		err = <-ch
280
+		if err == nil || err == ErrFileClosed {
281
+			err = ErrPipeListenerClosed
282
+		}
283
+	}
284
+	return p, err
285
+}
286
+
257 287
 func (l *win32PipeListener) listenerRoutine() {
258 288
 	closed := false
259 289
 	for !closed {
... ...
@@ -261,31 +292,20 @@ func (l *win32PipeListener) listenerRoutine() {
261 261
 		case <-l.closeCh:
262 262
 			closed = true
263 263
 		case responseCh := <-l.acceptCh:
264
-			p, err := l.makeServerPipe()
265
-			if err == nil {
266
-				// Wait for the client to connect.
267
-				ch := make(chan error)
268
-				go func(p *win32File) {
269
-					ch <- connectPipe(p)
270
-				}(p)
271
-				select {
272
-				case err = <-ch:
273
-					if err != nil {
274
-						p.Close()
275
-						p = nil
276
-					}
277
-				case <-l.closeCh:
278
-					// Abort the connect request by closing the handle.
279
-					p.Close()
280
-					p = nil
281
-					err = <-ch
282
-					if err == nil || err == ErrFileClosed {
283
-						err = ErrPipeListenerClosed
284
-					}
285
-					closed = true
264
+			var (
265
+				p   *win32File
266
+				err error
267
+			)
268
+			for {
269
+				p, err = l.makeConnectedServerPipe()
270
+				// If the connection was immediately closed by the client, try
271
+				// again.
272
+				if err != cERROR_NO_DATA {
273
+					break
286 274
 				}
287 275
 			}
288 276
 			responseCh <- acceptResponse{p, err}
277
+			closed = err == ErrPipeListenerClosed
289 278
 		}
290 279
 	}
291 280
 	syscall.Close(l.firstHandle)