mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 12:15:33 +00:00
Bug 1354968 - Avoid concurrent access of mTableRefreshness. r=francois
mTableRefreshness, a non-thread-safe object, might be accessed on worker thread and update thread cocurrently. To solve this issue, on update thread we only insert data to mNewTableRefreshness and merge to mTableRefreshness on the worker thread later. MozReview-Commit-ID: 9WgoeYfWVfK --HG-- extra : rebase_source : b7a8b4cd9d0fb1471cb81ee239f8343ff9a7b38a
This commit is contained in:
parent
9ab23a87f3
commit
a1d114de50
@ -621,6 +621,8 @@ Classifier::RemoveUpdateIntermediaries()
|
||||
}
|
||||
mNewLookupCaches.Clear();
|
||||
|
||||
mNewTableFreshness.Clear();
|
||||
|
||||
// Remove the "old" directory. (despite its looking-new name)
|
||||
if (NS_FAILED(mUpdatingDirectory->Remove(true))) {
|
||||
// If the directory is locked from removal for some reason,
|
||||
@ -685,16 +687,21 @@ Classifier::SwapInNewTablesAndCleanup()
|
||||
// up later.
|
||||
MergeNewLookupCaches();
|
||||
|
||||
// Step 3. Re-generate active tables based on on-disk tables.
|
||||
// Step 3. Merge mTableFreshnessForUpdate.
|
||||
for (auto itr = mNewTableFreshness.ConstIter(); !itr.Done(); itr.Next()) {
|
||||
mTableFreshness.Put(itr.Key(), itr.Data());
|
||||
}
|
||||
|
||||
// Step 4. Re-generate active tables based on on-disk tables.
|
||||
rv = RegenActiveTables();
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG(("Failed to re-generate active tables!"));
|
||||
}
|
||||
|
||||
// Step 4. Clean up intermediaries for update.
|
||||
// Step 5. Clean up intermediaries for update.
|
||||
RemoveUpdateIntermediaries();
|
||||
|
||||
// Step 5. Invalidate cached tableRequest request.
|
||||
// Step 6. Invalidate cached tableRequest request.
|
||||
mIsTableRequestResultOutdated = true;
|
||||
|
||||
LOG(("Done swap in updated tables."));
|
||||
@ -1299,7 +1306,7 @@ Classifier::UpdateHashStore(nsTArray<TableUpdate*>* aUpdates,
|
||||
|
||||
int64_t now = (PR_Now() / PR_USEC_PER_SEC);
|
||||
LOG(("Successfully updated %s", store.TableName().get()));
|
||||
mTableFreshness.Put(store.TableName(), now);
|
||||
mNewTableFreshness.Put(store.TableName(), now);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1401,7 +1408,7 @@ Classifier::UpdateTableV4(nsTArray<TableUpdate*>* aUpdates,
|
||||
|
||||
int64_t now = (PR_Now() / PR_USEC_PER_SEC);
|
||||
LOG(("Successfully updated %s\n", PromiseFlatCString(aTable).get()));
|
||||
mTableFreshness.Put(aTable, now);
|
||||
mNewTableFreshness.Put(aTable, now);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -214,6 +214,7 @@ private:
|
||||
uint32_t mHashKey;
|
||||
// Stores the last time a given table was updated (seconds).
|
||||
TableFreshnessMap mTableFreshness;
|
||||
TableFreshnessMap mNewTableFreshness;
|
||||
|
||||
// In-memory cache for the result of TableRequest. See
|
||||
// nsIUrlClassifierDBService.getTables for the format.
|
||||
|
Loading…
Reference in New Issue
Block a user