aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/util/port_posix.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-08-27 07:36:12 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-08-27 07:36:12 -0700
commit99d7b661bede39143d1be6040fb67c81b8117ae3 (patch)
tree8396780e126a8db360700b182ed2722eef2527a9 /test/core/util/port_posix.c
parentb6c912b75b14cebc0527ccbac91964af347e7df7 (diff)
Revert "Refactor Endpoint API"
Diffstat (limited to 'test/core/util/port_posix.c')
-rw-r--r--test/core/util/port_posix.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c
index 4781d334e2..836e62a541 100644
--- a/test/core/util/port_posix.c
+++ b/test/core/util/port_posix.c
@@ -198,13 +198,14 @@ int grpc_pick_unused_port(void) {
races with other processes on kernels that want to reuse the same
port numbers over and over. */
- /* In alternating iterations we trial UDP ports before TCP ports UDP
+ /* In alternating iterations we try UDP ports before TCP ports UDP
ports -- it could be the case that this machine has been using up
UDP ports and they are scarcer. */
/* Type of port to first pick in next iteration */
int is_tcp = 1;
- int trial = 0;
+ int try
+ = 0;
char *env = gpr_getenv("GRPC_TEST_PORT_SERVER");
if (env) {
@@ -217,10 +218,11 @@ int grpc_pick_unused_port(void) {
for (;;) {
int port;
- trial++;
- if (trial == 1) {
+ try
+ ++;
+ if (try == 1) {
port = getpid() % (65536 - 30000) + 30000;
- } else if (trial <= NUM_RANDOM_PORTS_TO_PICK) {
+ } else if (try <= NUM_RANDOM_PORTS_TO_PICK) {
port = rand() % (65536 - 30000) + 30000;
} else {
port = 0;
@@ -237,7 +239,7 @@ int grpc_pick_unused_port(void) {
GPR_ASSERT(port > 0);
/* Check that the port # is free for the other type of socket also */
if (!is_port_available(&port, !is_tcp)) {
- /* In the next iteration trial to bind to the other type first
+ /* In the next iteration try to bind to the other type first
because perhaps it is more rare. */
is_tcp = !is_tcp;
continue;