From 9a10148c019add4ba7928271b951fb65fd7fe838 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 28 Jul 2017 22:23:05 +0100 Subject: p2p: fix thread leak --- src/p2p/net_node.inl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index b23090c7d..4ecf8f710 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -444,11 +444,11 @@ namespace nodetool std::vector> dns_results; dns_results.resize(m_seed_nodes_list.size()); - std::list dns_threads; + std::list dns_threads; uint64_t result_index = 0; for (const std::string& addr_str : m_seed_nodes_list) { - boost::thread* th = new boost::thread([=, &dns_results, &addr_str] + boost::thread th = boost::thread([=, &dns_results, &addr_str] { MDEBUG("dns_threads[" << result_index << "] created for: " << addr_str); // TODO: care about dnssec avail/valid @@ -474,19 +474,19 @@ namespace nodetool dns_results[result_index] = addr_list; }); - dns_threads.push_back(th); + dns_threads.push_back(std::move(th)); ++result_index; } MDEBUG("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) + for (boost::thread& th : dns_threads) { - if (! th->try_join_until(deadline)) + if (! th.try_join_until(deadline)) { MWARNING("dns_threads[" << i << "] timed out, sending interrupt"); - th->interrupt(); + th.interrupt(); } ++i; } -- cgit v1.2.3