From b2194c95f9d02965b2ad3d0dcf333e74881347d0 Mon Sep 17 00:00:00 2001 From: James Chapman Date: Thu, 31 Aug 2023 14:05:31 +0000 Subject: [PATCH] Issue 5909 - Multi listener hang with 20k connections (#5917) Bug Description: A fix for connection sub-table to freelist mapping results in an uninitialised head of the sub-table linked list. Fix Description: During connection table creation, initialise all elements but skip the list head during the mapping phase. Fixes: https//github.com/389ds/389-ds-base/issues/5909 Reviewed by: @progier389 @tbordaz (Thank you) --- ldap/servers/slapd/conntable.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c index b1c66cf421..11e997432b 100644 --- a/ldap/servers/slapd/conntable.c +++ b/ldap/servers/slapd/conntable.c @@ -172,9 +172,9 @@ connection_table_new(int table_size) /* all connections start out invalid */ ct->fd[ct_list][i].fd = SLAPD_INVALID_SOCKET; - /* The connection table has a double linked list running through it. + /* The connection sub-tables have a double linked list running through them. * This is used to find out which connections should be looked at - * in the poll loop. Slot 0 in the table is always the head of + * in the poll loop. Slot 0 in each sub-table is always the head of * the linked list. Each slot has a c_next and c_prev which are * pointers back into the array of connection slots. */ ct->c[ct_list][i].c_next = NULL; @@ -196,8 +196,10 @@ connection_table_new(int table_size) /* Ready to rock, mark as such. */ ct->c[ct_list][i].c_state = CONN_STATE_INIT; - /* Map multiple ct lists to a single freelist. */ - ct->c_freelist[free_idx++] = &(ct->c[ct_list][i]); + /* Map multiple ct lists to a single freelist, but skip slot 0 of each list. */ + if (i != 0) { + ct->c_freelist[free_idx++] = &(ct->c[ct_list][i]); + } } }