From 938430b1eba6c62e0740e6f7a18f7f6ee12f5d55 Mon Sep 17 00:00:00 2001 From: Bowei Du Date: Mon, 31 Oct 2016 22:10:35 -0700 Subject: [PATCH] Should not defer conn.Close when leaking the connection --- test/images/net/nat/closewait.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/images/net/nat/closewait.go b/test/images/net/nat/closewait.go index b9f804cea0c..d06aab79d21 100644 --- a/test/images/net/nat/closewait.go +++ b/test/images/net/nat/closewait.go @@ -36,7 +36,8 @@ import ( "k8s.io/kubernetes/test/images/net/common" ) -// leakedConnection is a +// leakedConnection is a global variable that should leak the active +// connection assigned here. var leakedConnection *net.TCPConn // Server JSON options. @@ -156,7 +157,9 @@ func (client *closeWaitClient) Run(logger *log.Logger, rawOptions interface{}) e if err != nil { return err } - defer conn.Close() + if !client.options.LeakConnection { + defer conn.Close() + } logger.Printf("Connected to server")