display: Make dpms checking follow dpms_context iteration 77/313577/1
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 28 Jun 2024 04:34:23 +0000 (13:34 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 28 Jun 2024 04:53:36 +0000 (13:53 +0900)
Even dpms_client is available at the beginning of the wm_dpms_set_state(),
it could be finalized, before sending get/set request, by a pending event
that is going to destroy dpms_client. Therefore, it is more robust that
checking dpms after handling all pending requests.

The below crash happened:

Program terminated with signal SIGSEGV, Segmentation fault.
 #0  0x004aac62 in wm_dpms_set_state (on=3)
     at /usr/src/debug/deviced-10.0.0-1.arm/src/display/display-dpms.c:526
 526        tizen_dpms_manager_set_dpms(dpms_client->tz_dpms_mng,
                                dpms_client->wl_output, mode);
 [Current thread is 1 (LWP 478)]
 (gdb) p dpms_client
 $1 = (wl_glib_info *) 0x0

Change-Id: Ic0f191a64a46a1e834f85ce9d5d110804e4c2676
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/display/display-dpms.c

index 17749b6e7fd980d3b0c64ad8b1ddfc2b2706157b..ff5a2681cc563730bb279230c288a84e3f6bd86e 100644 (file)
@@ -507,15 +507,15 @@ static void wm_dpms_set_state(int on)
 {
        uint32_t mode;
 
+       // clear pending events
+       while (g_main_context_pending(dpms_context))
+               g_main_context_iteration(dpms_context, true);
+
        if (!dpms_is_available()) {
                _E("Dpms is not available.");
                return;
        }
 
-       // clear pending events
-       while (g_main_context_pending(dpms_context))
-               g_main_context_iteration(dpms_context, true);
-
        mode = (uint32_t)on;
 
        dpms_set_state_done = false;
@@ -538,15 +538,15 @@ static void wm_dpms_set_state(int on)
 
 static int wm_dpms_get_state(void)
 {
+       // clear pending events
+       while (dpms_context && g_main_context_pending(dpms_context))
+               g_main_context_iteration(dpms_context, true);
+
        if (!dpms_is_available()) {
                _E("Dpms is not available.");
                return -EINVAL;
        }
 
-       // clear pending events
-       while (g_main_context_pending(dpms_context))
-               g_main_context_iteration(dpms_context, true);
-
        dpms_get_state_done = false;
 
        // request for a dpms state to dpms server