DNSLookup: copy hostname and port instead of accessing member
This commit is contained in:
parent
6deaa03114
commit
121acdab6f
@ -105,7 +105,7 @@ namespace ix
|
|||||||
// Good resource on thread forced termination
|
// Good resource on thread forced termination
|
||||||
// https://www.bo-yang.net/2017/11/19/cpp-kill-detached-thread
|
// https://www.bo-yang.net/2017/11/19/cpp-kill-detached-thread
|
||||||
//
|
//
|
||||||
_thread = std::thread(&DNSLookup::run, this);
|
_thread = std::thread(&DNSLookup::run, this, _hostname, _port);
|
||||||
_thread.detach();
|
_thread.detach();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(_conditionVariableMutex);
|
std::unique_lock<std::mutex> lock(_conditionVariableMutex);
|
||||||
@ -138,11 +138,11 @@ namespace ix
|
|||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNSLookup::run()
|
void DNSLookup::run(const std::string& hostname, int port) // thread runner
|
||||||
{
|
{
|
||||||
uint64_t id = _id;
|
uint64_t id = _id;
|
||||||
std::string errMsg;
|
std::string errMsg;
|
||||||
_res = getAddrInfo(_hostname, _port, errMsg);
|
_res = getAddrInfo(hostname, port, errMsg);
|
||||||
|
|
||||||
// if this isn't an active job, and the control thread is gone
|
// if this isn't an active job, and the control thread is gone
|
||||||
// there is not thing to do, and we don't want to touch the defunct
|
// there is not thing to do, and we don't want to touch the defunct
|
||||||
|
@ -43,7 +43,7 @@ namespace ix
|
|||||||
int port,
|
int port,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
|
|
||||||
void run(); // thread runner
|
void run(const std::string& hostname, int port); // thread runner
|
||||||
|
|
||||||
std::string _hostname;
|
std::string _hostname;
|
||||||
int _port;
|
int _port;
|
||||||
|
Loading…
Reference in New Issue
Block a user