summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/dumpstate.cpp
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2017-08-29 15:36:28 +0000
committer android-build-merger <android-build-merger@google.com> 2017-08-29 15:36:28 +0000
commitdfd4ea3d9b0c62d30ec8bfb1099a4c169337ef38 (patch)
tree3083f0697bd3391b4f3d025fca5e3bae327d9fb5 /cmds/dumpstate/dumpstate.cpp
parentf7f90ec7e2588b42c42c7f067ce501055377e016 (diff)
parent4d8a26a9e6fc5152c549ee98cdba7b3bf94cf4cb (diff)
Merge "Dumpstate: Add tombstone filtering" into oc-mr1-dev
am: 4d8a26a9e6 Change-Id: I2378d352d1b545eaab8c27698d934b5fcf50829e
Diffstat (limited to 'cmds/dumpstate/dumpstate.cpp')
-rw-r--r--cmds/dumpstate/dumpstate.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 9e77e8fbcb..b3d628cac5 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -144,10 +144,12 @@ static const CommandOptions AS_ROOT_20 = CommandOptions::WithTimeout(20).AsRoot(
* Returns a vector of dump fds under |dir_path| with a given |file_prefix|.
* The returned vector is sorted by the mtimes of the dumps. If |limit_by_mtime|
* is set, the vector only contains files that were written in the last 30 minutes.
+ * If |limit_by_count| is set, the vector only contains the ten latest files.
*/
static std::vector<DumpData>* GetDumpFds(const std::string& dir_path,
const std::string& file_prefix,
- bool limit_by_mtime) {
+ bool limit_by_mtime,
+ bool limit_by_count = true) {
const time_t thirty_minutes_ago = ds.now_ - 60 * 30;
std::unique_ptr<std::vector<DumpData>> dump_data(new std::vector<DumpData>());
@@ -190,6 +192,10 @@ static std::vector<DumpData>* GetDumpFds(const std::string& dir_path,
std::sort(dump_data->begin(), dump_data->end());
+ if (limit_by_count && dump_data->size() > 10) {
+ dump_data->erase(dump_data->begin() + 10, dump_data->end());
+ }
+
return dump_data.release();
}