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

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 1186053006: [tracing] fix a data race in MemoryDumpManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: femto perf improvement Created 5 years, 6 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 | « no previous file | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager.cc
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
index 1e0a36a44e7b3f3f7758ac38bacdf2302d55e95a..e10a77d527f89ee7aeabe58d5919d63672eee753 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -283,6 +283,7 @@ void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
new ProcessMemoryDumpHolder(args, session_state_, callback));
ProcessMemoryDump* pmd = &pmd_holder->process_memory_dump;
bool did_any_provider_dump = false;
+ bool did_post_any_async_task = false;
// Iterate over the active dump providers and invoke OnMemoryDump(pmd).
// The MDM guarantees linearity (at most one MDP is active within one
@@ -314,8 +315,10 @@ void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
FROM_HERE, Bind(&MemoryDumpManager::ContinueAsyncProcessDump,
Unretained(this), Unretained(mdp), pmd_holder));
// The thread underlying the TaskRunner might have gone away.
- if (did_post_async_task)
+ if (did_post_async_task) {
++pmd_holder->num_pending_async_requests;
+ did_post_any_async_task = true;
+ }
} else {
// Invoke the dump provider synchronously.
did_any_provider_dump |= InvokeDumpProviderLocked(mdp, pmd);
@@ -326,7 +329,7 @@ void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
// If at least one synchronous provider did dump and there are no pending
// asynchronous requests, add the dump to the trace and invoke the callback
// straight away (FinalizeDumpAndAddToTrace() takes care of the callback).
- if (did_any_provider_dump && pmd_holder->num_pending_async_requests == 0)
+ if (did_any_provider_dump && !did_post_any_async_task)
FinalizeDumpAndAddToTrace(pmd_holder);
}
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698