# HG changeset patch # User Maxim Dounin # Date 1613069537 -10800 # Node ID 0a5687a458dead91c3fb8b2f4ef40a3c97215da0 # Parent fc536dcdbbf776d19ba53bbba4a5009da70b34ff HTTP/2: fixed reusing connections with active requests. New connections are marked reusable by ngx_http_init_connection() if there are no data available for reading. As a result, if SSL is not used, ngx_http_v2_init() might be called when the connection is marked reusable. If a HEADERS frame is immediately available for reading, this resulted in connection being preserved in reusable state with an active request, and possibly closed later as if during worker shutdown (that is, after all active requests were finalized). Fix is to explicitly mark connections non-reusable in ngx_http_v2_init() instead of (incorrectly) assuming they are already non-reusable. Found by Sergey Kandaurov. diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c --- a/src/http/v2/ngx_http_v2.c +++ b/src/http/v2/ngx_http_v2.c @@ -326,6 +326,7 @@ ngx_http_v2_init(ngx_event_t *rev) c->write->handler = ngx_http_v2_write_handler; c->idle = 1; + ngx_reusable_connection(c, 0); ngx_http_v2_read_handler(rev); }