summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-04-04 12:47:44 -0700
committerMark Salyzyn <salyzyn@google.com>2014-04-04 13:12:56 -0700
commit765f7828918b0eebe70ab9b16c31a2587969fc7e (patch)
treeb38b599aa082887f74307def405ad75e0d20177d /logd
parenta97798afc9105668a80b775516a7cc4db341a62e (diff)
downloadsystem_core-765f7828918b0eebe70ab9b16c31a2587969fc7e.zip
system_core-765f7828918b0eebe70ab9b16c31a2587969fc7e.tar.gz
system_core-765f7828918b0eebe70ab9b16c31a2587969fc7e.tar.bz2
logd: transitory reader thread create should be detached
Bug: 13692914 Change-Id: Ia7306e6e844ae9f17c6f594bf6b25f3148652570
Diffstat (limited to 'logd')
-rw-r--r--logd/LogTimes.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp
index 8cb015c..c32ac2d 100644
--- a/logd/LogTimes.cpp
+++ b/logd/LogTimes.cpp
@@ -46,14 +46,25 @@ LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client,
{ }
void LogTimeEntry::startReader_Locked(void) {
+ pthread_attr_t attr;
+
threadRunning = true;
- if (pthread_create(&mThread, NULL, LogTimeEntry::threadStart, this)) {
- threadRunning = false;
- if (mClient) {
- mClient->decRef();
+
+ if (!pthread_attr_init(&attr)) {
+ if (!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
+ if (!pthread_create(&mThread, &attr,
+ LogTimeEntry::threadStart, this)) {
+ pthread_attr_destroy(&attr);
+ return;
+ }
}
- decRef_Locked();
+ pthread_attr_destroy(&attr);
+ }
+ threadRunning = false;
+ if (mClient) {
+ mClient->decRef();
}
+ decRef_Locked();
}
void LogTimeEntry::threadStop(void *obj) {