diff --git a/src/etcp.c b/src/etcp.c index 71c0d43ca..9d12c0517 100644 --- a/src/etcp.c +++ b/src/etcp.c @@ -164,6 +164,16 @@ void etcp_connection_close(struct ETCP_CONN* etcp) { DEBUG_TRACE(DEBUG_CATEGORY_ETCP, ""); if (!etcp) return; + // Cancel active timers to prevent memory leaks + if (etcp->retrans_timer) { + uasync_cancel_timeout(etcp->instance->ua, etcp->retrans_timer); + etcp->retrans_timer = NULL; + } + if (etcp->ack_resp_timer) { + uasync_cancel_timeout(etcp->instance->ua, etcp->ack_resp_timer); + etcp->ack_resp_timer = NULL; + } + routing_del_conn(etcp); // Notify BGP about connection closure (send withdraws, remove from senders_list) diff --git a/src/etcp_connections.c b/src/etcp_connections.c index 3d7f0e072..4ea97e916 100644 --- a/src/etcp_connections.c +++ b/src/etcp_connections.c @@ -456,6 +456,12 @@ void etcp_link_close(struct ETCP_LINK* link) { link->init_timer = NULL; } + // Cancel shaper timer if active + if (link->shaper_timer) { + uasync_cancel_timeout(link->etcp->instance->ua, link->shaper_timer); + link->shaper_timer = NULL; + } + // универсальное удаление из односвязного списка struct ETCP_LINK **pp = &link->etcp->links; while (*pp) {