From 40a1fb0e2fdf1c0b287275bc85b981e226b1a79c Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Mon, 14 Aug 2017 15:18:59 +0800 Subject: [PATCH] Fix flaky test TestNotifyOnOOM Fixes: #1228 It can be reproduced by applying this patch: ```diff @@ -45,6 +46,7 @@ func registerMemoryEvent(cgDir string, evName string, arg string) (<-chan struct go func() { defer func() { close(ch) + <-time.After(1 * time.Second) eventfd.Close() evFile.Close() }() ``` We can close channel after fds were closed. Signed-off-by: Qiang Huang --- libcontainer/notify_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainer/notify_linux.go b/libcontainer/notify_linux.go index 81587b9b1..47a06783d 100644 --- a/libcontainer/notify_linux.go +++ b/libcontainer/notify_linux.go @@ -44,9 +44,9 @@ func registerMemoryEvent(cgDir string, evName string, arg string) (<-chan struct ch := make(chan struct{}) go func() { defer func() { - close(ch) eventfd.Close() evFile.Close() + close(ch) }() buf := make([]byte, 8) for {