From 40af31da4c27f26837e0f43bf4f9c070a9521caa Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 14 Jul 2021 23:09:28 +0900 Subject: [PATCH] nghttpx: Set connect_blocker and live_check after shuffling addresses --- src/shrpx_worker.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index 88f632b6..8273b58f 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -275,21 +275,6 @@ void Worker::replace_downstream_config( dst_addr.rise = src_addr.rise; dst_addr.dns = src_addr.dns; dst_addr.upgrade_scheme = src_addr.upgrade_scheme; - - auto shared_addr_ptr = shared_addr.get(); - - dst_addr.connect_blocker = std::make_unique( - randgen_, loop_, nullptr, [shared_addr_ptr, &dst_addr]() { - if (!dst_addr.queued) { - if (!dst_addr.wg) { - return; - } - ensure_enqueue_addr(shared_addr_ptr->pq, dst_addr.wg, &dst_addr); - } - }); - - dst_addr.live_check = std::make_unique( - loop_, cl_ssl_ctx_, this, &dst_addr, randgen_); } #ifdef HAVE_MRUBY @@ -313,6 +298,23 @@ void Worker::replace_downstream_config( std::shuffle(std::begin(shared_addr->addrs), std::end(shared_addr->addrs), randgen_); + auto shared_addr_ptr = shared_addr.get(); + + for (auto &addr : shared_addr->addrs) { + addr.connect_blocker = std::make_unique( + randgen_, loop_, nullptr, [shared_addr_ptr, &addr]() { + if (!addr.queued) { + if (!addr.wg) { + return; + } + ensure_enqueue_addr(shared_addr_ptr->pq, addr.wg, &addr); + } + }); + + addr.live_check = std::make_unique(loop_, cl_ssl_ctx_, this, + &addr, randgen_); + } + size_t seq = 0; for (auto &addr : shared_addr->addrs) { addr.dconn_pool = std::make_unique();