summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-03-10 16:31:54 -0600
committerMark Salyzyn2017-03-13 12:31:09 -0500
commit501c373916e292764400dbae735f44b33378400f (patch)
tree56946d23a00461d2a462658f36689faa1d9d71a3 /logd/LogTimes.cpp
parent488525b47ba23b2548f3bf6aa2f4ce6267b2d9b5 (diff)
downloadplatform-system-core-501c373916e292764400dbae735f44b33378400f.tar.gz
platform-system-core-501c373916e292764400dbae735f44b33378400f.tar.xz
platform-system-core-501c373916e292764400dbae735f44b33378400f.zip
logd: specify clang format
Switch _all_ file's coding style to match to ease all future changes. SideEffects: None Test: compile Bug: 35373582 Change-Id: I470cb17f64fa48f14aafc02f574e296bffe3a3f3
Diffstat (limited to 'logd/LogTimes.cpp')
-rw-r--r--logd/LogTimes.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp
index 2a04880e4..bdaeb751c 100644
--- a/logd/LogTimes.cpp
+++ b/logd/LogTimes.cpp
@@ -19,30 +19,30 @@
19 19
20#include "FlushCommand.h" 20#include "FlushCommand.h"
21#include "LogBuffer.h" 21#include "LogBuffer.h"
22#include "LogTimes.h"
23#include "LogReader.h" 22#include "LogReader.h"
23#include "LogTimes.h"
24 24
25pthread_mutex_t LogTimeEntry::timesLock = PTHREAD_MUTEX_INITIALIZER; 25pthread_mutex_t LogTimeEntry::timesLock = PTHREAD_MUTEX_INITIALIZER;
26 26
27LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client, 27LogTimeEntry::LogTimeEntry(LogReader& reader, SocketClient* client,
28 bool nonBlock, unsigned long tail, 28 bool nonBlock, unsigned long tail,
29 unsigned int logMask, pid_t pid, 29 unsigned int logMask, pid_t pid, uint64_t start,
30 uint64_t start, uint64_t timeout) : 30 uint64_t timeout)
31 mRefCount(1), 31 : mRefCount(1),
32 mRelease(false), 32 mRelease(false),
33 mError(false), 33 mError(false),
34 threadRunning(false), 34 threadRunning(false),
35 leadingDropped(false), 35 leadingDropped(false),
36 mReader(reader), 36 mReader(reader),
37 mLogMask(logMask), 37 mLogMask(logMask),
38 mPid(pid), 38 mPid(pid),
39 mCount(0), 39 mCount(0),
40 mTail(tail), 40 mTail(tail),
41 mIndex(0), 41 mIndex(0),
42 mClient(client), 42 mClient(client),
43 mStart(start), 43 mStart(start),
44 mNonBlock(nonBlock), 44 mNonBlock(nonBlock),
45 mEnd(LogBufferElement::getCurrentSequence()) { 45 mEnd(LogBufferElement::getCurrentSequence()) {
46 mTimeout.tv_sec = timeout / NS_PER_SEC; 46 mTimeout.tv_sec = timeout / NS_PER_SEC;
47 mTimeout.tv_nsec = timeout % NS_PER_SEC; 47 mTimeout.tv_nsec = timeout % NS_PER_SEC;
48 pthread_cond_init(&threadTriggeredCondition, NULL); 48 pthread_cond_init(&threadTriggeredCondition, NULL);
@@ -56,8 +56,8 @@ void LogTimeEntry::startReader_Locked(void) {
56 56
57 if (!pthread_attr_init(&attr)) { 57 if (!pthread_attr_init(&attr)) {
58 if (!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) { 58 if (!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
59 if (!pthread_create(&mThread, &attr, 59 if (!pthread_create(&mThread, &attr, LogTimeEntry::threadStart,
60 LogTimeEntry::threadStart, this)) { 60 this)) {
61 pthread_attr_destroy(&attr); 61 pthread_attr_destroy(&attr);
62 return; 62 return;
63 } 63 }
@@ -71,8 +71,8 @@ void LogTimeEntry::startReader_Locked(void) {
71 decRef_Locked(); 71 decRef_Locked();
72} 72}
73 73
74void LogTimeEntry::threadStop(void *obj) { 74void LogTimeEntry::threadStop(void* obj) {
75 LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj); 75 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
76 76
77 lock(); 77 lock();
78 78
@@ -80,14 +80,14 @@ void LogTimeEntry::threadStop(void *obj) {
80 me->error_Locked(); 80 me->error_Locked();
81 } 81 }
82 82
83 SocketClient *client = me->mClient; 83 SocketClient* client = me->mClient;
84 84
85 if (me->isError_Locked()) { 85 if (me->isError_Locked()) {
86 LogReader &reader = me->mReader; 86 LogReader& reader = me->mReader;
87 LastLogTimes &times = reader.logbuf().mTimes; 87 LastLogTimes& times = reader.logbuf().mTimes;
88 88
89 LastLogTimes::iterator it = times.begin(); 89 LastLogTimes::iterator it = times.begin();
90 while(it != times.end()) { 90 while (it != times.end()) {
91 if (*it == me) { 91 if (*it == me) {
92 times.erase(it); 92 times.erase(it);
93 me->release_nodelete_Locked(); 93 me->release_nodelete_Locked();
@@ -110,20 +110,20 @@ void LogTimeEntry::threadStop(void *obj) {
110 unlock(); 110 unlock();
111} 111}
112 112
113void *LogTimeEntry::threadStart(void *obj) { 113void* LogTimeEntry::threadStart(void* obj) {
114 prctl(PR_SET_NAME, "logd.reader.per"); 114 prctl(PR_SET_NAME, "logd.reader.per");
115 115
116 LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj); 116 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
117 117
118 pthread_cleanup_push(threadStop, obj); 118 pthread_cleanup_push(threadStop, obj);
119 119
120 SocketClient *client = me->mClient; 120 SocketClient* client = me->mClient;
121 if (!client) { 121 if (!client) {
122 me->error(); 122 me->error();
123 return NULL; 123 return NULL;
124 } 124 }
125 125
126 LogBuffer &logbuf = me->mReader.logbuf(); 126 LogBuffer& logbuf = me->mReader.logbuf();
127 127
128 bool privileged = FlushCommand::hasReadLogs(client); 128 bool privileged = FlushCommand::hasReadLogs(client);
129 bool security = FlushCommand::hasSecurityLogs(client); 129 bool security = FlushCommand::hasSecurityLogs(client);
@@ -135,11 +135,9 @@ void *LogTimeEntry::threadStart(void *obj) {
135 uint64_t start = me->mStart; 135 uint64_t start = me->mStart;
136 136
137 while (me->threadRunning && !me->isError_Locked()) { 137 while (me->threadRunning && !me->isError_Locked()) {
138
139 if (me->mTimeout.tv_sec || me->mTimeout.tv_nsec) { 138 if (me->mTimeout.tv_sec || me->mTimeout.tv_nsec) {
140 if (pthread_cond_timedwait(&me->threadTriggeredCondition, 139 if (pthread_cond_timedwait(&me->threadTriggeredCondition,
141 &timesLock, 140 &timesLock, &me->mTimeout) == ETIMEDOUT) {
142 &me->mTimeout) == ETIMEDOUT) {
143 me->mTimeout.tv_sec = 0; 141 me->mTimeout.tv_sec = 0;
144 me->mTimeout.tv_nsec = 0; 142 me->mTimeout.tv_nsec = 0;
145 } 143 }
@@ -151,10 +149,12 @@ void *LogTimeEntry::threadStart(void *obj) {
151 unlock(); 149 unlock();
152 150
153 if (me->mTail) { 151 if (me->mTail) {
154 logbuf.flushTo(client, start, privileged, security, FilterFirstPass, me); 152 logbuf.flushTo(client, start, privileged, security, FilterFirstPass,
153 me);
155 me->leadingDropped = true; 154 me->leadingDropped = true;
156 } 155 }
157 start = logbuf.flushTo(client, start, privileged, security, FilterSecondPass, me); 156 start = logbuf.flushTo(client, start, privileged, security,
157 FilterSecondPass, me);
158 158
159 lock(); 159 lock();
160 160
@@ -184,8 +184,8 @@ void *LogTimeEntry::threadStart(void *obj) {
184} 184}
185 185
186// A first pass to count the number of elements 186// A first pass to count the number of elements
187int LogTimeEntry::FilterFirstPass(const LogBufferElement *element, void *obj) { 187int LogTimeEntry::FilterFirstPass(const LogBufferElement* element, void* obj) {
188 LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj); 188 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
189 189
190 LogTimeEntry::lock(); 190 LogTimeEntry::lock();
191 191
@@ -201,8 +201,8 @@ int LogTimeEntry::FilterFirstPass(const LogBufferElement *element, void *obj) {
201 me->mStart = element->getSequence(); 201 me->mStart = element->getSequence();
202 } 202 }
203 203
204 if ((!me->mPid || (me->mPid == element->getPid())) 204 if ((!me->mPid || (me->mPid == element->getPid())) &&
205 && (me->isWatching(element->getLogId()))) { 205 (me->isWatching(element->getLogId()))) {
206 ++me->mCount; 206 ++me->mCount;
207 } 207 }
208 208
@@ -212,8 +212,8 @@ int LogTimeEntry::FilterFirstPass(const LogBufferElement *element, void *obj) {
212} 212}
213 213
214// A second pass to send the selected elements 214// A second pass to send the selected elements
215int LogTimeEntry::FilterSecondPass(const LogBufferElement *element, void *obj) { 215int LogTimeEntry::FilterSecondPass(const LogBufferElement* element, void* obj) {
216 LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj); 216 LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
217 217
218 LogTimeEntry::lock(); 218 LogTimeEntry::lock();
219 219
@@ -267,7 +267,7 @@ ok:
267 LogTimeEntry::unlock(); 267 LogTimeEntry::unlock();
268 return true; 268 return true;
269 } 269 }
270 // FALLTHRU 270// FALLTHRU
271 271
272skip: 272skip:
273 LogTimeEntry::unlock(); 273 LogTimeEntry::unlock();
@@ -279,7 +279,7 @@ stop:
279} 279}
280 280
281void LogTimeEntry::cleanSkip_Locked(void) { 281void LogTimeEntry::cleanSkip_Locked(void) {
282 for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t) (i + 1)) { 282 for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t)(i + 1)) {
283 skipAhead[i] = 0; 283 skipAhead[i] = 0;
284 } 284 }
285} 285}