summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-10-17 16:17:35 -0700
committerShentubot <shentubot@google.com>2018-10-17 16:18:39 -0700
commite0bb94201f1edb6ce649192fe4a62e1781940b50 (patch)
tree630a0ba1f14c91e24894904d0c6313dc7f9be93e /runsc
parentb2a88ff4713325fca736f6a3bf200be02d2d72a7 (diff)
Close the gofer socket gracefully in boot:boot_test.
We were closing the FD directly. If the test then created a new socket pair with the same FD, in-flight RPCs would get directed to the new socket and break the test. Instead, we should use unet.Socket.Close(), which allows any in-flight RPCs to finish. PiperOrigin-RevId: 217608491 Change-Id: I8c5a76638899ba30f33ca976e6fac967fa0aadbf
Diffstat (limited to 'runsc')
-rw-r--r--runsc/boot/loader_test.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/runsc/boot/loader_test.go b/runsc/boot/loader_test.go
index 7d35dcae2..41ff3681b 100644
--- a/runsc/boot/loader_test.go
+++ b/runsc/boot/loader_test.go
@@ -84,8 +84,13 @@ func startGofer(root string) (int, func(), error) {
log.Infof("Gofer is stopping. FD: %d, err: %v\n", goferEnd, err)
}
}()
- // Closing the gofer FD will stop the gofer and exit goroutine above.
- return sandboxEnd, func() { syscall.Close(goferEnd) }, nil
+ // Closing the gofer socket will stop the gofer and exit goroutine above.
+ cleanup := func() {
+ if err := socket.Close(); err != nil {
+ log.Warningf("Error closing gofer socket: %v", err)
+ }
+ }
+ return sandboxEnd, cleanup, nil
}
func createLoader() (*Loader, func(), error) {