Mercurial > hg > nginx
comparison src/http/modules/ngx_http_limit_req_module.c @ 7811:1ebd78df4ce7
Fixed handling of already closed connections.
In limit_req, auth_delay, and upstream code to check for broken
connections, tests for possible connection close by the client
did not work if the connection was already closed when relevant
event handler was set. This happened because there were no additional
events in case of edge-triggered event methods, and read events
were disabled in case of level-triggered ones.
Fix is to explicitly post a read event if the c->read->ready flag
is set.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 28 Mar 2021 17:45:39 +0300 |
parents | 559d19037984 |
children |
comparison
equal
deleted
inserted
replaced
7810:1bf8ab7063de | 7811:1ebd78df4ce7 |
---|---|
308 return NGX_DECLINED; | 308 return NGX_DECLINED; |
309 } | 309 } |
310 | 310 |
311 r->main->limit_req_status = NGX_HTTP_LIMIT_REQ_DELAYED; | 311 r->main->limit_req_status = NGX_HTTP_LIMIT_REQ_DELAYED; |
312 | 312 |
313 if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) { | 313 if (r->connection->read->ready) { |
314 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 314 ngx_post_event(r->connection->read, &ngx_posted_events); |
315 | |
316 } else { | |
317 if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) { | |
318 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
319 } | |
315 } | 320 } |
316 | 321 |
317 r->read_event_handler = ngx_http_test_reading; | 322 r->read_event_handler = ngx_http_test_reading; |
318 r->write_event_handler = ngx_http_limit_req_delay; | 323 r->write_event_handler = ngx_http_limit_req_delay; |
319 | 324 |