comparison src/http/v2/ngx_http_v2.c @ 7766:3e83336cda5b

Reuse of connections in lingering close. This is particularly important in HTTP/2, where keepalive connections are closed with lingering. Before the patch, reusing a keepalive HTTP/2 connection resulted in the connection waiting for lingering close to remain in the reusable connections queue, preventing ngx_drain_connections() from closing additional connections. The patch fixes it by marking the connection reusable again, and so moving it in the reusable connections queue. Further, it makes actually possible to reuse such connections if needed.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 11 Feb 2021 21:52:09 +0300
parents 519b55453c45
children fc536dcdbbf7
comparison
equal deleted inserted replaced
7765:519b55453c45 7766:3e83336cda5b
765 ngx_shutdown_socket_n " failed"); 765 ngx_shutdown_socket_n " failed");
766 ngx_http_close_connection(c); 766 ngx_http_close_connection(c);
767 return; 767 return;
768 } 768 }
769 769
770 c->close = 0;
771 ngx_reusable_connection(c, 1);
772
770 ngx_add_timer(rev, clcf->lingering_timeout); 773 ngx_add_timer(rev, clcf->lingering_timeout);
771 774
772 if (rev->ready) { 775 if (rev->ready) {
773 ngx_http_v2_lingering_close_handler(rev); 776 ngx_http_v2_lingering_close_handler(rev);
774 } 777 }
789 h2c = c->data; 792 h2c = c->data;
790 793
791 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, 794 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
792 "http2 lingering close handler"); 795 "http2 lingering close handler");
793 796
794 if (rev->timedout) { 797 if (rev->timedout || c->close) {
795 ngx_http_close_connection(c); 798 ngx_http_close_connection(c);
796 return; 799 return;
797 } 800 }
798 801
799 timer = (ngx_msec_t) h2c->lingering_time - (ngx_msec_t) ngx_time(); 802 timer = (ngx_msec_t) h2c->lingering_time - (ngx_msec_t) ngx_time();