From c5ee9d826c991905e5980ca7e548fb9d80b04f13 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 5 Jul 2022 17:17:55 -0400 Subject: [PATCH] TT#14008 skip free list when allocating requested port Reported in #1503 Change-Id: Ida64c4462c832dd97bcbc95901fd5c49344447bc --- daemon/media_socket.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 27f83a79b..ae209a296 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -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) {