e_input: fix not to use getenv() within an ecore thread 79/164479/1
authorSung-Jin Park <sj76.park@samsung.com>
Tue, 19 Dec 2017 08:25:15 +0000 (17:25 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 19 Dec 2017 08:25:15 +0000 (17:25 +0900)
Change-Id: Ia5c969b5ae6a067390208260c12ba002b75bb11f
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/bin/e_input_device.c
src/bin/e_input_private.h

index d0ca4f3..006b9f8 100644 (file)
@@ -713,20 +713,14 @@ _einput_device_input_thread_udev_backend_heavy(void *data, Ecore_Thread *th, voi
         return;
      }
 
-   /* set libinput log priority */
-   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
-   if ((env) && (atoi(env) == 1))
+   if (input->log_disable)
      libinput_log_set_handler(input->libinput, NULL);
    else
      {
-        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
-        if ((env) && (atoi(env) == 1))
-          libinput_log_set_handler(input->libinput,
-                                   e_input_device_libinput_log_handler);
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, e_input_device_libinput_log_handler);
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
      }
-   E_FREE(env);
-
-   libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
 
    TRACE_INPUT_BEGIN(libinput_udev_assign_seat);
    /* assign udev seat */
@@ -817,6 +811,22 @@ e_input_device_input_create_libinput_udev(E_Input_Device *dev)
    /* set reference for parent device */
    input->dev = dev;
 
+   input->log_disable = EINA_FALSE;
+   input->log_use_eina = EINA_FALSE;
+
+   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
+   if ((env) && (atoi(env) == 1))
+     input->log_disable = EINA_TRUE;
+   else
+     {
+        if (env) E_FREE(env);
+
+        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
+        if ((env) && (atoi(env) == 1))
+          input->log_use_eina = EINA_TRUE;
+     }
+   E_FREE(env);
+
    env = e_util_env_get("E_INPUT_USE_THREAD_INIT");
    if (env)
      {
@@ -847,22 +857,14 @@ e_input_device_input_create_libinput_udev(E_Input_Device *dev)
         goto err;
      }
 
-   /* set libinput log priority */
-   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
-   if ((env) && (atoi(env) == 1))
+   if (input->log_disable)
      libinput_log_set_handler(input->libinput, NULL);
    else
      {
-        E_FREE(env);
-
-        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
-        if ((env) && (atoi(env) == 1))
-          libinput_log_set_handler(input->libinput,
-                                   e_input_device_libinput_log_handler);
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, e_input_device_libinput_log_handler);
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
      }
-   E_FREE(env);
-
-   libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
 
    /* assign udev seat */
    TRACE_INPUT_BEGIN(libinput_udev_assign_seat);
@@ -930,6 +932,22 @@ e_input_device_input_create_libinput_path(E_Input_Device *dev)
    /* set reference for parent device */
    input->dev = dev;
 
+   input->log_disable = EINA_FALSE;
+   input->log_use_eina = EINA_FALSE;
+
+   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
+   if ((env) && (atoi(env) == 1))
+     input->log_disable = EINA_TRUE;
+   else
+     {
+        if (env) E_FREE(env);
+
+        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
+        if ((env) && (atoi(env) == 1))
+          input->log_use_eina = EINA_TRUE;
+     }
+   E_FREE(env);
+
    /* try to create libinput context */
    input->libinput =
      libinput_path_create_context(&_input_interface, input);
@@ -939,22 +957,14 @@ e_input_device_input_create_libinput_path(E_Input_Device *dev)
         goto err;
      }
 
-   /* set libinput log priority */
-   env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
-   if ((env) && (atoi(env) == 1))
+   if (input->log_disable)
      libinput_log_set_handler(input->libinput, NULL);
    else
      {
-        E_FREE(env);
-
-        env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
-        if ((env) && (atoi(env) == 1))
-          libinput_log_set_handler(input->libinput,
-                                   e_input_device_libinput_log_handler);
+        if (input->log_use_eina)
+          libinput_log_set_handler(input->libinput, e_input_device_libinput_log_handler);
+        libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
      }
-   E_FREE(env);
-
-   libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
 
    for (int i = 0; i < devices_num; i++)
      {
index dc125f7..e0d7976 100644 (file)
@@ -47,6 +47,9 @@ struct _E_Input_Backend
 
    Ecore_Thread *thread;
    Eina_Bool use_thread : 1;
+
+   Eina_Bool log_disable : 1;
+   Eina_Bool log_use_eina : 1;
 };
 
 struct _E_Input_Evdev