fix RST on FIN: tcp_recved in proxy_recv_cb BEFORE closing_tun, guard proxy_err_cb with !closing_sent

This commit is contained in:
Evgeny committed 2026-05-30 23:24:37 +03:00
1 parent 8de8b5bb41
commit 80e4e4fd5d
1 file changed
+3 -1
+3 -1
View File
@@ -262,6 +262,8 @@ static err_t proxy_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t
if (p == NULL || err != LERR_OK) {
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY FIN stream=%016llx tun=1 active=%d", (unsigned long long)(pc->remote_stream_id ? pc->remote_stream_id : 0), pc->active);
{ uint16_t wnd_gap = TCP_WND_MAX(pcb) - pcb->rcv_wnd;
if (wnd_gap > 0) tcp_recved(pcb, wnd_gap); }
pc->closing_tun = 1;
return LERR_OK;
}
@@ -303,7 +305,7 @@ static void proxy_err_cb(void *arg, err_t err) {
if (!pc) return;
DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "TCP proxy: tcp error %d", err);
pc->closing_tun = 1;
if (pc->transport) pc->transport->ops->close(pc->transport);
if (pc->transport && !pc->closing_sent) pc->transport->ops->close(pc->transport);
}
static err_t proxy_poll_cb(void *arg, struct tcp_pcb *pcb) {