Make sure timer related functions are called in main thread 33/226033/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 26 Feb 2020 07:49:22 +0000 (16:49 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 26 Feb 2020 07:49:22 +0000 (16:49 +0900)
Change-Id: I3180942cf551a779140f25d3227430122e3a6f96

client/ma.c
client/ma_dbus.c

index 673d2828af81beba6843901149c0c27f588378ab..7df57703d9d1f5cfdbeb43ee5c00c5f6496b3da0 100644 (file)
@@ -388,9 +388,10 @@ static Ecore_Timer* g_retry_connection_timer = NULL;
 static int g_retry_connection_count = 0;
 static Eina_Bool retry_connection(void* data)
 {
+       MA_SLOGI("[ENTER]");
        int ret = ma_dbus_request_hello();
        if (ret == 0) {
-               MA_SLOGD("Success to request hello. retry count(%d)", g_retry_connection_count);
+               MA_SLOGI("Success to request hello. retry count(%d)", g_retry_connection_count);
                g_retry_connection_count = 0;
                if (g_retry_connection_timer) ecore_timer_del(g_retry_connection_timer);
                g_retry_connection_timer = NULL;
@@ -418,10 +419,26 @@ static Eina_Bool retry_connection(void* data)
        return ECORE_CALLBACK_RENEW;
 }
 
+static void delete_retry_connection_timer(void* data)
+{
+       if (g_retry_connection_timer) {
+               ecore_timer_del(g_retry_connection_timer);
+               g_retry_connection_timer = NULL;
+       }
+}
+
+static void add_retry_connection_timer(void* data)
+{
+       delete_retry_connection_timer(NULL);
+
+       g_retry_connection_timer = ecore_timer_add(1.5f, retry_connection, NULL);
+       MA_SLOGI("Added timer for retry_connection : %p", g_retry_connection_timer);
+}
+
 static void __start_prepare_func()
 {
        if (ECORE_CALLBACK_RENEW == retry_connection(NULL)) {
-               ecore_timer_add(1.5f, retry_connection, NULL);
+               ecore_main_loop_thread_safe_call_async(add_retry_connection_timer, NULL);
        }
 }
 
@@ -473,8 +490,8 @@ int ma_unprepare(void)
 
        MA_SLOGI("[Client DEBUG] Unprepare");
 
-       if (g_retry_connection_timer) ecore_timer_del(g_retry_connection_timer);
-       g_retry_connection_timer = NULL;
+       MA_SLOGD("Deleting timer for retry_connection");
+       ecore_main_loop_thread_safe_call_async(delete_retry_connection_timer, NULL);
 
        ma_state_e state;
 
index f7acf8fce761472f2697c4885983266be1d7a412..0111bb6f233492da8e5b76f707ff5b1747f04b13 100644 (file)
@@ -662,7 +662,7 @@ int ma_dbus_request_hello()
        result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, 1000, &err);
 
        if (dbus_error_is_set(&err)) {
-               MA_SLOGE("[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE
+               MA_SLOGE("[ERROR] Dbus Error (%s) %p", err.message, result_msg); //LCOV_EXCL_LINE
                dbus_error_free(&err);
        }