|
|
|
@ -43,7 +43,7 @@ static int get_random_port_offset() { |
|
|
|
|
static int s_initial_offset = get_random_port_offset(); |
|
|
|
|
static gpr_atm s_pick_counter = 0; |
|
|
|
|
|
|
|
|
|
int grpc_pick_unused_port_or_die(void) { |
|
|
|
|
static int grpc_pick_unused_port_or_die_impl(void) { |
|
|
|
|
int orig_counter_val = |
|
|
|
|
static_cast<int>(gpr_atm_full_fetch_add(&s_pick_counter, 1)); |
|
|
|
|
GPR_ASSERT(orig_counter_val < (MAX_PORT - MIN_PORT + 1)); |
|
|
|
@ -51,6 +51,19 @@ int grpc_pick_unused_port_or_die(void) { |
|
|
|
|
(s_initial_offset + orig_counter_val) % (MAX_PORT - MIN_PORT + 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int grpc_pick_unused_port_or_die(void) { |
|
|
|
|
while (true) { |
|
|
|
|
int port = grpc_pick_unused_port_or_die_impl(); |
|
|
|
|
// 5985 cannot be bound on Windows RBE and results in
|
|
|
|
|
// WSA_ERROR 10013: "An attempt was made to access a socket in a way
|
|
|
|
|
// forbidden by its access permissions."
|
|
|
|
|
if (port == 5985) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
return port; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_recycle_unused_port(int port) { (void)port; } |
|
|
|
|
|
|
|
|
|
#endif /* GRPC_PORT_ISOLATED_RUNTIME */ |
|
|
|
|