add-on to earlier change to this file
This commit is contained in:
parent
fdc31908fa
commit
3501087b4d
|
@ -915,9 +915,9 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
|
||||||
char *tmp, *sqlbuf = (char *) malloc(sql_len);
|
char *tmp, *sqlbuf = (char *) malloc(sql_len);
|
||||||
char *sql = NULL, *save_sql = NULL;
|
char *sql = NULL, *save_sql = NULL;
|
||||||
switch_size_t newlen;
|
switch_size_t newlen;
|
||||||
int lc = 0;
|
int lc = 0, wrote = 0, do_sleep = 1;
|
||||||
uint32_t sanity = 120;
|
uint32_t sanity = 120;
|
||||||
|
|
||||||
switch_assert(sqlbuf);
|
switch_assert(sqlbuf);
|
||||||
|
|
||||||
while (!sql_manager.event_db) {
|
while (!sql_manager.event_db) {
|
||||||
|
@ -978,6 +978,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
|
||||||
#endif
|
#endif
|
||||||
save_sql = sql;
|
save_sql = sql;
|
||||||
sql = NULL;
|
sql = NULL;
|
||||||
|
lc = 0;
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -993,10 +994,12 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lc = switch_queue_size(sql_manager.sql_queue[0]) + switch_queue_size(sql_manager.sql_queue[1]);
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
|
|
||||||
lc = switch_queue_size(sql_manager.sql_queue[0]) + switch_queue_size(sql_manager.sql_queue[1]);
|
wrote = 0;
|
||||||
|
|
||||||
if (trans && iterations && (iterations > target || !lc)) {
|
if (trans && iterations && (iterations > target || !lc)) {
|
||||||
#ifdef DEBUG_SQL
|
#ifdef DEBUG_SQL
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||||
|
@ -1013,14 +1016,25 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
|
||||||
len = 0;
|
len = 0;
|
||||||
*sqlbuf = '\0';
|
*sqlbuf = '\0';
|
||||||
lc = 0;
|
lc = 0;
|
||||||
switch_yield(400000);
|
if (do_sleep) {
|
||||||
|
switch_yield(200000);
|
||||||
|
}
|
||||||
|
wrote = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
lc = sql ? 1 : 0 + switch_queue_size(sql_manager.sql_queue[0]) + switch_queue_size(sql_manager.sql_queue[1]);
|
lc = switch_queue_size(sql_manager.sql_queue[0]) + switch_queue_size(sql_manager.sql_queue[1]);
|
||||||
|
|
||||||
if (!lc) {
|
if (!lc) {
|
||||||
switch_thread_cond_wait(sql_manager.cond, sql_manager.cond_mutex);
|
switch_thread_cond_wait(sql_manager.cond, sql_manager.cond_mutex);
|
||||||
|
} else if (wrote) {
|
||||||
|
if (lc > 2000) {
|
||||||
|
do_sleep = 0;
|
||||||
|
} else {
|
||||||
|
do_sleep = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_unlock(sql_manager.cond_mutex);
|
switch_mutex_unlock(sql_manager.cond_mutex);
|
||||||
|
|
Loading…
Reference in New Issue