power: make change state wait timeout configurable 63/269263/4
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 12 Jan 2022 07:01:04 +0000 (23:01 -0800)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 14 Jan 2022 01:42:56 +0000 (10:42 +0900)
Change-Id: I808f29e3518c643a295189accf919cd163f75e7e
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
conf/power.conf
plugins/iot-headless/power/power-state-manager.c
plugins/iot-headless/power/power-state-wait.c
plugins/iot-headless/power/power-state-wait.h

index 52abf4a..60a66cc 100644 (file)
@@ -7,3 +7,6 @@ Option=silent
 
 [Sleep]
 TimeoutSleepSupport=yes
+
+[PowerState]
+ChangeStateMaxWaitSecond=10
index cbc24d2..6f9bf09 100644 (file)
@@ -231,6 +231,7 @@ void power_state_manager_init(void *data)
 
        power_plugin_dbus_init(NULL);
        power_event_lock_init();
+       power_state_wait_init();
 
        /* initialize the power state */
        parse_initial_transition(&initial_ti);
index bdd7152..bfa430a 100644 (file)
 #include "power-state-wait.h"
 #include "power-state-manager.h"
 
+#define POWER_CONF_FILE    "/etc/deviced/power.conf"
 #define MAX_WAIT_SECOND    5 /* second */
 
+static int max_wait_timeout = 5; /* second */
+
 struct proc_info {
        pid_t pid;
        char comm[128];
@@ -213,7 +216,23 @@ int update_change_state_wait(guint64 id, const struct trans_info *ti, change_sta
        __change_state_wait_done = callback;
 
        _D("Expected number of wait confirm=%d", n_waiting);
-       max_wait_timer = g_timeout_add_seconds(MAX_WAIT_SECOND, max_wait_expired_cb, NULL);
+       max_wait_timer = g_timeout_add_seconds(max_wait_timeout, max_wait_expired_cb, NULL);
 
        return n_waiting;
 }
+
+static int load_max_wait_timeout(struct parse_result *result, void *user_data)
+{
+       if (MATCH(result->section, "PowerState")
+               && MATCH(result->name, "ChangeStateMaxWaitSecond"))
+               max_wait_timeout = atoi(result->value);
+
+       return 0;
+}
+
+void power_state_wait_init(void)
+{
+       config_parse(POWER_CONF_FILE, load_max_wait_timeout, NULL);
+
+       CRITICAL_LOG("Change state max wait timeout=%ds", max_wait_timeout);
+}
index 45544cd..622575f 100644 (file)
@@ -10,5 +10,6 @@ int add_change_state_wait(pid_t pid, guint64 state);
 void remove_change_state_wait(pid_t pid, guint64 state);
 int confirm_change_state_wait(pid_t pid, guint64 id);
 int update_change_state_wait(guint64 id, const struct trans_info *ti, change_state_wait_done_cb cb);
+void power_state_wait_init(void);
 
 #endif //__POWER_STATE_WAIT_H__