diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-04-04 12:47:44 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-04-04 13:12:56 -0700 |
commit | 765f7828918b0eebe70ab9b16c31a2587969fc7e (patch) | |
tree | b38b599aa082887f74307def405ad75e0d20177d /logd | |
parent | a97798afc9105668a80b775516a7cc4db341a62e (diff) | |
download | system_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.cpp | 21 |
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) { |