added checks for result of pthread_create (issue #126)

This commit is contained in:
csoler 2015-10-20 18:39:32 -04:00
parent f49f7ac763
commit 6398ed2c17
4 changed files with 36 additions and 15 deletions

View file

@ -101,15 +101,18 @@ void *solveDNSEntries(void *p)
void DNSResolver::start_request()
{
{
RsStackMutex mut(_rdnsMtx) ;
*_thread_running = true ;
}
{
RsStackMutex mut(_rdnsMtx) ;
*_thread_running = true ;
}
void *data = (void *)this;
pthread_t tid ;
pthread_create(&tid, 0, &solveDNSEntries, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
void *data = (void *)this;
pthread_t tid ;
if(! pthread_create(&tid, 0, &solveDNSEntries, data))
pthread_detach(tid); /* so memory is reclaimed in linux */
else
std::cerr << "(EE) Could not start DNS resolver thread!" << std::endl;
}
void DNSResolver::reset()

View file

@ -209,8 +209,11 @@ void ExtAddrFinder::start_request()
{
void *data = (void *)this;
pthread_t tid ;
pthread_create(&tid, 0, &doExtAddrSearch, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
if(! pthread_create(&tid, 0, &doExtAddrSearch, data))
pthread_detach(tid); /* so memory is reclaimed in linux */
else
std::cerr << "(EE) Could not start ExtAddrFinder thread." << std::endl;
}
bool ExtAddrFinder::hasValidIP(struct sockaddr_storage &addr)