From e0bb94201f1edb6ce649192fe4a62e1781940b50 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Wed, 17 Oct 2018 16:17:35 -0700 Subject: [PATCH] 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 --- runsc/boot/loader_test.go | 9 +++++++-- 1 file 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) {