fix some sql order issues
This commit is contained in:
parent
6c2baed108
commit
43b094f139
|
@ -1015,6 +1015,7 @@ void sofia_glue_execute_sql(sofia_profile_t *profile, char **sqlp, switch_bool_t
|
|||
void sofia_glue_actually_execute_sql(sofia_profile_t *profile, char *sql, switch_mutex_t *mutex);
|
||||
void sofia_glue_actually_execute_sql_trans(sofia_profile_t *profile, char *sql, switch_mutex_t *mutex);
|
||||
void sofia_glue_execute_sql_now(sofia_profile_t *profile, char **sqlp, switch_bool_t sql_already_dynamic);
|
||||
void sofia_glue_execute_sql_soon(sofia_profile_t *profile, char **sqlp, switch_bool_t sql_already_dynamic);
|
||||
void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot);
|
||||
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
|
||||
void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now);
|
||||
|
|
|
@ -2530,7 +2530,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
switch_snprintf(qname, sizeof(qname), "sofia:%s", profile->name);
|
||||
switch_sql_queue_manager_init_name(qname,
|
||||
&profile->qm,
|
||||
1,
|
||||
2,
|
||||
profile->odbc_dsn ? profile->odbc_dsn : profile->dbname,
|
||||
SWITCH_MAX_TRANS,
|
||||
profile->pre_trans_execute,
|
||||
|
|
|
@ -6373,7 +6373,7 @@ void sofia_glue_execute_sql(sofia_profile_t *profile, char **sqlp, switch_bool_t
|
|||
switch_assert(sqlp && *sqlp);
|
||||
sql = *sqlp;
|
||||
|
||||
switch_sql_queue_manager_push(profile->qm, sql, 0, !sql_already_dynamic);
|
||||
switch_sql_queue_manager_push(profile->qm, sql, 1, !sql_already_dynamic);
|
||||
|
||||
if (sql_already_dynamic) {
|
||||
*sqlp = NULL;
|
||||
|
@ -6395,6 +6395,20 @@ void sofia_glue_execute_sql_now(sofia_profile_t *profile, char **sqlp, switch_bo
|
|||
}
|
||||
}
|
||||
|
||||
void sofia_glue_execute_sql_soon(sofia_profile_t *profile, char **sqlp, switch_bool_t sql_already_dynamic)
|
||||
{
|
||||
char *sql;
|
||||
|
||||
switch_assert(sqlp && *sqlp);
|
||||
sql = *sqlp;
|
||||
|
||||
switch_sql_queue_manager_push(profile->qm, sql, 0, !sql_already_dynamic);
|
||||
|
||||
if (sql_already_dynamic) {
|
||||
*sqlp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_cache_db_handle_t *_sofia_glue_get_db_handle(sofia_profile_t *profile, const char *file, const char *func, int line)
|
||||
{
|
||||
|
|
|
@ -1350,7 +1350,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
|||
}
|
||||
|
||||
if (zstr(call_id)) {
|
||||
|
||||
|
||||
sql = switch_mprintf("update sip_subscriptions set version=version+1 where hostname='%q' and profile_name='%q' and "
|
||||
"sip_subscriptions.event != 'line-seize' "
|
||||
"and sip_subscriptions.proto='%q' and (event='%q' or event='%q') and sub_to_user='%q' and "
|
||||
|
@ -1366,8 +1366,8 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PRES SQL %s\n", sql);
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
sofia_glue_execute_sql_soon(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
|
||||
|
||||
sql = switch_mprintf("select distinct sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
|
||||
|
@ -1376,7 +1376,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
|||
"sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
|
||||
"sip_subscriptions.accept,sip_subscriptions.profile_name"
|
||||
",'%q','%q','%q',sip_presence.status,sip_presence.rpid,sip_presence.open_closed,'%q','%q',"
|
||||
"sip_subscriptions.version, '%q',sip_subscriptions.orig_proto,sip_subscriptions.full_to,"
|
||||
"sip_subscriptions.version+1, '%q',sip_subscriptions.orig_proto,sip_subscriptions.full_to,"
|
||||
"sip_subscriptions.network_ip, sip_subscriptions.network_port "
|
||||
"from sip_subscriptions "
|
||||
"left join sip_presence on "
|
||||
|
@ -1395,6 +1395,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
|||
event_type, alt_event_type, euser, host, profile->sipip,
|
||||
profile->extsipip ? profile->extsipip : "N/A", host);
|
||||
} else {
|
||||
|
||||
sql = switch_mprintf("update sip_subscriptions set version=version+1 where sip_subscriptions.event != 'line-seize' and "
|
||||
"hostname='%q' and profile_name = '%q' and sip_subscriptions.call_id='%q'",
|
||||
mod_sofia_globals.hostname, profile->name, call_id);
|
||||
|
@ -1404,7 +1405,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PRES SQL %s\n", sql);
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
||||
sofia_glue_execute_sql_soon(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
|
||||
sql = switch_mprintf("select distinct sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
|
||||
|
@ -1413,7 +1414,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
|||
"sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
|
||||
"sip_subscriptions.accept,sip_subscriptions.profile_name"
|
||||
",'%q','%q','%q',sip_presence.status,sip_presence.rpid,sip_presence.open_closed,'%q','%q',"
|
||||
"sip_subscriptions.version, '%q',sip_subscriptions.orig_proto,sip_subscriptions.full_to,"
|
||||
"sip_subscriptions.version+1, '%q',sip_subscriptions.orig_proto,sip_subscriptions.full_to,"
|
||||
"sip_subscriptions.network_ip, sip_subscriptions.network_port "
|
||||
"from sip_subscriptions "
|
||||
"left join sip_presence on "
|
||||
|
|
|
@ -2353,6 +2353,8 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
|||
if (zstr(np)) {
|
||||
nonce_cb_t cb = { 0 };
|
||||
long nc_long = 0;
|
||||
int sanity = 0;
|
||||
|
||||
first = 1;
|
||||
|
||||
if (nc) {
|
||||
|
@ -2366,7 +2368,14 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
|||
cb.nplen = nplen;
|
||||
|
||||
switch_assert(sql != NULL);
|
||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_nonce_callback, &cb);
|
||||
|
||||
do {
|
||||
if (sanity) {
|
||||
switch_yield(100000 * sanity);
|
||||
}
|
||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_nonce_callback, &cb);
|
||||
} while(nc_long < 2 && ++sanity < 10 && zstr(np));
|
||||
|
||||
free(sql);
|
||||
|
||||
//if (!sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, np, nplen)) {
|
||||
|
|
|
@ -835,7 +835,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans_full(sw
|
|||
switch(dbh->type) {
|
||||
case SCDB_TYPE_CORE_DB:
|
||||
{
|
||||
switch_cache_db_execute_sql_real(dbh, "BEGIN", &errmsg);
|
||||
switch_cache_db_execute_sql_real(dbh, "BEGIN EXCLUSIVE", &errmsg);
|
||||
}
|
||||
break;
|
||||
case SCDB_TYPE_ODBC:
|
||||
|
@ -1497,7 +1497,7 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm)
|
|||
switch(qm->event_db->type) {
|
||||
case SCDB_TYPE_CORE_DB:
|
||||
{
|
||||
switch_cache_db_execute_sql_real(qm->event_db, "BEGIN", &errmsg);
|
||||
switch_cache_db_execute_sql_real(qm->event_db, "BEGIN EXCLUSIVE", &errmsg);
|
||||
}
|
||||
break;
|
||||
case SCDB_TYPE_ODBC:
|
||||
|
@ -2979,7 +2979,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
|||
switch(sql_manager.dbh->type) {
|
||||
case SCDB_TYPE_CORE_DB:
|
||||
{
|
||||
switch_cache_db_execute_sql_real(sql_manager.dbh, "BEGIN", &err);
|
||||
switch_cache_db_execute_sql_real(sql_manager.dbh, "BEGIN EXCLUSIVE", &err);
|
||||
}
|
||||
break;
|
||||
case SCDB_TYPE_ODBC:
|
||||
|
|
Loading…
Reference in New Issue