From: Brad Hubbard Date: Sat, 14 Nov 2020 01:53:06 +0000 (+1000) Subject: test/admin_socket_output: Don't invalidate 'target' iterator X-Git-Tag: v14.2.14~2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=53740ffab619830dd389544a4b137067d5c35f22;p=ceph.git test/admin_socket_output: Don't invalidate 'target' iterator Fixes: https://tracker.ceph.com/issues/48204 Signed-off-by: Brad Hubbard --- diff --git a/src/test/admin_socket_output.cc b/src/test/admin_socket_output.cc index 1302391c9cb3..76e6e567726f 100644 --- a/src/test/admin_socket_output.cc +++ b/src/test/admin_socket_output.cc @@ -74,16 +74,20 @@ void AdminSocketOutput::postpone(const std::string &target, bool AdminSocketOutput::init_sockets() { std::cout << "Initialising sockets" << std::endl; - for (const auto &x : fs::directory_iterator(socketdir)) { + std::string socket_regex = R"(\..*\.asok)"; + for (const auto &x : fs::recursive_directory_iterator(socketdir)) { std::cout << x.path() << std::endl; if (x.path().extension() == ".asok") { - for (auto &target : targets) { - if (std::regex_search(x.path().filename().string(), - std::regex(prefix + target + R"(\..*\.asok)"))) { - std::cout << "Found " << target << " socket " << x.path() + for (auto target = targets.cbegin(); target != targets.cend();) { + std::regex reg(prefix + *target + socket_regex); + if (std::regex_search(x.path().filename().string(), reg)) { + std::cout << "Found " << *target << " socket " << x.path() << std::endl; - sockets.insert(std::make_pair(target, x.path().string())); - targets.erase(target); + sockets.insert(std::make_pair(*target, x.path().string())); + target = targets.erase(target); + } + else { + ++target; } } if (targets.empty()) {