Fixup: request cannot be cleanup sometimes.

When nginx tries to write to a broken connection. It triggers an
IO error, and then mark the connection as error. If
ngx_http_finalize_connection is invoked after the IO error,
Current code will setup an handler to r->write_event_handler.
That will be a trouble, the newly installed handler will never
be called, and the request will be leaked.
This commit is contained in:
Chizhong Jin 2025-01-15 03:12:40 +08:00
parent 57d54fd922
commit 1fc3c1814e

View file

@ -2715,7 +2715,7 @@ ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc)
"http terminate cleanup count:%d blk:%d",
mr->count, mr->blocked);
if (mr->write_event_handler) {
if (!mr->connection->error && mr->write_event_handler) {
if (mr->blocked) {
r = r->connection->data;