mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-23 05:44:45 -04:00
Protect p3BanList::isAddressAccepted with mutex
This method is called from other threads and apparently caused a sporadic crash caought on Android. See retroshare://forum?name=Got%20crash%20on%20Android%20with%20GDB%20backtrace&id=95de1451952d8c38cb1cdfdb85eed986&msgid=ac8c9d41f2cd0c9e8e290433c7f296fecb2d62b3
This commit is contained in:
parent
ac8043806b
commit
85ef0e0940
2 changed files with 7 additions and 7 deletions
|
@ -306,18 +306,23 @@ bool p3BanList::acceptedBanRanges_locked(const BanListPeer& blp)
|
||||||
}
|
}
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3BanList::isAddressAccepted(
|
bool p3BanList::isAddressAccepted(
|
||||||
const sockaddr_storage& dAddr, uint32_t checking_flags,
|
const sockaddr_storage& dAddr, uint32_t checking_flags,
|
||||||
uint32_t& check_result )
|
uint32_t& check_result )
|
||||||
{
|
{
|
||||||
check_result = RSBANLIST_CHECK_RESULT_NOCHECK;
|
check_result = RSBANLIST_CHECK_RESULT_NOCHECK;
|
||||||
if(!mIPFilteringEnabled) return true;
|
|
||||||
|
|
||||||
sockaddr_storage addr; sockaddr_storage_copy(dAddr, addr);
|
sockaddr_storage addr; sockaddr_storage_copy(dAddr, addr);
|
||||||
|
|
||||||
if(!sockaddr_storage_ipv6_to_ipv4(addr)) return true;
|
if(!sockaddr_storage_ipv6_to_ipv4(addr)) return true;
|
||||||
if(sockaddr_storage_isLoopbackNet(addr)) return true;
|
if(sockaddr_storage_isLoopbackNet(addr)) return true;
|
||||||
|
|
||||||
|
|
||||||
|
RS_STACK_MUTEX(mBanMtx);
|
||||||
|
|
||||||
|
if(!mIPFilteringEnabled) return true;
|
||||||
|
|
||||||
#ifdef DEBUG_BANLIST
|
#ifdef DEBUG_BANLIST
|
||||||
std::cerr << "isAddressAccepted(): tested addr=" << sockaddr_storage_iptostring(addr) << ", checking flags=" << checking_flags ;
|
std::cerr << "isAddressAccepted(): tested addr=" << sockaddr_storage_iptostring(addr) << ", checking flags=" << checking_flags ;
|
||||||
#endif
|
#endif
|
||||||
|
@ -409,6 +414,7 @@ bool p3BanList::isAddressAccepted(
|
||||||
check_result = RSBANLIST_CHECK_RESULT_ACCEPTED;
|
check_result = RSBANLIST_CHECK_RESULT_ACCEPTED;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3BanList::getWhiteListedIps(std::list<BanListPeer> &lst)
|
void p3BanList::getWhiteListedIps(std::list<BanListPeer> &lst)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mBanMtx) ;
|
RS_STACK_MUTEX(mBanMtx) ;
|
||||||
|
@ -582,11 +588,6 @@ int p3BanList::tick()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p3BanList::status()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void p3BanList::getDhtInfo()
|
void p3BanList::getDhtInfo()
|
||||||
{
|
{
|
||||||
// Get the list of masquerading peers from the DHT. Add them as potential IPs to be banned.
|
// Get the list of masquerading peers from the DHT. Add them as potential IPs to be banned.
|
||||||
|
|
|
@ -105,7 +105,6 @@ public:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
virtual int tick();
|
virtual int tick();
|
||||||
virtual int status();
|
|
||||||
|
|
||||||
int sendPackets();
|
int sendPackets();
|
||||||
bool processIncoming();
|
bool processIncoming();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue