From 3330d1208fc7cc43f133acd55e7e78aadfd64375 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Tue, 4 Sep 2018 11:12:04 -0700 Subject: statsd: fix double close. Previously, fdopen was being called on a file descriptor that was owned by a unique_fd without releasing. This leads to a double close, since both fclose and the unique_fd destructor will try to close the fd. Bug: http://b/113880863 Test: treehugger Change-Id: I6f6f48d304861b5e4d7efee0d3ad0e30178a95a4 --- cmds/statsd/src/external/Perfetto.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmds/statsd/src/external/Perfetto.cpp b/cmds/statsd/src/external/Perfetto.cpp index 05544837b752..c1f9a643e153 100644 --- a/cmds/statsd/src/external/Perfetto.cpp +++ b/cmds/statsd/src/external/Perfetto.cpp @@ -105,9 +105,9 @@ bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config, readPipe.reset(); // Close the read end (owned by the child process). - // Using fopen() because fwrite() has the right logic to chunking write() + // Using fdopen() because fwrite() has the right logic to chunking write() // over a pipe (see __sfvwrite()). - FILE* writePipeStream = fdopen(writePipe.get(), "wb"); + FILE* writePipeStream = android::base::Fdopen(std::move(writePipe), "wb"); if (!writePipeStream) { ALOGE("fdopen() failed while calling the Perfetto client: %s", strerror(errno)); return false; -- cgit v1.2.3-59-g8ed1b