From 5fde2ff79c92e2bb2ff67e4537640af7d06e73b6 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Mon, 9 Sep 2024 23:15:29 +0800 Subject: http: Fix router process crash whilst using proxy When the client closes the connection before the upstream, the proxy's error handler was calling cleanup operation like peer close and request close twice, this fix ensures the cleanup is performed only once, improving proxy stability. Closes: https://github.com/nginx/unit/issues/828 --- src/nxt_http_proxy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nxt_http_proxy.c') diff --git a/src/nxt_http_proxy.c b/src/nxt_http_proxy.c index 6aa3aabb..7f6ad686 100644 --- a/src/nxt_http_proxy.c +++ b/src/nxt_http_proxy.c @@ -381,9 +381,10 @@ nxt_http_proxy_error(nxt_task_t *task, void *obj, void *data) r = obj; peer = r->peer; - nxt_http_proto[peer->protocol].peer_close(task, peer); - - nxt_mp_release(r->mem_pool); + if (!peer->closed) { + nxt_http_proto[peer->protocol].peer_close(task, peer); + nxt_mp_release(r->mem_pool); + } nxt_http_request_error(&r->task, r, peer->status); } -- cgit