Extend time delay every 5 failures 47/287047/4
authorwn.jang <wn.jang@samsung.com>
Thu, 19 Jan 2023 06:04:15 +0000 (15:04 +0900)
committerwn.jang <wn.jang@samsung.com>
Thu, 19 Jan 2023 06:49:11 +0000 (15:49 +0900)
Cause:
In case of robot image, pkgmgr_client_new() function always returns fail.
So it cause a lot of error message and it makes a huge log file over 1GB.

Solution:
Time delay is extended every 5 failures.
This patch makes only 92 errors in 1 day, and only 110 error messages in 10 days.

Change-Id: Ibd5e5844a543adc6831d5ce76858254505dcba3d

client/tts_core.c

index 74fc095..3cf8791 100644 (file)
@@ -240,6 +240,8 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
        SLOG(LOG_INFO, TAG_TTSC, "[DEBUG] create pkgmgr thread");
 
        pthread_mutex_lock(&g_pkgmgr_mutex);
+       int time_delay = 10000;
+       int cnt = 0;
        while (NULL == g_pkgmgr) {
                /* Checking the thread is canceled or not */
                if (g_is_thread_canceled) {
@@ -255,7 +257,10 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
 
                g_pkgmgr = pkgmgr_client_new(PC_LISTENING);
                if (NULL == g_pkgmgr) {
-//                     SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create pkgmgr handle");
+                       if (0 == cnt % 5) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create pkgmgr handle");
+                               time_delay *= 2;
+                       }
                } else {
                        int ret = pkgmgr_client_set_status_type(g_pkgmgr, PKGMGR_CLIENT_STATUS_INSTALL | PKGMGR_CLIENT_STATUS_UNINSTALL | PKGMGR_CLIENT_STATUS_UPGRADE);
                        if (0 == ret) {
@@ -263,6 +268,8 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
                                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to listen pkgmgr status. remove and recreate client");
                                        pkgmgr_client_free(g_pkgmgr);
                                        g_pkgmgr = NULL;
+                                       if (0 == cnt % 5)
+                                               time_delay *= 2;
                                } else {
                                        SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Succeed to register pkgmgr cb");
                                        break;
@@ -271,10 +278,13 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
                                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set status type on pkgmgr, ret(%d)", ret);
                                pkgmgr_client_free(g_pkgmgr);
                                g_pkgmgr = NULL;
+                               if (0 == cnt % 5)
+                                       time_delay *= 2;
                        }
                }
 
-               usleep(10000);
+               usleep(time_delay);
+               cnt++;
        }
        pthread_mutex_unlock(&g_pkgmgr_mutex);