Browse code

Revendor go-winio to v0.4.1

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2017/05/20 08:13:52
Showing 3 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 # the following lines are in sorted order, FYI
2 2
 github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62
3 3
 github.com/Microsoft/hcsshim v0.5.17
4
-github.com/Microsoft/go-winio v0.4.0
4
+github.com/Microsoft/go-winio v0.4.1
5 5
 github.com/Sirupsen/logrus v0.11.0
6 6
 github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76
7 7
 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
... ...
@@ -124,7 +124,8 @@ func (f *win32File) Close() error {
124 124
 	return nil
125 125
 }
126 126
 
127
-// prepareIo prepares for a new IO operation
127
+// prepareIo prepares for a new IO operation.
128
+// The caller must call f.wg.Done() when the IO is finished, prior to Close() returning.
128 129
 func (f *win32File) prepareIo() (*ioOperation, error) {
129 130
 	f.wg.Add(1)
130 131
 	if f.closing {
... ...
@@ -155,7 +156,6 @@ func ioCompletionProcessor(h syscall.Handle) {
155 155
 // the operation has actually completed.
156 156
 func (f *win32File) asyncIo(c *ioOperation, d *deadlineHandler, bytes uint32, err error) (int, error) {
157 157
 	if err != syscall.ERROR_IO_PENDING {
158
-		f.wg.Done()
159 158
 		return int(bytes), err
160 159
 	}
161 160
 
... ...
@@ -192,7 +192,6 @@ func (f *win32File) asyncIo(c *ioOperation, d *deadlineHandler, bytes uint32, er
192 192
 	// code to ioCompletionProcessor, c must remain alive
193 193
 	// until the channel read is complete.
194 194
 	runtime.KeepAlive(c)
195
-	f.wg.Done()
196 195
 	return int(r.bytes), err
197 196
 }
198 197
 
... ...
@@ -202,6 +201,7 @@ func (f *win32File) Read(b []byte) (int, error) {
202 202
 	if err != nil {
203 203
 		return 0, err
204 204
 	}
205
+	defer f.wg.Done()
205 206
 
206 207
 	if f.readDeadline.timedout.isSet() {
207 208
 		return 0, ErrTimeout
... ...
@@ -228,6 +228,8 @@ func (f *win32File) Write(b []byte) (int, error) {
228 228
 	if err != nil {
229 229
 		return 0, err
230 230
 	}
231
+	defer f.wg.Done()
232
+
231 233
 	if f.writeDeadline.timedout.isSet() {
232 234
 		return 0, ErrTimeout
233 235
 	}
... ...
@@ -367,6 +367,8 @@ func connectPipe(p *win32File) error {
367 367
 	if err != nil {
368 368
 		return err
369 369
 	}
370
+	defer p.wg.Done()
371
+
370 372
 	err = connectNamedPipe(p.handle, &c.o)
371 373
 	_, err = p.asyncIo(c, nil, 0, err)
372 374
 	if err != nil && err != cERROR_PIPE_CONNECTED {