From cd2b92b8febb75203b2f8b7f688469ef39464d5e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 29 Apr 2023 10:48:28 -0700 Subject: [PATCH] modules/client/keys/claim: Restore when_any() loop to smooth remote handling. --- modules/client/keys/claim.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/client/keys/claim.cc b/modules/client/keys/claim.cc index 3926717e9..3a8fe7212 100644 --- a/modules/client/keys/claim.cc +++ b/modules/client/keys/claim.cc @@ -228,9 +228,29 @@ recv_responses(const host_users_map &map, } // remote handle - for(auto &[remote, request] : queries) + while(!queries.empty()) { - assert(!failures.count(remote)); + auto next + { + ctx::when_any(begin(queries), end(queries), [] + (auto &it) -> m::fed::user::keys::claim & + { + return it->second; + }) + }; + + const bool ok + { + next.wait_until(timeout, std::nothrow) + }; + + const auto it(next.get()); + const unwind remove{[&queries, &it] + { + queries.erase(it); + }}; + + auto &[remote, request] {*it}; recv_response(remote, request, failures, one_time_keys, timeout); } }