Merge changes from topic 'slow_log'
* changes: init: fix undefined behavior in ExecuteCommand Revert "Revert "init: warn slow action""
This commit is contained in:
commit
2369b1eb80
2 changed files with 12 additions and 7 deletions
|
|
@ -105,7 +105,10 @@ std::size_t Action::NumCommands() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::ExecuteOneCommand(std::size_t command) const {
|
void Action::ExecuteOneCommand(std::size_t command) const {
|
||||||
ExecuteCommand(commands_[command]);
|
// We need a copy here since some Command execution may result in
|
||||||
|
// changing commands_ vector by importing .rc files through parser
|
||||||
|
Command cmd = commands_[command];
|
||||||
|
ExecuteCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::ExecuteAllCommands() const {
|
void Action::ExecuteAllCommands() const {
|
||||||
|
|
@ -118,14 +121,16 @@ void Action::ExecuteCommand(const Command& command) const {
|
||||||
Timer t;
|
Timer t;
|
||||||
int result = command.InvokeFunc();
|
int result = command.InvokeFunc();
|
||||||
|
|
||||||
// TODO: this should probably be changed to "if (failed || took a long time)"...
|
double duration_ms = t.duration() * 1000;
|
||||||
if (android::base::GetMinimumLogSeverity() <= android::base::DEBUG) {
|
// Any action longer than 50ms will be warned to user as slow operation
|
||||||
|
if (duration_ms > 50.0 ||
|
||||||
|
android::base::GetMinimumLogSeverity() <= android::base::DEBUG) {
|
||||||
std::string trigger_name = BuildTriggersString();
|
std::string trigger_name = BuildTriggersString();
|
||||||
std::string cmd_str = command.BuildCommandString();
|
std::string cmd_str = command.BuildCommandString();
|
||||||
std::string source = command.BuildSourceString();
|
std::string source = command.BuildSourceString();
|
||||||
|
|
||||||
LOG(INFO) << "Command '" << cmd_str << "' action=" << trigger_name << source
|
LOG(INFO) << "Command '" << cmd_str << "' action=" << trigger_name << source
|
||||||
<< " returned " << result << " took " << t.duration() << "s";
|
<< " returned " << result << " took " << duration_ms << "ms.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -589,9 +589,9 @@ static int do_mount_all(const std::vector<std::string>& args) {
|
||||||
|
|
||||||
for (na = args.size() - 1; na > 1; --na) {
|
for (na = args.size() - 1; na > 1; --na) {
|
||||||
if (args[na] == "--early") {
|
if (args[na] == "--early") {
|
||||||
path_arg_end = na;
|
path_arg_end = na;
|
||||||
queue_event = false;
|
queue_event = false;
|
||||||
mount_mode = MOUNT_MODE_EARLY;
|
mount_mode = MOUNT_MODE_EARLY;
|
||||||
} else if (args[na] == "--late") {
|
} else if (args[na] == "--late") {
|
||||||
path_arg_end = na;
|
path_arg_end = na;
|
||||||
import_rc = false;
|
import_rc = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue