From a218e25989c6a271b4eb20a31b968c5748a92bd3 Mon Sep 17 00:00:00 2001 From: Raamnath Mani Date: Wed, 17 Oct 2018 15:13:41 +0100 Subject: [PATCH 1/2] Bail out of the loop when the stub Input stream is done --- toxics/timeout.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toxics/timeout.go b/toxics/timeout.go index f42d9d23..87ac1555 100644 --- a/toxics/timeout.go +++ b/toxics/timeout.go @@ -19,7 +19,10 @@ func (t *TimeoutToxic) Pipe(stub *ToxicStub) { return case <-stub.Interrupt: return - case <-stub.Input: + case c := <-stub.Input: + if c == nil { + return + } // Drop the data on the ground. } } From 1390d9962f16d8164610c9128c8b5581fd046081 Mon Sep 17 00:00:00 2001 From: Jake Pittis Date: Mon, 17 Dec 2018 08:51:05 -0500 Subject: [PATCH 2/2] avoid stub leak on both branches of timeout toxic --- toxics/timeout.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/toxics/timeout.go b/toxics/timeout.go index 87ac1555..d05ca6f4 100644 --- a/toxics/timeout.go +++ b/toxics/timeout.go @@ -21,6 +21,7 @@ func (t *TimeoutToxic) Pipe(stub *ToxicStub) { return case c := <-stub.Input: if c == nil { + stub.Close() return } // Drop the data on the ground. @@ -31,7 +32,11 @@ func (t *TimeoutToxic) Pipe(stub *ToxicStub) { select { case <-stub.Interrupt: return - case <-stub.Input: + case c := <-stub.Input: + if c == nil { + stub.Close() + return + } // Drop the data on the ground. } }