dns lookup: fix race condition accessing _errMsg

This commit is contained in:
Benjamin Sergeant
2019-04-29 19:29:27 -07:00
parent 9dca893ce7
commit 6d310d417a
2 changed files with 41 additions and 16 deletions

View File

@ -45,12 +45,21 @@ namespace ix
void run(uint64_t id, std::string hostname, int port); // thread runner
void setErrMsg(const std::string& errMsg);
const std::string& getErrMsg();
void setRes(struct addrinfo* addr);
struct addrinfo* getRes();
std::string _hostname;
int _port;
int64_t _wait;
std::string _errMsg;
struct addrinfo* _res;
static std::mutex _resMutex;
std::mutex _resMutex;
std::string _errMsg;
std::mutex _errMsgMutex;
std::atomic<bool> _done;
std::thread _thread;