1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

release bridge worker when inactive

This commit is contained in:
Darien Raymond 2018-10-28 21:46:12 +01:00
parent f1ab89d9d8
commit f3ad8acbe4
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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()