Modify startup timer 16/300616/2
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 30 Oct 2023 03:44:41 +0000 (12:44 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 30 Oct 2023 04:09:29 +0000 (13:09 +0900)
The interval of the startup timer is changed to 10 seconds.
And, a member variable called delay_count_ is added to check if
the number of times has exceeded 6.
If the count is less than 6, amd prints the error log for debugging.

Change-Id: Iddca7dd9799339345fcf36e8e866207ce78129ba
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/app_status/app_status.cc
src/lib/app_status/app_status.hh
src/lib/app_status/app_status_manager.cc
src/lib/app_status/app_status_manager.hh

index 109b6dd..7e10218 100644 (file)
@@ -36,7 +36,7 @@ namespace amd {
 namespace {
 
 constexpr int DYING_TIMEOUT = 5;
-constexpr int STARTUP_TIMEOUT = 30;
+constexpr int STARTUP_TIMEOUT = 10;
 
 typedef enum {
   AT_SERVICE_APP,
@@ -209,9 +209,12 @@ void AppStatus::SetStartupTimer() {
   startup_timer_ = g_timeout_add_seconds(STARTUP_TIMEOUT,
       +[](gpointer data) -> gboolean {
     auto* app_status = static_cast<AppStatus*>(data);
-    app_status->startup_timer_ = 0;
-    app_status->event_listener_->OnStartupTimeout(app_status);
-    return G_SOURCE_REMOVE;
+    if (!app_status->event_listener_->OnStartupTimeout(app_status)) {
+      app_status->startup_timer_ = 0;
+      return G_SOURCE_REMOVE;
+    }
+
+    return G_SOURCE_CONTINUE;
   }, this);
 
   if (startup_timer_ == 0) {
@@ -300,6 +303,14 @@ void AppStatus::IncreaseFgCount() {
   ++fg_count_;
 }
 
+int AppStatus::GetDelayCount() const {
+  return delay_count_;
+}
+
+void AppStatus::IncreaseDelayCount() {
+  ++delay_count_;
+}
+
 bool AppStatus::IsManaged() const {
   return app_info_->GetTaskmanage() == "true";
 }
index 735fe5f..b2dcaf2 100644 (file)
@@ -42,7 +42,7 @@ class AppStatus : public std::enable_shared_from_this<AppStatus> {
   class IEvent {
    public:
     virtual void OnDyingTimeout(AppStatus* data) = 0;
-    virtual void OnStartupTimeout(AppStatus* data) = 0;
+    virtual bool OnStartupTimeout(AppStatus* data) = 0;
     virtual ~IEvent() = default;
   };
 
@@ -107,6 +107,8 @@ class AppStatus : public std::enable_shared_from_this<AppStatus> {
   void SetTimeStamp(int timestamp);
   int GetFgCount() const;
   void IncreaseFgCount();
+  int GetDelayCount() const;
+  void IncreaseDelayCount();
 
   bool IsSubapp() const;
   bool IsManaged() const;
@@ -163,6 +165,7 @@ class AppStatus : public std::enable_shared_from_this<AppStatus> {
   bool exiting_ = false;
   std::unordered_map<std::string, void*> extras_;
   int64_t start_time_;  /* start timestamp millisecond */
+  int delay_count_ = 0;
 };
 
 }  // namespace amd
index b219e68..3ae9798 100644 (file)
@@ -174,9 +174,17 @@ void AppStatusManager::OnDyingTimeout(AppStatus* app_status) {
   _request_flush_pending_request(app_status->GetPID());
 }
 
-void AppStatusManager::OnStartupTimeout(AppStatus* app_status) {
+bool AppStatusManager::OnStartupTimeout(AppStatus* app_status) {
   if (app_status == nullptr)
-    return;
+    return false;
+
+  app_status->IncreaseDelayCount();
+  if (app_status->GetDelayCount() < 6) {
+    _E("App(%s[%d]) hasn't run main loop yet. delay_count(%d)",
+        app_status->GetAppID().c_str(), app_status->GetPID(),
+        app_status->GetDelayCount());
+    return true;
+  }
 
   _E("App startup signal has not been received. pid(%d)", app_status->GetPID());
   /*
@@ -187,6 +195,7 @@ void AppStatusManager::OnStartupTimeout(AppStatus* app_status) {
   */
   amd::AppStatusManager::GetInst().Update(app_status->shared_from_this(),
       STATUS_DYING, false, true);
+  return false;
 }
 
 AppStatusManager& AppStatusManager::GetInst() {
index cbf6b23..deb126d 100644 (file)
@@ -91,7 +91,7 @@ class AppStatusManager : public AppStatus::IEvent {
   int Finish();
 
   void OnDyingTimeout(AppStatus* app) override;
-  void OnStartupTimeout(AppStatus* app) override;
+  bool OnStartupTimeout(AppStatus* app) override;
 
  private:
   AppStatusManager() = default;