diff options
author | Paul Crowley <paulcrowley@google.com> | 2018-01-29 15:47:14 -0800 |
---|---|---|
committer | Paul Crowley <paulcrowley@google.com> | 2018-01-30 08:18:24 -0800 |
commit | e184423526888dade9c672ea2584127ae1d9d949 (patch) | |
tree | 69953a95622f7ac6e09d8a05978387109fa15958 /libcutils/trace-dev.cpp | |
parent | 01ba1157325a5e6572122f5d46cfd0376b75aa98 (diff) | |
download | system_core-e184423526888dade9c672ea2584127ae1d9d949.tar.gz system_core-e184423526888dade9c672ea2584127ae1d9d949.tar.bz2 system_core-e184423526888dade9c672ea2584127ae1d9d949.zip |
Don't initialize atrace if it's already disabled.
For processes that start very early, atrace initialization can cause
an selinux denial, so make sure it's possible to disable it and avoid
the call to open "trace_marker".
Bug: 63927601
Test: disable atrace early in vold, ensure that selinux denial is
avoided.
Change-Id: I2422e6d0db323bc13c6d6ed1896435151fca21f7
Diffstat (limited to 'libcutils/trace-dev.cpp')
-rw-r--r-- | libcutils/trace-dev.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libcutils/trace-dev.cpp b/libcutils/trace-dev.cpp index 4da821555..27255c2a2 100644 --- a/libcutils/trace-dev.cpp +++ b/libcutils/trace-dev.cpp @@ -25,6 +25,7 @@ static pthread_once_t atrace_once_control = PTHREAD_ONCE_INIT; void atrace_set_tracing_enabled(bool enabled) { atomic_store_explicit(&atrace_is_enabled, enabled, memory_order_release); + atomic_store_explicit(&atrace_is_ready, false, memory_order_release); atrace_update_tags(); } @@ -34,18 +35,17 @@ static void atrace_init_once() if (atrace_marker_fd == -1) { ALOGE("Error opening trace file: %s (%d)", strerror(errno), errno); atrace_enabled_tags = 0; - goto done; + return; } - atrace_enabled_tags = atrace_get_property(); - -done: - atomic_store_explicit(&atrace_is_ready, true, memory_order_release); } void atrace_setup() { - pthread_once(&atrace_once_control, atrace_init_once); + if (atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) { + pthread_once(&atrace_once_control, atrace_init_once); + } + atomic_store_explicit(&atrace_is_ready, true, memory_order_release); } void atrace_begin_body(const char* name) |