Klaus Demo nginx / 0a5e969
HTTP/2: fixed connection finalization. All streams in connection must be finalized before the connection itself can be finalized and all related memory is freed. That's not always possible on the current event loop iteration. Thus when the last stream is finalized, it sets the special read event handler ngx_http_v2_handle_connection_handler() and posts the event. Previously, this handler didn't check the connection state and could call the regular event handler on a connection that was already in finalization stage. In the worst case that could lead to a segmentation fault, since some data structures aren't supposed to be used during connection finalization. Particularly, the waiting queue can contain already freed streams, so the WINDOW_UPDATE frame received by that moment could trigger accessing to these freed streams. Now, the connection error flag is explicitly checked in ngx_http_v2_handle_connection_handler(). Valentin Bartenev 3 years ago
1 changed file(s) with 8 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
41334133 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
41344134 "http2 handle connection handler");
41354135
4136 c = rev->data;
4137 h2c = c->data;
4138
4139 if (c->error) {
4140 ngx_http_v2_finalize_connection(h2c, 0);
4141 return;
4142 }
4143
41364144 rev->handler = ngx_http_v2_read_handler;
41374145
41384146 if (rev->ready) {
41394147 ngx_http_v2_read_handler(rev);
41404148 return;
41414149 }
4142
4143 c = rev->data;
4144 h2c = c->data;
41454150
41464151 if (h2c->last_out && ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) {
41474152 ngx_http_v2_finalize_connection(h2c, 0);