diff options
Diffstat (limited to 'logd/LogTimes.cpp')
-rw-r--r-- | logd/LogTimes.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp index 8cb015c..1a9a548 100644 --- a/logd/LogTimes.cpp +++ b/logd/LogTimes.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <sys/prctl.h> + #include "FlushCommand.h" #include "LogBuffer.h" #include "LogTimes.h" @@ -46,14 +48,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) { @@ -96,6 +109,8 @@ void LogTimeEntry::threadStop(void *obj) { } void *LogTimeEntry::threadStart(void *obj) { + prctl(PR_SET_NAME, "logd.reader.per"); + LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj); pthread_cleanup_push(threadStop, obj); |