From 69b53b9aaa85ab47a2fdef452d0960a75f886b21 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 22 Sep 2016 23:17:49 +0900 Subject: [PATCH] nghttpx: Handle graceful shutdown with client IP affinity enabled --- src/shrpx_client_handler.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index bf72a907..aa7a8117 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -706,8 +706,21 @@ Http2Session *ClientHandler::select_http2_session_with_affinity( << ", index=" << (addr - shared_addr->addrs.data()); } - if (addr->http2_extra_freelist.size()) { - auto session = addr->http2_extra_freelist.head; + for (auto session = addr->http2_extra_freelist.head; session;) { + auto next = session->dlnext; + + if (session->max_concurrency_reached(0)) { + if (LOG_ENABLED(INFO)) { + CLOG(INFO, this) + << "Maximum streams have been reached for Http2Session(" << session + << "). Skip it"; + } + + session->remove_from_freelist(); + session = next; + + continue; + } if (LOG_ENABLED(INFO)) { CLOG(INFO, this) << "Use Http2Session " << session