mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 16:27:01 -05:00
added checks for result of pthread_create (issue #126)
This commit is contained in:
parent
f49f7ac763
commit
6398ed2c17
@ -103,10 +103,18 @@ bool upnphandler::background_setup_upnp(bool start, bool stop)
|
|||||||
data->start = start;
|
data->start = start;
|
||||||
data->stop = stop;
|
data->stop = stop;
|
||||||
|
|
||||||
pthread_create(&tid, 0, &doSetupUPnP, (void *) data);
|
if(! pthread_create(&tid, 0, &doSetupUPnP, (void *) data))
|
||||||
|
{
|
||||||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
pthread_detach(tid); /* so memory is reclaimed in linux */
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete data ;
|
||||||
|
std::cerr << "(EE) Could not start background upnp thread!" << std::endl;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool upnphandler::start_upnp()
|
bool upnphandler::start_upnp()
|
||||||
|
@ -236,10 +236,17 @@ bool upnphandler::background_setup_upnp(bool start, bool stop)
|
|||||||
data->start = start;
|
data->start = start;
|
||||||
data->stop = stop;
|
data->stop = stop;
|
||||||
|
|
||||||
pthread_create(&tid, 0, &doSetupUPnP, (void *) data);
|
if(!pthread_create(&tid, 0, &doSetupUPnP, (void *) data))
|
||||||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
{
|
||||||
|
pthread_detach(tid); /* so memory is reclaimed in linux */
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete data ;
|
||||||
|
std::cerr << "(EE) Failed to start upnp thread." << std::endl;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool upnphandler::start_upnp()
|
bool upnphandler::start_upnp()
|
||||||
|
@ -101,15 +101,18 @@ void *solveDNSEntries(void *p)
|
|||||||
|
|
||||||
void DNSResolver::start_request()
|
void DNSResolver::start_request()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
RsStackMutex mut(_rdnsMtx) ;
|
RsStackMutex mut(_rdnsMtx) ;
|
||||||
*_thread_running = true ;
|
*_thread_running = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *data = (void *)this;
|
void *data = (void *)this;
|
||||||
pthread_t tid ;
|
pthread_t tid ;
|
||||||
pthread_create(&tid, 0, &solveDNSEntries, data);
|
|
||||||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
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()
|
void DNSResolver::reset()
|
||||||
|
@ -209,8 +209,11 @@ void ExtAddrFinder::start_request()
|
|||||||
{
|
{
|
||||||
void *data = (void *)this;
|
void *data = (void *)this;
|
||||||
pthread_t tid ;
|
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)
|
bool ExtAddrFinder::hasValidIP(struct sockaddr_storage &addr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user