Test for IsPostFork() in RecordFree.
If we test only in FlushFreesLocked, it is possible that the parent
forked holding the free_batch_lock_, and we will stall the process for 1
second, waiting for the timed_mutex to time out.
Change-Id: I973878ac2dc368ee5f61eedb2b9d649fbecd5c95
diff --git a/src/profiling/memory/client.cc b/src/profiling/memory/client.cc
index 94d8cc5..ce5d561 100644
--- a/src/profiling/memory/client.cc
+++ b/src/profiling/memory/client.cc
@@ -390,6 +390,10 @@
}
bool Client::RecordFree(const uint64_t alloc_address) {
+ if (PERFETTO_UNLIKELY(IsPostFork())) {
+ return postfork_return_value_;
+ }
+
uint64_t sequence_number =
1 + sequence_number_.fetch_add(1, std::memory_order_acq_rel);
@@ -410,10 +414,6 @@
}
bool Client::FlushFreesLocked() {
- if (PERFETTO_UNLIKELY(IsPostFork())) {
- return postfork_return_value_;
- }
-
WireMessage msg = {};
msg.record_type = RecordType::Free;
msg.free_header = &free_batch_;