#define sofia_profile_start_failure(p, xp) sofia_perform_profile_start_failure(p, xp, __FILE__, __LINE__)
-#define SQLLEN 1024 * 64
+#define SQLLEN 1024 * 32
void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread, void *obj)
{
sofia_profile_t *profile = (sofia_profile_t *) obj;
void *pop;
int loop_count = 0;
switch_size_t sql_len = SQLLEN;
- char *tmp, *sqlbuf = NULL;
+ char *sqlbuf = NULL;
+ char *sql = NULL;
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
sqlbuf = (char *) malloc(sql_len);
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
- if (qsize > 0 && (qsize >= 1024 || ++loop_count >= profile->trans_timeout)) {
+ if ((qsize > 0 && (qsize >= 1024 || ++loop_count >= profile->trans_timeout)) || sql) {
switch_size_t newlen;
uint32_t itterations = 0;
switch_size_t len = 0;
//sofia_glue_actually_execute_sql(profile, "begin;\n", NULL);
- while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
- char *sql = (char *) pop;
-
+ while (sql || (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop)) {
+
+ if (!sql) {
+ sql = (char *) pop;
+ }
+
newlen = strlen(sql) + 2;
-
- if (newlen + 10 < SQLLEN) {
- itterations++;
- if (len + newlen + 10 > sql_len) {
- sql_len = len + 10 + SQLLEN;
- if (!(tmp = realloc(sqlbuf, sql_len))) {
- abort();
- break;
- }
- sqlbuf = tmp;
- }
+ itterations++;
+
+ if (len + newlen + 10 < sql_len) {
sprintf(sqlbuf + len, "%s;\n", sql);
len += newlen;
+ switch_safe_free(sql);
+ } else {
+ break;
}
-
- free(pop);
}
-
+
//printf("TRANS:\n%s\n", sqlbuf);
sofia_glue_actually_execute_sql_trans(profile, sqlbuf, NULL);
//sofia_glue_actually_execute_sql(profile, "commit;\n", NULL);
goto done;
}
- profile->trans_timeout = 500;
+ profile->trans_timeout = 100;
profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833;// | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
nua_invite(tech_pvt->nh,
NUTAG_AUTOANSWER(0),
NUTAG_SESSION_TIMER(session_timeout),
+ TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
nua_invite(tech_pvt->nh,
NUTAG_AUTOANSWER(0),
NUTAG_SESSION_TIMER(session_timeout),
+ TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
}
}
- sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
+ sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
sofia_clear_flag(tech_pvt, TFLAG_TRACKED);
switch_safe_free(sql);