diff --git a/app/reverse/bridge.go b/app/reverse/bridge.go index f18503dfb..0d65a7071 100644 --- a/app/reverse/bridge.go +++ b/app/reverse/bridge.go @@ -42,7 +42,23 @@ func NewBridge(config *BridgeConfig, dispatcher routing.Dispatcher) (*Bridge, er return b, nil } +func (b *Bridge) cleanup() { + var activeWorkers []*BridgeWorker + + for _, w := range b.workers { + if w.IsActive() { + activeWorkers = append(activeWorkers, w) + } + } + + if len(activeWorkers) != len(b.workers) { + b.workers = activeWorkers + } +} + func (b *Bridge) monitor() error { + b.cleanup() + var numConnections uint32 var numWorker uint32 diff --git a/testing/scenarios/reverse_test.go b/testing/scenarios/reverse_test.go index aa311865d..0f42572d3 100644 --- a/testing/scenarios/reverse_test.go +++ b/testing/scenarios/reverse_test.go @@ -182,7 +182,7 @@ func TestReverseProxy(t *testing.T) { defer CloseAllServers(servers) var wg sync.WaitGroup - wg.Add(10) + wg.Add(32) for i := 0; i < 32; i++ { go func() { defer wg.Done()