summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2019-12-23 21:25:17 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2019-12-23 21:25:17 +0300
commit49709f75b262c483550cc826471839f624765ab1 (patch)
treeaa0f4091630184d0ea79c5bccc5d75f9de4aabf4
parent5e5fa2e9e57b713e445b1737005ff6a202bda8ad (diff)
downloadnginx-49709f75b262c483550cc826471839f624765ab1.tar.gz
HTTP/2: fixed socket leak with queued frames (ticket #1689).
If a stream is closed with queued frames, it is possible that no further write events will occur on the stream, leading to the socket leak. To fix this, the stream's fake connection read handler is set to ngx_http_v2_close_stream_handler(), to make sure that finalizing the connection with ngx_http_v2_finalize_connection() will be able to close the stream regardless of the current number of queued frames. Additionally, the stream's fake connection fc->error flag is explicitly set, so ngx_http_v2_handle_stream() will post a write event when queued frames are finally sent even if stream flow control window is exhausted.
-rw-r--r--src/http/v2/ngx_http_v2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
index d0e44475c..d28b8090a 100644
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -4288,8 +4288,9 @@ ngx_http_v2_close_stream(ngx_http_v2_stream_t *stream, ngx_int_t rc)
fc = stream->request->connection;
if (stream->queued) {
+ fc->error = 1;
fc->write->handler = ngx_http_v2_close_stream_handler;
- fc->read->handler = ngx_http_empty_handler;
+ fc->read->handler = ngx_http_v2_close_stream_handler;
return;
}