summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2018-04-25 22:32:36 -0700
committerAndreas Gampe <agampe@google.com>2018-05-03 13:33:17 -0700
commit57f73c361b50bfcc93d2872af068b1ac3982b79e (patch)
treeac5f0877c9e78b71cc7ffd51af0c2a40c3ae8f51
parent9ecd8d334edcd05bc2f18842f167e02936c2487d (diff)
downloadextras-57f73c361b50bfcc93d2872af068b1ac3982b79e.tar.gz
Perfprofd: Add ScopeGuard for file deletion
Ensure that the temporary will be deleted. (cherry picked from commit 529af96ba77f26c1597d077ca55d051feeb5df3d) Bug: 73175642 Test: perfprofd_test Merged-In: I4e15cd4fa81a173a70126edaea5c0a0023b8c359 Change-Id: I4e15cd4fa81a173a70126edaea5c0a0023b8c359
-rw-r--r--perfprofd/perfprofdcore.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/perfprofd/perfprofdcore.cc b/perfprofd/perfprofdcore.cc
index 065f8e67..c5605ac7 100644
--- a/perfprofd/perfprofdcore.cc
+++ b/perfprofd/perfprofdcore.cc
@@ -36,6 +36,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
+#include <android-base/scopeguard.h>
#include <android-base/stringprintf.h>
#ifdef __BIONIC__
@@ -650,6 +651,9 @@ static ProtoUniquePtr collect_profile(Config& config)
bool take_action = (hardwire && duration <= max_duration);
HardwireCpuHelper helper(take_action);
+ auto scope_guard = android::base::make_scope_guard(
+ [&data_file_path]() { unlink(data_file_path.c_str()); });
+
//
// Invoke perf
//