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:
Gioacchino Mazzurco 2019-08-28 21:39:25 +02:00
parent ac8043806b
commit 85ef0e0940
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
2 changed files with 7 additions and 7 deletions

View File

@ -306,18 +306,23 @@ bool p3BanList::acceptedBanRanges_locked(const BanListPeer& blp)
}
return false ;
}
bool p3BanList::isAddressAccepted(
const sockaddr_storage& dAddr, uint32_t checking_flags,
uint32_t& check_result )
{
check_result = RSBANLIST_CHECK_RESULT_NOCHECK;
if(!mIPFilteringEnabled) return true;
sockaddr_storage addr; sockaddr_storage_copy(dAddr, addr);
if(!sockaddr_storage_ipv6_to_ipv4(addr)) return true;
if(sockaddr_storage_isLoopbackNet(addr)) return true;
RS_STACK_MUTEX(mBanMtx);
if(!mIPFilteringEnabled) return true;
#ifdef DEBUG_BANLIST
std::cerr << "isAddressAccepted(): tested addr=" << sockaddr_storage_iptostring(addr) << ", checking flags=" << checking_flags ;
#endif
@ -409,6 +414,7 @@ bool p3BanList::isAddressAccepted(
check_result = RSBANLIST_CHECK_RESULT_ACCEPTED;
return true ;
}
void p3BanList::getWhiteListedIps(std::list<BanListPeer> &lst)
{
RS_STACK_MUTEX(mBanMtx) ;
@ -582,11 +588,6 @@ int p3BanList::tick()
return 0;
}
int p3BanList::status()
{
return 1;
}
void p3BanList::getDhtInfo()
{
// Get the list of masquerading peers from the DHT. Add them as potential IPs to be banned.

View File

@ -105,7 +105,6 @@ public:
*/
virtual int tick();
virtual int status();
int sendPackets();
bool processIncoming();