From: Anthony Minessale Date: Thu, 22 Apr 2010 18:28:44 +0000 (-0500) Subject: try harder to get db handle in sql thread and fail out if it can't get one X-Git-Tag: git2svn-syncpoint-master~169^2~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=631f5407448ad0c78bcc5c6e06736764ec763c02;p=thirdparty%2Ffreeswitch.git try harder to get db handle in sql thread and fail out if it can't get one --- diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 530d700873..9e02a91c8e 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -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) {