func findNextPort(proto string, allocated *collections.OrderedIntSet) (int, error) { port := nextPort(proto) for allocated.Exists(port) { port = nextPort(proto) } if port > EndPortRange { return 0, ErrPortExceedsRange } return port, nil }
func findNextPort(proto string, allocated *collections.OrderedIntSet) (int, error) { port := nextPort(proto) startSearchPort := port for allocated.Exists(port) { port = nextPort(proto) if startSearchPort == port { return 0, ErrAllPortsAllocated } } return port, nil }