mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 01:27:03 -05:00
release bridge worker when inactive
This commit is contained in:
parent
f1ab89d9d8
commit
f3ad8acbe4
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user