diff --git a/src/command_download.cc b/src/command_download.cc index d0e0d632..d72aba5d 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -1,5 +1,6 @@ #include "config.h" +#include #include #include #include @@ -308,8 +309,10 @@ apply_d_add_peer(core::Download* download, const std::string& arg) { if (port < 1 || port > 65535) throw torrent::input_error("Invalid port number."); + assert(std::this_thread::get_id() == torrent::main_thread()->thread_id()); + // Currently discarding SOCK_STREAM. - torrent::main_thread()->resolver()->resolve_preferred(NULL, host, AF_UNSPEC, AF_INET, [download, port](torrent::c_sa_shared_ptr sa, int err) { + torrent::this_thread::resolver()->resolve_preferred(NULL, host, AF_UNSPEC, AF_INET, [download, port](torrent::c_sa_shared_ptr sa, int err) { if (sa == nullptr) { lt_log_print(torrent::LOG_TORRENT_WARN, "could not resolve hostname for added peer: %s", gai_strerror(err)); return; diff --git a/src/command_tracker.cc b/src/command_tracker.cc index e7f75727..9a1d8a62 100644 --- a/src/command_tracker.cc +++ b/src/command_tracker.cc @@ -1,5 +1,6 @@ #include "config.h" +#include #include #include #include @@ -44,8 +45,10 @@ apply_dht_add_node(const std::string& arg) { if (port < 1 || port > 65535) throw torrent::input_error("Invalid port number."); + assert(std::this_thread::get_id() == torrent::main_thread()->thread_id()); + // Currently discarding SOCK_STREAM. - torrent::main_thread()->resolver()->resolve_specific(nullptr, host, PF_INET, [port](torrent::c_sa_shared_ptr sa, int err) { + torrent::this_thread::resolver()->resolve_specific(nullptr, host, PF_INET, [port](torrent::c_sa_shared_ptr sa, int err) { if (sa == nullptr) { lt_log_print(torrent::LOG_DHT_WARN, "Could not resolve host: %s", gai_strerror(err)); return;