]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
try harder to get db handle in sql thread and fail out if it can't get one
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 22 Apr 2010 18:28:44 +0000 (13:28 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 22 Apr 2010 18:28:44 +0000 (13:28 -0500)
src/switch_core_sqldb.c

index 530d7008737b5b71a781becb26e43737484867b9..9e02a91c8e576bb07e6f3594f2381b203e54bea8 100644 (file)
@@ -809,6 +809,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
        int lc = 0;
        uint32_t loops = 0, sec = 0;
        uint32_t l1 = 1000;
+       uint32_t sanity = 120;
 
        switch_assert(sqlbuf);
 
@@ -816,10 +817,19 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
                l1 = 10;
        }
 
+       while (!sql_manager.event_db) {
+               if (switch_core_db_handle(&sql_manager.event_db) == SWITCH_STATUS_SUCCESS && sql_manager.event_db) break;
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error getting core db, Retrying\n");
+               switch_yield(500000);
+               sanity--;
+       }
+
        if (!sql_manager.event_db) {
-               switch_core_db_handle(&sql_manager.event_db);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error getting core db Disabling core sql functionality\n");
+               return NULL;
        }
 
+
        sql_manager.thread_running = 1;
 
        while (sql_manager.thread_running == 1) {