From 1a1e305b6b246e48ac4e6b1656e9c5874517f47a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Jun 2026 22:52:44 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20etcp=5Fconnection=5Fclose=20=E2=80=94=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BB?= =?UTF-8?q?=D0=B8=D0=BD=D0=BA=D0=B8=20=D0=B4=D0=BE=20=D0=BE=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BA=D0=B8=20=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=B9=20(SIGSEGV=20=D0=BD=D0=B0=20input=5Fsend=5Fq=3DNUL?= =?UTF-8?q?L)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/etcp.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/etcp.c b/src/etcp.c index 8114fa89..7acadd93 100644 --- a/src/etcp.c +++ b/src/etcp.c @@ -302,23 +302,26 @@ void etcp_connection_close(struct ETCP_CONN* etcp) { etcp->normalizer = NULL; } - // Drain and free all queues using helper functions + // Clear links BEFORE draining queues: etcp_link_close calls + // etcp_conn_on_inflight_lim_changed -> input_queue_try_resume + // which accesses input_send_q, input_queue, input_wait_ack. + if (etcp->links) { + struct ETCP_LINK* link = etcp->links; + while (link) { + struct ETCP_LINK* next = link->next; + etcp_link_close(link); + link = next; + } + etcp->links = NULL; + } + + // Drain and free all queues drain_and_free_queue(&etcp->input_queue); drain_and_free_queue(&etcp->output_queue); drain_and_free_queue(&etcp->input_send_q); drain_and_free_queue(&etcp->input_wait_ack); drain_and_free_queue(&etcp->recv_q); drain_and_free_queue(&etcp->ack_q); - - // Drain and free ack_q (contains ACK_PACKET from ack_pool - special handling) - if (etcp->ack_q) { - struct ACK_PACKET* pkt; - while ((pkt = (struct ACK_PACKET*)queue_data_get(etcp->ack_q)) != NULL) { - queue_entry_free((struct ll_entry*)pkt); - } - queue_free(etcp->ack_q); - etcp->ack_q = NULL; - } // Free memory pools after all elements are returned if (etcp->inflight_pool) { @@ -331,17 +334,6 @@ void etcp_connection_close(struct ETCP_CONN* etcp) { etcp->io_pool = NULL; } - // Clear links list safely - if (etcp->links) { - struct ETCP_LINK* link = etcp->links; - while (link) { - struct ETCP_LINK* next = link->next; - etcp_link_close(link); - link = next; - } - etcp->links = NULL; - } - u_free(etcp->name); // Clear next pointer to prevent dangling references