Explorar o código

Be more explicit in finding next port to allocate

Docker-DCO-1.1-Signed-off-by: Andy Kipp <andy@rstudio.com> (github: kippandrew)
Andy Kipp %!s(int64=11) %!d(string=hai) anos
pai
achega
73c416a20d
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      runtime/networkdriver/portallocator/portallocator.go

+ 3 - 2
runtime/networkdriver/portallocator/portallocator.go

@@ -151,8 +151,9 @@ func equalsDefault(ip net.IP) bool {
 }
 }
 
 
 func findNextPort(proto string, allocated *collections.OrderedIntSet) (int, error) {
 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 {
 	if port > EndPortRange {
 		return 0, ErrPortExceedsRange
 		return 0, ErrPortExceedsRange