Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Unified Diff: base/metrics/statistics_recorder.cc

Issue 1872713002: Remove unnecessary lock that causes reentry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comment as to why Import is done before lock Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder.cc
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index b19a897a96c1ab6e2d7737bd2648100c9bd10281..404a6554a0a237d3289a0bd9e7c5f60d82e4f69e 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -285,18 +285,22 @@ void StatisticsRecorder::GetBucketRanges(
HistogramBase* StatisticsRecorder::FindHistogram(base::StringPiece name) {
if (lock_ == NULL)
return NULL;
- base::AutoLock auto_lock(*lock_);
- if (histograms_ == NULL)
- return NULL;
// Import histograms from known persistent storage. Histograms could have
// been added by other processes and they must be fetched and recognized
// locally. If the persistent memory segment is not shared between processes,
// this call does nothing.
+ // This must be called *before* the lock is acquired below because it will
+ // call back into this object to register histograms. Those called methods
+ // will acquire the lock at that time.
GlobalHistogramAllocator* allocator = GlobalHistogramAllocator::Get();
if (allocator)
allocator->ImportHistogramsToStatisticsRecorder();
+ base::AutoLock auto_lock(*lock_);
+ if (histograms_ == NULL)
+ return NULL;
+
HistogramMap::iterator it = histograms_->find(name);
if (histograms_->end() == it)
return NULL;
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698