Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 8704:13f7085b90d2 quic
Merged with the default branch.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 17 Feb 2021 14:48:35 +0300 |
parents | 6422455c92b4 3e83336cda5b |
children | f1986657fc26 |
comparison
equal
deleted
inserted
replaced
8703:d710c457171c | 8704:13f7085b90d2 |
---|---|
198 | 198 |
199 | 199 |
200 void | 200 void |
201 ngx_http_init_connection(ngx_connection_t *c) | 201 ngx_http_init_connection(ngx_connection_t *c) |
202 { | 202 { |
203 ngx_uint_t i; | 203 ngx_uint_t i; |
204 ngx_event_t *rev; | 204 ngx_event_t *rev; |
205 struct sockaddr_in *sin; | 205 struct sockaddr_in *sin; |
206 ngx_http_port_t *port; | 206 ngx_http_port_t *port; |
207 ngx_http_in_addr_t *addr; | 207 ngx_http_in_addr_t *addr; |
208 ngx_http_log_ctx_t *ctx; | 208 ngx_http_log_ctx_t *ctx; |
209 ngx_http_connection_t *hc; | 209 ngx_http_connection_t *hc; |
210 ngx_http_core_srv_conf_t *cscf; | |
210 #if (NGX_HAVE_INET6) | 211 #if (NGX_HAVE_INET6) |
211 struct sockaddr_in6 *sin6; | 212 struct sockaddr_in6 *sin6; |
212 ngx_http_in6_addr_t *addr6; | 213 ngx_http_in6_addr_t *addr6; |
213 #endif | 214 #endif |
214 | 215 |
215 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); | 216 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); |
216 if (hc == NULL) { | 217 if (hc == NULL) { |
217 ngx_http_close_connection(c); | 218 ngx_http_close_connection(c); |
368 | 369 |
369 rev->handler(rev); | 370 rev->handler(rev); |
370 return; | 371 return; |
371 } | 372 } |
372 | 373 |
373 ngx_add_timer(rev, c->listening->post_accept_timeout); | 374 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module); |
375 | |
376 ngx_add_timer(rev, cscf->client_header_timeout); | |
374 ngx_reusable_connection(c, 1); | 377 ngx_reusable_connection(c, 1); |
375 | 378 |
376 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | 379 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
377 ngx_http_close_connection(c); | 380 ngx_http_close_connection(c); |
378 return; | 381 return; |
438 n = c->recv(c, b->last, size); | 441 n = c->recv(c, b->last, size); |
439 | 442 |
440 if (n == NGX_AGAIN) { | 443 if (n == NGX_AGAIN) { |
441 | 444 |
442 if (!rev->timer_set) { | 445 if (!rev->timer_set) { |
443 ngx_add_timer(rev, c->listening->post_accept_timeout); | 446 ngx_add_timer(rev, cscf->client_header_timeout); |
444 ngx_reusable_connection(c, 1); | 447 ngx_reusable_connection(c, 1); |
445 } | 448 } |
446 | 449 |
447 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | 450 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
448 ngx_http_close_connection(c); | 451 ngx_http_close_connection(c); |
656 ngx_int_t rc; | 659 ngx_int_t rc; |
657 ngx_connection_t *c; | 660 ngx_connection_t *c; |
658 ngx_http_connection_t *hc; | 661 ngx_http_connection_t *hc; |
659 ngx_http_ssl_srv_conf_t *sscf; | 662 ngx_http_ssl_srv_conf_t *sscf; |
660 ngx_http_core_loc_conf_t *clcf; | 663 ngx_http_core_loc_conf_t *clcf; |
664 ngx_http_core_srv_conf_t *cscf; | |
661 | 665 |
662 c = rev->data; | 666 c = rev->data; |
663 hc = c->data; | 667 hc = c->data; |
664 | 668 |
665 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, | 669 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
687 if (n == -1) { | 691 if (n == -1) { |
688 if (err == NGX_EAGAIN) { | 692 if (err == NGX_EAGAIN) { |
689 rev->ready = 0; | 693 rev->ready = 0; |
690 | 694 |
691 if (!rev->timer_set) { | 695 if (!rev->timer_set) { |
692 ngx_add_timer(rev, c->listening->post_accept_timeout); | 696 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, |
697 ngx_http_core_module); | |
698 ngx_add_timer(rev, cscf->client_header_timeout); | |
693 ngx_reusable_connection(c, 1); | 699 ngx_reusable_connection(c, 1); |
694 } | 700 } |
695 | 701 |
696 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | 702 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
697 ngx_http_close_connection(c); | 703 ngx_http_close_connection(c); |
762 rc = ngx_ssl_handshake(c); | 768 rc = ngx_ssl_handshake(c); |
763 | 769 |
764 if (rc == NGX_AGAIN) { | 770 if (rc == NGX_AGAIN) { |
765 | 771 |
766 if (!rev->timer_set) { | 772 if (!rev->timer_set) { |
767 ngx_add_timer(rev, c->listening->post_accept_timeout); | 773 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, |
774 ngx_http_core_module); | |
775 ngx_add_timer(rev, cscf->client_header_timeout); | |
768 } | 776 } |
769 | 777 |
770 c->ssl->handler = ngx_http_ssl_handshake_handler; | 778 c->ssl->handler = ngx_http_ssl_handshake_handler; |
771 return; | 779 return; |
772 } | 780 } |
3456 ngx_shutdown_socket_n " failed"); | 3464 ngx_shutdown_socket_n " failed"); |
3457 ngx_http_close_request(r, 0); | 3465 ngx_http_close_request(r, 0); |
3458 return; | 3466 return; |
3459 } | 3467 } |
3460 | 3468 |
3469 c->close = 0; | |
3470 ngx_reusable_connection(c, 1); | |
3471 | |
3461 ngx_add_timer(rev, clcf->lingering_timeout); | 3472 ngx_add_timer(rev, clcf->lingering_timeout); |
3462 | 3473 |
3463 if (rev->ready) { | 3474 if (rev->ready) { |
3464 ngx_http_lingering_close_handler(rev); | 3475 ngx_http_lingering_close_handler(rev); |
3465 } | 3476 } |
3480 r = c->data; | 3491 r = c->data; |
3481 | 3492 |
3482 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 3493 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
3483 "http lingering close handler"); | 3494 "http lingering close handler"); |
3484 | 3495 |
3485 if (rev->timedout) { | 3496 if (rev->timedout || c->close) { |
3486 ngx_http_close_request(r, 0); | 3497 ngx_http_close_request(r, 0); |
3487 return; | 3498 return; |
3488 } | 3499 } |
3489 | 3500 |
3490 timer = (ngx_msec_t) r->lingering_time - (ngx_msec_t) ngx_time(); | 3501 timer = (ngx_msec_t) r->lingering_time - (ngx_msec_t) ngx_time(); |