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
This commit is contained in:
parent
01ba115732
commit
e184423526
1 changed files with 6 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue