mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
removed possible data race on boolean value (Not critical)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5161 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dc2d6c975e
commit
02a7548de4
@ -202,39 +202,46 @@ bool ExtAddrFinder::hasValidIP(struct in_addr *addr)
|
|||||||
std::cerr << "ExtAddrFinder: Getting ip." << std::endl ;
|
std::cerr << "ExtAddrFinder: Getting ip." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(*_found)
|
|
||||||
{
|
{
|
||||||
|
RsStackMutex mut(_addrMtx) ;
|
||||||
|
if(*_found)
|
||||||
|
{
|
||||||
#ifdef EXTADDRSEARCH_DEBUG
|
#ifdef EXTADDRSEARCH_DEBUG
|
||||||
std::cerr << "ExtAddrFinder: Has stored ip: responding with this ip." << std::endl ;
|
std::cerr << "ExtAddrFinder: Has stored ip: responding with this ip." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
*addr = *_addr;
|
*addr = *_addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
time_t delta;
|
||||||
|
{
|
||||||
|
RsStackMutex mut(_addrMtx) ;
|
||||||
|
//timeout the current ip
|
||||||
|
delta = time(NULL) - *mFoundTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//timeout the current ip
|
|
||||||
time_t delta = time(NULL) - *mFoundTS;
|
|
||||||
if((uint32_t)delta > MAX_IP_STORE) {//launch a research
|
if((uint32_t)delta > MAX_IP_STORE) {//launch a research
|
||||||
if( _addrMtx.trylock())
|
if( _addrMtx.trylock())
|
||||||
{
|
{
|
||||||
if(!*_searching)
|
if(!*_searching)
|
||||||
{
|
{
|
||||||
#ifdef EXTADDRSEARCH_DEBUG
|
#ifdef EXTADDRSEARCH_DEBUG
|
||||||
std::cerr << "ExtAddrFinder: No stored ip: Initiating new search." << std::endl ;
|
std::cerr << "ExtAddrFinder: No stored ip: Initiating new search." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
*_searching = true ;
|
*_searching = true ;
|
||||||
start_request() ;
|
start_request() ;
|
||||||
}
|
}
|
||||||
#ifdef EXTADDRSEARCH_DEBUG
|
#ifdef EXTADDRSEARCH_DEBUG
|
||||||
else
|
else
|
||||||
std::cerr << "ExtAddrFinder: Already searching." << std::endl ;
|
std::cerr << "ExtAddrFinder: Already searching." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
_addrMtx.unlock();
|
_addrMtx.unlock();
|
||||||
}
|
}
|
||||||
#ifdef EXTADDRSEARCH_DEBUG
|
#ifdef EXTADDRSEARCH_DEBUG
|
||||||
else
|
else
|
||||||
std::cerr << "ExtAddrFinder: (Note) Could not acquire lock. Busy." << std::endl ;
|
std::cerr << "ExtAddrFinder: (Note) Could not acquire lock. Busy." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsStackMutex mut(_addrMtx) ;
|
||||||
return *_found ;
|
return *_found ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user