From 7b5eb7193c7b2411571a67aa6d7fbb21bdffa099 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Feb 2015 07:52:09 -0800 Subject: [PATCH] Increment 'try' variable To ensure that we actually probe different ports --- test/core/util/port_posix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 55150a7cedc..36f13e1b51e 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -117,9 +117,10 @@ int grpc_pick_unused_port(void) { for (;;) { int port; - if (try == 0) { + try++; + if (try == 1) { port = getpid() % (65536 - 30000) + 30000; - } else if (try < NUM_RANDOM_PORTS_TO_PICK) { + } else if (try <= NUM_RANDOM_PORTS_TO_PICK) { port = rand() % (65536 - 30000) + 30000; } else { port = 0;