1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00

pick truely unused port

This commit is contained in:
v2ray 2016-02-23 21:50:19 +01:00
parent 47e61f62c1
commit 464f15cb02

View File

@ -91,9 +91,11 @@ func (this *InboundDetourHandlerDynamic) refresh() error {
this.ich2Recycle, this.ichInUse = this.ichInUse, this.ich2Recycle this.ich2Recycle, this.ichInUse = this.ichInUse, this.ich2Recycle
for _, ich := range this.ichInUse { for _, ich := range this.ichInUse {
port := this.pickUnusedPort()
delete(this.portsInUse, ich.Port()) delete(this.portsInUse, ich.Port())
ich.Close() ich.Close()
port := this.pickUnusedPort()
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error { err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
err := ich.Listen(port) err := ich.Listen(port)
if err != nil { if err != nil {