TT#14008 skip free list when allocating requested port

Reported in #1503

Change-Id: Ida64c4462c832dd97bcbc95901fd5c49344447bc
pull/1525/head
Richard Fuchs 3 years ago
parent 40ba01980e
commit 5df21de306

@ -896,22 +896,22 @@ int __get_consecutive_ports(GQueue *out, unsigned int num_ports, unsigned int wa
port += PORT_RANDOM_MIN + (ssl_random() % (PORT_RANDOM_MAX - PORT_RANDOM_MIN));
#endif
__C_DBG("after randomization port=%d", port);
}
// debug msg if port is in the given interval
if (bit_array_isset(pp->ports_used, port)) {
__C_DBG("port %d is USED in port pool", port);
mutex_lock(&pp->free_list_lock);
unsigned int fport = GPOINTER_TO_UINT(g_queue_pop_head(&pp->free_list));
if (fport)
bit_array_clear(pp->free_list_used, fport);
mutex_unlock(&pp->free_list_lock);
if (fport) {
port = fport;
__C_DBG("Picked port %u from free list", port);
// debug msg if port is in the given interval
if (bit_array_isset(pp->ports_used, port)) {
__C_DBG("port %d is USED in port pool", port);
mutex_lock(&pp->free_list_lock);
unsigned int fport = GPOINTER_TO_UINT(g_queue_pop_head(&pp->free_list));
if (fport)
bit_array_clear(pp->free_list_used, fport);
mutex_unlock(&pp->free_list_lock);
if (fport) {
port = fport;
__C_DBG("Picked port %u from free list", port);
}
} else {
__C_DBG("port %d is NOT USED in port pool", port);
}
} else {
__C_DBG("port %d is NOT USED in port pool", port);
}
while (1) {

Loading…
Cancel
Save