summaryrefslogtreecommitdiff
path: root/libs/utils/Threads.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2013-03-07 15:34:28 -0800
committer Mathias Agopian <mathias@google.com> 2013-03-07 15:34:28 -0800
commite3e43b384e0603e5883b501cdb169641fab8fea2 (patch)
tree150f4954e60200f4918ba7c065f0b28df0c4093f /libs/utils/Threads.cpp
parent649b976a00c1295e4c1bd2f8c317376f31e9858a (diff)
rename binder services main thread to Binder_*
When a binder service's main thread joins the thread pool it retains its name (whatever the exec name was), which is very confusing in systrace. we now rename that thread just like its friends in the thread pool. Change-Id: Ibb3b6ff07304b247cfc6fb1694e72350c579513e
Diffstat (limited to 'libs/utils/Threads.cpp')
-rw-r--r--libs/utils/Threads.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index a25a81fbeb..eb964978e4 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -109,30 +109,34 @@ struct thread_data_t {
}
if (name) {
-#if defined(HAVE_PRCTL)
- // Mac OS doesn't have this, and we build libutil for the host too
- int hasAt = 0;
- int hasDot = 0;
- char *s = name;
- while (*s) {
- if (*s == '.') hasDot = 1;
- else if (*s == '@') hasAt = 1;
- s++;
- }
- int len = s - name;
- if (len < 15 || hasAt || !hasDot) {
- s = name;
- } else {
- s = name + len - 15;
- }
- prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0);
-#endif
+ androidSetThreadName(name);
free(name);
}
return f(u);
}
};
+void androidSetThreadName(const char* name) {
+#if defined(HAVE_PRCTL)
+ // Mac OS doesn't have this, and we build libutil for the host too
+ int hasAt = 0;
+ int hasDot = 0;
+ const char *s = name;
+ while (*s) {
+ if (*s == '.') hasDot = 1;
+ else if (*s == '@') hasAt = 1;
+ s++;
+ }
+ int len = s - name;
+ if (len < 15 || hasAt || !hasDot) {
+ s = name;
+ } else {
+ s = name + len - 15;
+ }
+ prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0);
+#endif
+}
+
int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
void *userData,
const char* threadName,