From d45b7b68a2a34e3c1d97713182262a17ba030259 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 25 Aug 2015 14:01:51 +0200 Subject: [PATCH] Fix load_balance: does not retry dead target MP-626 --- src/filter_load_balance.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/filter_load_balance.cpp b/src/filter_load_balance.cpp index dafe8f3..1ad761c 100644 --- a/src/filter_load_balance.cpp +++ b/src/filter_load_balance.cpp @@ -150,8 +150,8 @@ void yf::LoadBalance::Impl::process(mp::Package &package) // they turn out to be bad.. while (1) { - std::string target; std::list::iterator ivh = vhosts.begin(); + std::list::iterator ivh_pick = vhosts.end(); Package init_pkg(package.session(), package.origin()); init_pkg.copy_filter(package); @@ -160,7 +160,7 @@ void yf::LoadBalance::Impl::process(mp::Package &package) { boost::mutex::scoped_lock scoped_lock(m_mutex); - for (; ivh != vhosts.end(); ) + for (; ivh != vhosts.end(); ivh++) { if ((*ivh).size() != 0) { @@ -170,21 +170,17 @@ void yf::LoadBalance::Impl::process(mp::Package &package) (*ivh).c_str(), cost, vhcost); if (cost > vhcost) { + ivh_pick = ivh; cost = vhcost; - target = *ivh; - ivh = vhosts.erase(ivh); } - else - ivh++; } - else - ivh++; } } - if (target.length() == 0) + if (ivh_pick == vhosts.end()) break; + std::string target = *ivh_pick; + vhosts.erase(ivh_pick); // copying new target into init package - yazpp_1::GDU init_gdu(base_req); Z_InitRequest *init_req = init_gdu.get()->u.z3950->u.initRequest; -- 1.7.10.4