From 73c416a20db8fe48302a6cf0db4c1c0585ed0739 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Thu, 13 Mar 2014 13:30:07 -0400 Subject: [PATCH] Be more explicit in finding next port to allocate Docker-DCO-1.1-Signed-off-by: Andy Kipp (github: kippandrew) --- runtime/networkdriver/portallocator/portallocator.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/networkdriver/portallocator/portallocator.go b/runtime/networkdriver/portallocator/portallocator.go index 18ae9469e5..4d698f2de2 100644 --- a/runtime/networkdriver/portallocator/portallocator.go +++ b/runtime/networkdriver/portallocator/portallocator.go @@ -151,8 +151,9 @@ func equalsDefault(ip net.IP) bool { } func findNextPort(proto string, allocated *collections.OrderedIntSet) (int, error) { - port := 0 - for port = nextPort(proto); allocated.Exists(port); port = nextPort(proto) { + port := nextPort(proto) + for allocated.Exists(port) { + port = nextPort(proto) } if port > EndPortRange { return 0, ErrPortExceedsRange