Merge "Fix deadlock from outside Perfetto mutex" into main
This commit is contained in:
commit
a0eabde1f7
1 changed files with 13 additions and 11 deletions
|
|
@ -149,18 +149,20 @@ void NetworkTracePoller::TraceIfaces(const std::vector<PacketTrace>& packets) {
|
|||
}
|
||||
|
||||
bool NetworkTracePoller::ConsumeAll() {
|
||||
std::scoped_lock<std::mutex> lock(mBufferMutex);
|
||||
if (mRingBuffer == nullptr) {
|
||||
ALOGW("Tracing is not active");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<PacketTrace> packets;
|
||||
base::Result<int> ret = mRingBuffer->ConsumeAll(
|
||||
[&](const PacketTrace& pkt) { packets.push_back(pkt); });
|
||||
if (!ret.ok()) {
|
||||
ALOGW("Failed to poll ringbuf: %s", ret.error().message().c_str());
|
||||
return false;
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(mBufferMutex);
|
||||
if (mRingBuffer == nullptr) {
|
||||
ALOGW("Tracing is not active");
|
||||
return false;
|
||||
}
|
||||
|
||||
base::Result<int> ret = mRingBuffer->ConsumeAll(
|
||||
[&](const PacketTrace& pkt) { packets.push_back(pkt); });
|
||||
if (!ret.ok()) {
|
||||
ALOGW("Failed to poll ringbuf: %s", ret.error().message().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ATRACE_INT("NetworkTracePackets", packets.size());
|
||||
|
|
|
|||
Loading…
Reference in a new issue