From: Alan T. DeKok Date: Thu, 6 Jun 2024 18:36:19 +0000 (-0400) Subject: unlink connection from parent before cleaning it up X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9d52d3189dae0564cb985c3bc43ad0c18711983;p=thirdparty%2Ffreeradius-server.git unlink connection from parent before cleaning it up to prevent repeated deletes --- diff --git a/src/lib/io/master.c b/src/lib/io/master.c index 87729313347..3f955722906 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -2006,10 +2006,11 @@ static void client_expiry_timer(fr_event_list_t *el, fr_time_t now, void *uctx) * It's a connected socket. Remove it from the * parents list of connections, and delete it. */ - if (connection) { + if (connection && connection->parent) { fr_io_client_t *parent = connection->parent; pthread_mutex_lock(&parent->mutex); + connection->parent = NULL; if (parent->ht) (void) fr_hash_table_delete(parent->ht, connection); pthread_mutex_unlock(&parent->mutex); @@ -2621,10 +2622,13 @@ static int mod_close(fr_listen_t *li) /* * Remove connection from parent hash table */ - parent = connection->parent; - pthread_mutex_lock(&parent->mutex); - if (parent->ht) (void) fr_hash_table_delete(parent->ht, connection); - pthread_mutex_unlock(&parent->mutex); + if (connection->parent) { + parent = connection->parent; + pthread_mutex_lock(&parent->mutex); + connection->parent = NULL; + if (parent->ht) (void) fr_hash_table_delete(parent->ht, connection); + pthread_mutex_unlock(&parent->mutex); + } /* * Clean up listener