Klaus Demo nginx / b32cb6b
Fixed worker_shutdown_timeout in various cases. The ngx_http_upstream_process_upgraded() did not handle c->close request, and upgraded connections do not use the write filter. As a result, worker_shutdown_timeout did not affect upgraded connections (ticket #1419). Fix is to handle c->close in the ngx_http_request_handler() function, thus covering most of the possible cases in http handling. Additionally, mail proxying did not handle neither c->close nor c->error, and thus worker_shutdown_timeout did not work for mail connections. Fix is to add c->close handling to ngx_mail_proxy_handler(). Also, added explicit handling of c->close to stream proxy, ngx_stream_proxy_process_connection(). This improves worker_shutdown_timeout handling in stream, it will no longer wait for some data being transferred in a connection before closing it, and will also provide appropriate logging at the "info" level. Maxim Dounin 4 years ago
3 changed file(s) with 18 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
22242224 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
22252225 "http run request: \"%V?%V\"", &r->uri, &r->args);
22262226
2227 if (c->close) {
2228 r->main->count++;
2229 ngx_http_terminate_request(r, 0);
2230 ngx_http_run_posted_requests(c);
2231 return;
2232 }
2233
22272234 if (ev->delayed && ev->timedout) {
22282235 ev->delayed = 0;
22292236 ev->timedout = 0;
881881 c = ev->data;
882882 s = c->data;
883883
884 if (ev->timedout) {
884 if (ev->timedout || c->close) {
885885 c->log->action = "proxying";
886886
887 if (c == s->connection) {
887 if (c->close) {
888 ngx_log_error(NGX_LOG_INFO, c->log, 0, "shutdown timeout");
889
890 } else if (c == s->connection) {
888891 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
889892 "client timed out");
890893 c->timedout = 1;
12891289 s = c->data;
12901290 u = s->upstream;
12911291
1292 if (c->close) {
1293 ngx_log_error(NGX_LOG_INFO, c->log, 0, "shutdown timeout");
1294 ngx_stream_proxy_finalize(s, NGX_STREAM_OK);
1295 return;
1296 }
1297
12921298 c = s->connection;
12931299 pc = u->peer.connection;
12941300