From 464f15cb0205e795e72e73f06ef2dd6a1e0cdce7 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 23 Feb 2016 21:50:19 +0100 Subject: [PATCH] pick truely unused port --- shell/point/inbound_detour_dynamic.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/point/inbound_detour_dynamic.go b/shell/point/inbound_detour_dynamic.go index 7d402d2c1..7e929ba8b 100644 --- a/shell/point/inbound_detour_dynamic.go +++ b/shell/point/inbound_detour_dynamic.go @@ -91,9 +91,11 @@ func (this *InboundDetourHandlerDynamic) refresh() error { this.ich2Recycle, this.ichInUse = this.ichInUse, this.ich2Recycle for _, ich := range this.ichInUse { + port := this.pickUnusedPort() + delete(this.portsInUse, ich.Port()) ich.Close() - port := this.pickUnusedPort() + err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error { err := ich.Listen(port) if err != nil {