diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-11-30 11:35:56 -0800 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2015-12-07 14:24:02 -0800 |
commit | b75cce0389748bea111ca62af623645117e12d9d (patch) | |
tree | ab909a5121db593408c82efe857c8c19e535ae64 /logd/FlushCommand.cpp | |
parent | 3ea02e8eca9fc0f2122d73a1d117292514256fcf (diff) | |
download | system_core-b75cce0389748bea111ca62af623645117e12d9d.tar.gz system_core-b75cce0389748bea111ca62af623645117e12d9d.tar.bz2 system_core-b75cce0389748bea111ca62af623645117e12d9d.zip |
logd: wakeup on wrap or timeout
If a timeout is specified for the reader, then go to sleep
with the socket open. If the start time is about to get
pruned in the specified log buffers, then wakeup and dump
the logs; or wakeup on timeout, whichever comes first.
Bug: 25929746
Change-Id: I7d2421c2c5083b33747b84f74d9a560d3ba645df
Diffstat (limited to 'logd/FlushCommand.cpp')
-rw-r--r-- | logd/FlushCommand.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/logd/FlushCommand.cpp b/logd/FlushCommand.cpp index 823a842fb..bf650cdaa 100644 --- a/logd/FlushCommand.cpp +++ b/logd/FlushCommand.cpp @@ -27,13 +27,15 @@ FlushCommand::FlushCommand(LogReader &reader, unsigned long tail, unsigned int logMask, pid_t pid, - uint64_t start) : + uint64_t start, + uint64_t timeout) : mReader(reader), mNonBlock(nonBlock), mTail(tail), mLogMask(logMask), mPid(pid), - mStart(start) { + mStart(start), + mTimeout(timeout) { } // runSocketCommand is called once for every open client on the @@ -54,6 +56,10 @@ void FlushCommand::runSocketCommand(SocketClient *client) { while(it != times.end()) { entry = (*it); if (entry->mClient == client) { + if (entry->mTimeout.tv_sec || entry->mTimeout.tv_nsec) { + LogTimeEntry::unlock(); + return; + } entry->triggerReader_Locked(); if (entry->runningReader_Locked()) { LogTimeEntry::unlock(); @@ -71,7 +77,8 @@ void FlushCommand::runSocketCommand(SocketClient *client) { LogTimeEntry::unlock(); return; } - entry = new LogTimeEntry(mReader, client, mNonBlock, mTail, mLogMask, mPid, mStart); + entry = new LogTimeEntry(mReader, client, mNonBlock, mTail, mLogMask, + mPid, mStart, mTimeout); times.push_front(entry); } |