comparison src/http/ngx_http_request.c @ 7762:4e141d0816d4

Core: removed post_accept_timeout. Keeping post_accept_timeout in ngx_listening_t is no longer needed since we've switched to 1 second timeout for deferred accept in 5541:fdb67cfc957d. Further, using it in HTTP code can result in client_header_timeout being used from an incorrect server block, notably if address-specific virtual servers are used along with a wildcard listening socket, or if we've switched to a different server block based on SNI in SSL handshake.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 19 Jan 2021 20:32:00 +0300
parents 2fec22332ff4
children 3e83336cda5b
comparison
equal deleted inserted replaced
7761:43a0a9e988be 7762:4e141d0816d4
204 204
205 205
206 void 206 void
207 ngx_http_init_connection(ngx_connection_t *c) 207 ngx_http_init_connection(ngx_connection_t *c)
208 { 208 {
209 ngx_uint_t i; 209 ngx_uint_t i;
210 ngx_event_t *rev; 210 ngx_event_t *rev;
211 struct sockaddr_in *sin; 211 struct sockaddr_in *sin;
212 ngx_http_port_t *port; 212 ngx_http_port_t *port;
213 ngx_http_in_addr_t *addr; 213 ngx_http_in_addr_t *addr;
214 ngx_http_log_ctx_t *ctx; 214 ngx_http_log_ctx_t *ctx;
215 ngx_http_connection_t *hc; 215 ngx_http_connection_t *hc;
216 ngx_http_core_srv_conf_t *cscf;
216 #if (NGX_HAVE_INET6) 217 #if (NGX_HAVE_INET6)
217 struct sockaddr_in6 *sin6; 218 struct sockaddr_in6 *sin6;
218 ngx_http_in6_addr_t *addr6; 219 ngx_http_in6_addr_t *addr6;
219 #endif 220 #endif
220 221
221 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); 222 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t));
222 if (hc == NULL) { 223 if (hc == NULL) {
223 ngx_http_close_connection(c); 224 ngx_http_close_connection(c);
359 360
360 rev->handler(rev); 361 rev->handler(rev);
361 return; 362 return;
362 } 363 }
363 364
364 ngx_add_timer(rev, c->listening->post_accept_timeout); 365 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);
366
367 ngx_add_timer(rev, cscf->client_header_timeout);
365 ngx_reusable_connection(c, 1); 368 ngx_reusable_connection(c, 1);
366 369
367 if (ngx_handle_read_event(rev, 0) != NGX_OK) { 370 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
368 ngx_http_close_connection(c); 371 ngx_http_close_connection(c);
369 return; 372 return;
429 n = c->recv(c, b->last, size); 432 n = c->recv(c, b->last, size);
430 433
431 if (n == NGX_AGAIN) { 434 if (n == NGX_AGAIN) {
432 435
433 if (!rev->timer_set) { 436 if (!rev->timer_set) {
434 ngx_add_timer(rev, c->listening->post_accept_timeout); 437 ngx_add_timer(rev, cscf->client_header_timeout);
435 ngx_reusable_connection(c, 1); 438 ngx_reusable_connection(c, 1);
436 } 439 }
437 440
438 if (ngx_handle_read_event(rev, 0) != NGX_OK) { 441 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
439 ngx_http_close_connection(c); 442 ngx_http_close_connection(c);
647 ngx_int_t rc; 650 ngx_int_t rc;
648 ngx_connection_t *c; 651 ngx_connection_t *c;
649 ngx_http_connection_t *hc; 652 ngx_http_connection_t *hc;
650 ngx_http_ssl_srv_conf_t *sscf; 653 ngx_http_ssl_srv_conf_t *sscf;
651 ngx_http_core_loc_conf_t *clcf; 654 ngx_http_core_loc_conf_t *clcf;
655 ngx_http_core_srv_conf_t *cscf;
652 656
653 c = rev->data; 657 c = rev->data;
654 hc = c->data; 658 hc = c->data;
655 659
656 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, 660 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
678 if (n == -1) { 682 if (n == -1) {
679 if (err == NGX_EAGAIN) { 683 if (err == NGX_EAGAIN) {
680 rev->ready = 0; 684 rev->ready = 0;
681 685
682 if (!rev->timer_set) { 686 if (!rev->timer_set) {
683 ngx_add_timer(rev, c->listening->post_accept_timeout); 687 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
688 ngx_http_core_module);
689 ngx_add_timer(rev, cscf->client_header_timeout);
684 ngx_reusable_connection(c, 1); 690 ngx_reusable_connection(c, 1);
685 } 691 }
686 692
687 if (ngx_handle_read_event(rev, 0) != NGX_OK) { 693 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
688 ngx_http_close_connection(c); 694 ngx_http_close_connection(c);
753 rc = ngx_ssl_handshake(c); 759 rc = ngx_ssl_handshake(c);
754 760
755 if (rc == NGX_AGAIN) { 761 if (rc == NGX_AGAIN) {
756 762
757 if (!rev->timer_set) { 763 if (!rev->timer_set) {
758 ngx_add_timer(rev, c->listening->post_accept_timeout); 764 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
765 ngx_http_core_module);
766 ngx_add_timer(rev, cscf->client_header_timeout);
759 } 767 }
760 768
761 c->ssl->handler = ngx_http_ssl_handshake_handler; 769 c->ssl->handler = ngx_http_ssl_handshake_handler;
762 return; 770 return;
763 } 771 }