From: Nick Porter Date: Thu, 17 Aug 2023 19:10:45 +0000 (+0100) Subject: Tidy up on connection close X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52c2f298787c26e0f82a9c4db9346cc78a87804d;p=thirdparty%2Ffreeradius-server.git Tidy up on connection close --- diff --git a/src/lib/io/master.c b/src/lib/io/master.c index 6ea24d45d2c..c0ce3ee9ab1 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -2574,6 +2574,7 @@ static int mod_close(fr_listen_t *li) fr_io_instance_t const *inst; fr_io_connection_t *connection; fr_listen_t *child; + fr_io_client_t *parent; get_inst(li, &inst, NULL, &connection, &child); @@ -2597,6 +2598,22 @@ static int mod_close(fr_listen_t *li) if (connection->client->pending) { TALLOC_FREE(connection->client->pending); /* for any pending packets */ } + + /* + * Remove connection from parent hash table + */ + parent = connection->parent; + if (parent->ht) { + pthread_mutex_lock(&parent->mutex); + (void) fr_hash_table_delete(parent->ht, connection); + pthread_mutex_unlock(&parent->mutex); + } + + /* + * Clean up listener + */ + fr_network_listen_delete(connection->nr, child); + talloc_free(connection->dl_inst); return 0;