diff options
-rw-r--r-- | src/p2p/net_node.inl | 69 | ||||
-rw-r--r-- | utils/gpg_keys/moneromooo.asc | 52 |
2 files changed, 93 insertions, 28 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 3454e112c..ee4a10789 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -259,53 +259,66 @@ namespace nodetool std::vector<std::vector<std::string>> dns_results; dns_results.resize(m_seed_nodes_list.size()); - std::unique_ptr<std::atomic_flag[]> dns_finished(new std::atomic_flag[m_seed_nodes_list.size()]); - - // set each flag, thread will release when finished - for (uint64_t i = 0; i < m_seed_nodes_list.size(); ++i) - dns_finished[i].test_and_set(); - + std::list<boost::thread*> dns_threads; uint64_t result_index = 0; for (const std::string& addr_str : m_seed_nodes_list) { - - uint64_t result_index_capture = result_index++; - boost::thread t([&] + boost::thread* th = new boost::thread([=, &dns_results, &addr_str] { + LOG_PRINT_L4("dns_threads[" << result_index << "] created for: " << addr_str) // TODO: care about dnssec avail/valid bool avail, valid; - std::vector<std::string> addr_list = tools::DNSResolver().get_ipv4(addr_str, avail, valid); - - dns_results[result_index_capture] = addr_list; - dns_finished[result_index_capture].clear(); + std::vector<std::string> addr_list; + + try + { + addr_list = tools::DNSResolver().get_ipv4(addr_str, avail, valid); + LOG_PRINT_L4("dns_threads[" << result_index << "] DNS resolve done"); + boost::this_thread::interruption_point(); + } + catch(const boost::thread_interrupted&) + { + // thread interruption request + // even if we now have results, finish thread without setting + // result variables, which are now out of scope in main thread + LOG_PRINT_L4("dns_threads[" << result_index << "] interrupted"); + return; + } + + LOG_PRINT_L4("dns_threads[" << result_index << "] addr_str: " << addr_str << " number of results: " << addr_list.size()); + dns_results[result_index] = addr_list; }); + dns_threads.push_back(th); + ++result_index; } - uint64_t sleep_count = 0; - uint64_t sleep_interval_ms = 100; - while (sleep_count++ * sleep_interval_ms < CRYPTONOTE_DNS_TIMEOUT_MS) + LOG_PRINT_L4("dns_threads created, now waiting for completion or timeout of " << CRYPTONOTE_DNS_TIMEOUT_MS << "ms"); + boost::chrono::system_clock::time_point deadline = boost::chrono::system_clock::now() + boost::chrono::milliseconds(CRYPTONOTE_DNS_TIMEOUT_MS); + uint64_t i = 0; + for (boost::thread* th : dns_threads) { - boost::this_thread::sleep(boost::posix_time::milliseconds(sleep_interval_ms)); - bool all_done = false; - for (uint64_t i = 0; i < m_seed_nodes_list.size(); ++i) + if (! th->try_join_until(deadline)) { - if (dns_finished[i].test_and_set()) - break; - else - dns_finished[i].clear(); - all_done = true; + LOG_PRINT_L4("dns_threads[" << i << "] timed out, sending interrupt"); + th->interrupt(); } - if (all_done) - break; + ++i; } + i = 0; for (const auto& result : dns_results) { - for (const auto& addr_string : result) + LOG_PRINT_L4("DNS lookup for " << m_seed_nodes_list[i] << ": " << result.size() << " results"); + // if no results for node, thread's lookup likely timed out + if (result.size()) { - append_net_address(m_seed_nodes, addr_string + ":18080"); + for (const auto& addr_string : result) + { + append_net_address(m_seed_nodes, addr_string + ":18080"); + } } + ++i; } if (!m_seed_nodes.size()) diff --git a/utils/gpg_keys/moneromooo.asc b/utils/gpg_keys/moneromooo.asc new file mode 100644 index 000000000..80cb7ae0b --- /dev/null +++ b/utils/gpg_keys/moneromooo.asc @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v2 + +mQINBFQym34BEADDKCspvziDW0f+T9i6iOewFO9m2XTWKXlQutCPgTkIlZZUrcTR +K+ApsfPxk+PBWgucQDPv/nJVs0CNaSzqewxk7Swjsf8+YjvRmxSSg/NQEgsiBx/s +M0JYlJfCwwFdk9+5b/eAnS3nhcZs/6lFSKk65YCCkj0NSQ6C07gEQyIFagLFKVqW +kAlJoMTURyFKPbcwLj/helG9kUT4I/1DdMx5GhKyL6ogFdLYH5iySAkblLk7I43T +jFE/1OcObKUtkAUgJSirrTJcQ+gtyRUUd/xyU3dE0s9T4h4mG+mm0zRzir+dtjQu +i1OWCjMEe1FItz7We8dWwFlM9G+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