[ITC][device][Non-ACR][Fix unref timer twice] 22/217522/3
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 24 Oct 2019 08:32:19 +0000 (17:32 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Thu, 14 Nov 2019 07:12:10 +0000 (07:12 +0000)
For timer that returns false, glib automatically calls unref when timer expires.

Change-Id: Iadce6f99f7714661ec9687c6151f4a5b3e88658f
(cherry picked from commit 1348b24fb17bf6cff751ccc4c535d76dfb27419a)

src/itc/device/ITs-device.c

index 3cacf3737cadf7eefc4fd59deb9bac2d8dc6acbf..b7715cf1900a6e5dbb1955d7de20a850e2e78755 100755 (executable)
@@ -150,6 +150,9 @@ gboolean DeviceTimeout(gpointer data)
                g_main_loop_unref( g_pDeviceMainLoop );
                g_pDeviceMainLoop = NULL;
        }
+
+       nDeviceTimeoutId = 0;
+
        FPRINTF("[Line : %d][%s] Callback DeviceTimeout\\n", __LINE__, API_NAMESPACE);
        return false;
 }
@@ -262,8 +265,13 @@ int ITc_device_add_remove_callback_p(void)
                        g_pDeviceMainLoop = g_main_loop_new(NULL, false);
                        nDeviceTimeoutId = g_timeout_add(TIMEOUT_CB, DeviceTimeout, g_pDeviceMainLoop);
                        g_main_loop_run(g_pDeviceMainLoop);
-                       g_source_remove(nDeviceTimeoutId);
                        g_pDeviceMainLoop = NULL;
+                       if (nDeviceTimeoutId)
+                       {
+                               g_source_remove(nDeviceTimeoutId);
+                               nDeviceTimeoutId = 0;
+                       }
+
 
                        if ( g_bDeviceChangedCallback == false )
                        {
@@ -314,8 +322,12 @@ int ITc_device_add_remove_callback_p(void)
                        g_pDeviceMainLoop = g_main_loop_new(NULL, false);
                        nDeviceTimeoutId = g_timeout_add(TIMEOUT_CB, DeviceTimeout, g_pDeviceMainLoop);
                        g_main_loop_run(g_pDeviceMainLoop);
-                       g_source_remove(nDeviceTimeoutId);
                        g_pDeviceMainLoop = NULL;
+                       if (nDeviceTimeoutId)
+                       {
+                               g_source_remove(nDeviceTimeoutId);
+                               nDeviceTimeoutId = 0;
+                       }
 
                        if ( g_bDeviceChangedCallback == true )
                        {