From 09bc8c35c5c4fdef6af33b7399b05edda005a208 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 29 Sep 2026 03:59:30 +0300 Subject: [PATCH] Release TUN proxy connections when lwIP aborts their PCB --- src/proxy/tcp_proxy_client.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/proxy/tcp_proxy_client.c b/src/proxy/tcp_proxy_client.c index 5b295635..2c6cb1ec 100644 --- a/src/proxy/tcp_proxy_client.c +++ b/src/proxy/tcp_proxy_client.c @@ -452,12 +452,11 @@ static void tcp_proxy_client_err_cb(void *arg, err_t err) { DEBUG_ERROR(DEBUG_CATEGORY_PROXY, "TCP proxy client: error %d sid=%08x fin_local=%d rem_closed=%d", err, pc->stream_id, pc->fin_local, pc->rem_closed); pc->pcb = NULL; // pcb уже освобождён (или вот-вот) стеком lwip — не разыменовывать - if (err == LERR_CLSD) { // graceful close активной стороной — ERROR слать не нужно - tcp_proxy_client_conn_free(pc); - return; + if (err != LERR_CLSD) { + pc->error = 1; + if (tcp_proxy_client_send_error(pc) < 0) DEBUG_ERROR(DEBUG_CATEGORY_PROXY, "PROXY send_error failed sid=%08x", pc->stream_id); } - pc->error = 1; - if (tcp_proxy_client_send_error(pc) < 0) DEBUG_ERROR(DEBUG_CATEGORY_PROXY, "PROXY send_error failed sid=%08x", pc->stream_id); + tcp_proxy_client_conn_free(pc); } static err_t tcp_proxy_client_poll_cb(void *arg, struct tcp_pcb *pcb) { @@ -476,7 +475,7 @@ static err_t tcp_proxy_client_poll_cb(void *arg, struct tcp_pcb *pcb) { pc->pcb = NULL; } tcp_proxy_client_conn_free(pc); - return LERR_OK; + return LERR_ABRT; } if (pc->close_pending) {