Skip to content

Commit cf8492c

Browse files
committed
lock the rbtree of incoming TCP/TLS connections
1 parent c56e192 commit cf8492c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/main/listen.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,10 @@ static int listener_cmp(void const *one, void const *two)
16491649

16501650
static int listener_unlink(UNUSED void *ctx, UNUSED void *data)
16511651
{
1652+
/*
1653+
* The child listener can stay active, even if the parent one is closed.
1654+
*/
1655+
16521656
return 2; /* unlink this node from the tree */
16531657
}
16541658
#endif
@@ -2049,7 +2053,7 @@ int common_socket_parse(CONF_SECTION *cs, rad_listen_t *this)
20492053
* matters when we're tearing down the server, so
20502054
* perhaps it's less relevant.
20512055
*/
2052-
this->children = rbtree_create(this, listener_cmp, NULL, 0);
2056+
this->children = rbtree_create(this, listener_cmp, NULL, RBTREE_FLAG_LOCK);
20532057
if (!this->children) {
20542058
cf_log_err_cs(cs, "Failed to create child list for TCP socket.");
20552059
return -1;
@@ -3564,13 +3568,16 @@ static int _listener_free(rad_listen_t *this)
35643568
*/
35653569
if (this->parent) {
35663570
rbtree_deletebydata(this->parent->children, this);
3571+
this->parent = NULL;
35673572
}
35683573

35693574
/*
35703575
* Delete / close all of the children, too!
35713576
*/
35723577
if (this->children) {
35733578
rbtree_walk(this->children, RBTREE_DELETE_ORDER, listener_unlink, this);
3579+
rbtree_free(this->children);
3580+
this->children = NULL;
35743581
}
35753582

35763583
#ifdef WITH_TLS

0 commit comments

Comments
 (0)