Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e578fd57 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "init: even better logging around subsequent sys.powerctl messages"

parents 4e78aa8f 080fa988
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -235,15 +235,6 @@ static class ShutdownState {
        // action queue.  Instead we set this flag and ensure that shutdown happens before the next
        // command is run in the main init loop.
        auto lock = std::lock_guard{shutdown_command_lock_};
        if (do_shutdown_) {
            LOG(ERROR) << "TriggerShutdown called while a previous shutdown command '"
                       << shutdown_command_ << "' has not been handled";
            UnwindMainThreadStack();
        }
        if (IsShuttingDown()) {
            LOG(ERROR) << "TriggerShutdown called while init is already shutting down";
            UnwindMainThreadStack();
        }
        shutdown_command_ = command;
        do_shutdown_ = true;
        WakeMainInitThread();
@@ -258,12 +249,27 @@ static class ShutdownState {
        return {};
    }

    bool do_shutdown() const { return do_shutdown_; }

  private:
    std::mutex shutdown_command_lock_;
    std::string shutdown_command_;
    bool do_shutdown_ = false;
} shutdown_state;

void DebugRebootLogging() {
    LOG(INFO) << "do_shutdown: " << shutdown_state.do_shutdown()
              << " IsShuttingDown: " << IsShuttingDown();
    if (shutdown_state.do_shutdown()) {
        LOG(ERROR) << "sys.powerctl set while a previous shutdown command has not been handled";
        UnwindMainThreadStack();
    }
    if (IsShuttingDown()) {
        LOG(ERROR) << "sys.powerctl set while init is already shutting down";
        UnwindMainThreadStack();
    }
}

void DumpState() {
    ServiceList::GetInstance().DumpState();
    ActionManager::GetInstance().DumpState();
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ void SendLoadPersistentPropertiesMessage();
void PropertyChanged(const std::string& name, const std::string& value);
bool QueueControlMessage(const std::string& message, const std::string& name, pid_t pid, int fd);

void DebugRebootLogging();

int SecondStageMain(int argc, char** argv);

}  // namespace init
+1 −0
Original line number Diff line number Diff line
@@ -489,6 +489,7 @@ uint32_t HandlePropertySet(const std::string& name, const std::string& value,
        }
        LOG(INFO) << "Received sys.powerctl='" << value << "' from pid: " << cr.pid
                  << process_log_string;
        DebugRebootLogging();
    }

    // If a process other than init is writing a non-empty value, it means that process is