comparison src/http/ngx_http_request.c @ 8647:507da0d3b070 quic

Merged with the default branch.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 24 Nov 2020 17:19:40 +0000
parents 279ad36f2f4b 554c6ae25ffc
children 9dce2978e4fd
comparison
equal deleted inserted replaced
8646:4bf332873a83 8647:507da0d3b070
47 static void ngx_http_writer(ngx_http_request_t *r); 47 static void ngx_http_writer(ngx_http_request_t *r);
48 static void ngx_http_request_finalizer(ngx_http_request_t *r); 48 static void ngx_http_request_finalizer(ngx_http_request_t *r);
49 49
50 static void ngx_http_set_keepalive(ngx_http_request_t *r); 50 static void ngx_http_set_keepalive(ngx_http_request_t *r);
51 static void ngx_http_keepalive_handler(ngx_event_t *ev); 51 static void ngx_http_keepalive_handler(ngx_event_t *ev);
52 static void ngx_http_set_lingering_close(ngx_http_request_t *r); 52 static void ngx_http_set_lingering_close(ngx_connection_t *c);
53 static void ngx_http_lingering_close_handler(ngx_event_t *ev); 53 static void ngx_http_lingering_close_handler(ngx_event_t *ev);
54 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); 54 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r);
55 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error); 55 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error);
56 static void ngx_http_log_request(ngx_http_request_t *r); 56 static void ngx_http_log_request(ngx_http_request_t *r);
57 57
2891 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON 2891 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON
2892 && (r->lingering_close 2892 && (r->lingering_close
2893 || r->header_in->pos < r->header_in->last 2893 || r->header_in->pos < r->header_in->last
2894 || r->connection->read->ready))) 2894 || r->connection->read->ready)))
2895 { 2895 {
2896 ngx_http_set_lingering_close(r); 2896 ngx_http_set_lingering_close(r->connection);
2897 return; 2897 return;
2898 } 2898 }
2899 2899
2900 ngx_http_close_request(r, 0); 2900 ngx_http_close_request(r, 0);
2901 } 2901 }
3188 rev = c->read; 3188 rev = c->read;
3189 3189
3190 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 3190 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
3191 3191
3192 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler"); 3192 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler");
3193
3194 if (r->discard_body) {
3195 r->write_event_handler = ngx_http_request_empty_handler;
3196 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000);
3197 ngx_add_timer(rev, clcf->lingering_timeout);
3198 return;
3199 }
3200 3193
3201 c->log->action = "closing request"; 3194 c->log->action = "closing request";
3202 3195
3203 hc = r->http_connection; 3196 hc = r->http_connection;
3204 b = r->header_in; 3197 b = r->header_in;
3525 ngx_http_process_request_line(rev); 3518 ngx_http_process_request_line(rev);
3526 } 3519 }
3527 3520
3528 3521
3529 static void 3522 static void
3530 ngx_http_set_lingering_close(ngx_http_request_t *r) 3523 ngx_http_set_lingering_close(ngx_connection_t *c)
3531 { 3524 {
3532 ngx_event_t *rev, *wev; 3525 ngx_event_t *rev, *wev;
3533 ngx_connection_t *c; 3526 ngx_http_request_t *r;
3534 ngx_http_core_loc_conf_t *clcf; 3527 ngx_http_core_loc_conf_t *clcf;
3535 3528
3536 c = r->connection; 3529 r = c->data;
3537 3530
3538 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 3531 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
3532
3533 if (r->lingering_time == 0) {
3534 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000);
3535 }
3536
3537 #if (NGX_HTTP_SSL)
3538 if (c->ssl) {
3539 ngx_int_t rc;
3540
3541 rc = ngx_ssl_shutdown(c);
3542
3543 if (rc == NGX_ERROR) {
3544 ngx_http_close_request(r, 0);
3545 return;
3546 }
3547
3548 if (rc == NGX_AGAIN) {
3549 c->ssl->handler = ngx_http_set_lingering_close;
3550 return;
3551 }
3552
3553 c->recv = ngx_recv;
3554 }
3555 #endif
3539 3556
3540 rev = c->read; 3557 rev = c->read;
3541 rev->handler = ngx_http_lingering_close_handler; 3558 rev->handler = ngx_http_lingering_close_handler;
3542
3543 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000);
3544 ngx_add_timer(rev, clcf->lingering_timeout);
3545 3559
3546 if (ngx_handle_read_event(rev, 0) != NGX_OK) { 3560 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
3547 ngx_http_close_request(r, 0); 3561 ngx_http_close_request(r, 0);
3548 return; 3562 return;
3549 } 3563 }
3565 ngx_http_close_request(r, 0); 3579 ngx_http_close_request(r, 0);
3566 return; 3580 return;
3567 } 3581 }
3568 } 3582 }
3569 3583
3584 ngx_add_timer(rev, clcf->lingering_timeout);
3585
3570 if (rev->ready) { 3586 if (rev->ready) {
3571 ngx_http_lingering_close_handler(rev); 3587 ngx_http_lingering_close_handler(rev);
3572 } 3588 }
3573 } 3589 }
3574 3590