comparison src/http/v2/ngx_http_v2.c @ 7783:171682010da4

HTTP/2: client_header_timeout before first request (ticket #2142). With this change, behaviour of HTTP/2 becomes even closer to HTTP/1.x, and client_header_timeout instead of keepalive_timeout is used before the first request is received. This fixes HTTP/2 connections being closed even before the first request if "keepalive_timeout 0;" was used in the configuration; the problem appeared in f790816a0e87 (1.19.7).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 01 Mar 2021 17:31:28 +0300
parents 827202ca1269
children ade8160120c1
comparison
equal deleted inserted replaced
7782:dea93b6dce94 7783:171682010da4
236 ngx_pool_cleanup_t *cln; 236 ngx_pool_cleanup_t *cln;
237 ngx_http_connection_t *hc; 237 ngx_http_connection_t *hc;
238 ngx_http_v2_srv_conf_t *h2scf; 238 ngx_http_v2_srv_conf_t *h2scf;
239 ngx_http_v2_main_conf_t *h2mcf; 239 ngx_http_v2_main_conf_t *h2mcf;
240 ngx_http_v2_connection_t *h2c; 240 ngx_http_v2_connection_t *h2c;
241 ngx_http_core_srv_conf_t *cscf;
241 242
242 c = rev->data; 243 c = rev->data;
243 hc = c->data; 244 hc = c->data;
244 245
245 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "init http2 connection"); 246 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "init http2 connection");
323 c->data = h2c; 324 c->data = h2c;
324 325
325 rev->handler = ngx_http_v2_read_handler; 326 rev->handler = ngx_http_v2_read_handler;
326 c->write->handler = ngx_http_v2_write_handler; 327 c->write->handler = ngx_http_v2_write_handler;
327 328
328 if (c->read->timer_set) { 329 if (!rev->timer_set) {
329 ngx_del_timer(c->read); 330 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
331 ngx_http_core_module);
332 ngx_add_timer(rev, cscf->client_header_timeout);
330 } 333 }
331 334
332 c->idle = 1; 335 c->idle = 1;
333 ngx_reusable_connection(c, 0); 336 ngx_reusable_connection(c, 0);
334 337