From 1ac028e166ae88351bfb0607cd4f9bf9d5e78ba5 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 16 May 2014 22:32:08 +0900 Subject: [PATCH] Take into account that pending_local_max_concurrent_stream could be too large pending_local_max_concurrent_stream is, once local settings applied, becomes NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS, which is very large number. When adjusting number of streams, we have to take min of local effective SETTINGS_MAX_CONCURRENT_STREAMS and pending one. --- lib/nghttp2_session.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 3635c157..8bf399e0 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -889,15 +889,22 @@ void nghttp2_session_keep_closed_stream(nghttp2_session *session, void nghttp2_session_adjust_closed_stream(nghttp2_session *session, ssize_t offset) { + size_t num_stream_max; + + num_stream_max = + nghttp2_min + (session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS], + session->pending_local_max_concurrent_stream); + DEBUGF(fprintf(stderr, "stream: adjusting kept closed streams " "num_closed_streams=%zu, num_incoming_streams=%zu, " "max_concurrent_streams=%u\n", session->num_closed_streams, session->num_incoming_streams, - session->pending_local_max_concurrent_stream)); + num_stream_max)); while(session->num_closed_streams > 0 && session->num_closed_streams + session->num_incoming_streams + offset - > session->pending_local_max_concurrent_stream) { + > num_stream_max) { nghttp2_stream *head_stream; head_stream = session->closed_stream_head;