Commit f529a277 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

plugin/forward: close channels when connManager returns (#1727)

Close a bunch of channels, also change the test to just use a for loop
with a counter.
parent d4919462
...@@ -44,7 +44,14 @@ func newTransport(addr string, tlsConfig *tls.Config) *transport { ...@@ -44,7 +44,14 @@ func newTransport(addr string, tlsConfig *tls.Config) *transport {
ret: make(chan connErr), ret: make(chan connErr),
stop: make(chan bool), stop: make(chan bool),
} }
go t.connManager() go func() {
t.connManager()
// if connManager returns it has been stopped.
close(t.stop)
close(t.yield)
close(t.dial)
// close(t.ret) // we can still be dialing and wanting to send back the socket on t.ret
}()
return t return t
} }
......
...@@ -25,9 +25,7 @@ func TestProxyClose(t *testing.T) { ...@@ -25,9 +25,7 @@ func TestProxyClose(t *testing.T) {
state := request.Request{W: &test.ResponseWriter{}, Req: req} state := request.Request{W: &test.ResponseWriter{}, Req: req}
ctx := context.TODO() ctx := context.TODO()
repeatCnt := 1000 for i := 0; i < 100; i++ {
for repeatCnt > 0 {
repeatCnt--
p := NewProxy(s.Addr, nil /* no TLS */) p := NewProxy(s.Addr, nil /* no TLS */)
p.start(hcDuration) p.start(hcDuration)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment