Bug 1396958 - Make eTLD cache thread-safe. r=valentin

Restrict the MRU cache for eTLD lookups to main thread only. This allows off
main thread lookups, but they will just take a slower path.

--HG--
extra : rebase_source : bb0676fc1be9dc6e02762a978b43765d79dcdfff
This commit is contained in:
Eric Rahm 2017-09-05 12:26:51 -07:00
Родитель 6d8e605a80
Коммит 80d3d41e39
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -212,9 +212,10 @@ nsEffectiveTLDService::GetBaseDomainInternal(nsCString &aHostname,
if (result == PR_SUCCESS)
return NS_ERROR_HOST_IS_IP_ADDRESS;
// Lookup in the cache if this is a normal query.
// Lookup in the cache if this is a normal query. This is restricted to
// main thread-only as the cache is not thread-safe.
TLDCacheEntry* entry = nullptr;
if (aAdditionalParts == 1) {
if (aAdditionalParts == 1 && NS_IsMainThread()) {
if (LookupForAdd(aHostname, &entry)) {
// There was a match, just return the cached value.
aBaseDomain = entry->mBaseDomain;