e_comp_wl_input: fix data race issue of kbd.enabled 84/324784/4 tizen_9.0
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 23 May 2025 11:47:23 +0000 (20:47 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 29 May 2025 04:31:47 +0000 (13:31 +0900)
e_comp_input_key->kbd.enabled variable is used in only main thread

Change-Id: I2ba66597123b77d2f271057b6f3003a089dc9721
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/e_comp_screen.c
src/bin/inputmgr/e_input_backend.c
src/bin/server/e_comp_wl_input.c

index 61e324cc1911503e37a4ec4348e525875b835e26..a3592502c4d71f4dfa542a6b2cc6b4b1b6e10de4 100644 (file)
@@ -172,11 +172,9 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
      }
    else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
      {
-        if (!e_input_thread_mode_get())
-          {
-             e_comp_input_key->kbd.num_devices++;
-             e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
-          }
+        e_comp_input_key->kbd.num_devices++;
+        if (e_comp_input_key->kbd.num_devices == 1)
+          e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
      }
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
@@ -248,6 +246,14 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
              _e_comp_screen_pointer_renew();
           }
      }
+   else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
+     {
+        e_comp_input_key->kbd.num_devices--;
+        if (e_comp_input_key->kbd.num_devices == 0)
+          {
+             e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
+          }
+     }
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         comp_wl->touch.num_devices--;
index acbafb2e2b1e2eff9cb9300cc312c6abb5af9194..a844df88a2ed1e185c7c410666824eed880f89f0 100644 (file)
@@ -378,15 +378,6 @@ _e_input_add_ecore_device(E_Input_Evdev *evdev, Ecore_Device_Class clas, Ecore_D
    e_device_class_set(e_dev, clas);
    e_device_subclass_set(e_dev, subclas);
 
-   if (e_input_thread_mode_get())
-     {
-        if (clas == ECORE_DEVICE_CLASS_KEYBOARD)
-          {
-             e_comp_input_key->kbd.num_devices++;
-             e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
-          }
-     }
-
    if (!evdev->e_dev)
      {
         if (!evdev->e_dev_list || (g_list_length(evdev->e_dev_list) == 0))
@@ -501,13 +492,6 @@ _e_input_remove_ecore_device(E_Input_Evdev *evdev, Ecore_Device_Class clas)
 
         if ((e_device_class_get(device) == clas) && (!strcmp(device_identifier, evdev->path)))
           {
-             if (clas == ECORE_DEVICE_CLASS_KEYBOARD)
-               {
-                  e_comp_input_key->kbd.num_devices--;
-                  if (e_comp_input_key->kbd.num_devices == 0)
-                    e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
-               }
-
              device_remove_log = eina_stringshare_printf("[Remove Device] device name(%s), identifier(%s), class(%s), subclass(%d)",
                                                          e_device_name_get(device),
                                                          device_identifier,
index 0203af410c7e2ad58d07dc4de1574bafbe06176b..83d1cdfaa05a3870f10f146f21619e49694e367c 100644 (file)
@@ -1995,17 +1995,6 @@ e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled)
    _e_comp_wl_input_update_seat_caps(comp_wl, NULL);
 }
 
-static void
-_e_comp_wl_input_thread_cb_keyboard_enabled_set(void *data)
-{
-   Eina_Bool enabled;
-   EINA_SAFETY_ON_NULL_RETURN(data);
-
-   enabled = *(Eina_Bool *)data;
-
-   e_comp_input_key->kbd.enabled = !!enabled;
-}
-
 EINTERN void
 e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
 {
@@ -2017,7 +2006,7 @@ e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
         return;
      }
 
-   e_input_backend_thread_safe_call(_e_comp_wl_input_thread_cb_keyboard_enabled_set, &enabled, sizeof(Eina_Bool));
+   e_comp_input_key->kbd.enabled = !!enabled;
    _e_comp_wl_input_update_seat_caps(comp_wl, NULL);
 }