mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-02 11:29:48 +00:00
improve sofia recover in some nat cases
This commit is contained in:
parent
d18c3a8a60
commit
4526ba30c6
@ -85,6 +85,10 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
|
|||||||
sofia_glue_tech_absorb_sdp(tech_pvt);
|
sofia_glue_tech_absorb_sdp(tech_pvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
|
||||||
|
sofia_set_flag(tech_pvt, TFLAG_RECOVERED);
|
||||||
|
}
|
||||||
|
|
||||||
if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
|
if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
|
||||||
const char *var;
|
const char *var;
|
||||||
|
|
||||||
|
@ -275,6 +275,7 @@ typedef enum {
|
|||||||
TFLAG_RECOVERING,
|
TFLAG_RECOVERING,
|
||||||
TFLAG_RECOVERING_BRIDGE,
|
TFLAG_RECOVERING_BRIDGE,
|
||||||
TFLAG_T38_PASSTHRU,
|
TFLAG_T38_PASSTHRU,
|
||||||
|
TFLAG_RECOVERED,
|
||||||
/* No new flags below this line */
|
/* No new flags below this line */
|
||||||
TFLAG_MAX
|
TFLAG_MAX
|
||||||
} TFLAGS;
|
} TFLAGS;
|
||||||
|
@ -1225,7 +1225,7 @@ static void sofia_perform_profile_start_failure(sofia_profile_t *profile, char *
|
|||||||
#define sofia_profile_start_failure(p, xp) sofia_perform_profile_start_failure(p, xp, __FILE__, __LINE__)
|
#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)
|
void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread, void *obj)
|
||||||
{
|
{
|
||||||
sofia_profile_t *profile = (sofia_profile_t *) obj;
|
sofia_profile_t *profile = (sofia_profile_t *) obj;
|
||||||
@ -1236,7 +1236,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
|
|||||||
void *pop;
|
void *pop;
|
||||||
int loop_count = 0;
|
int loop_count = 0;
|
||||||
switch_size_t sql_len = SQLLEN;
|
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)) {
|
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
|
||||||
sqlbuf = (char *) malloc(sql_len);
|
sqlbuf = (char *) malloc(sql_len);
|
||||||
@ -1253,7 +1254,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
|
|||||||
|
|
||||||
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
|
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
|
||||||
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
|
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;
|
switch_size_t newlen;
|
||||||
uint32_t itterations = 0;
|
uint32_t itterations = 0;
|
||||||
switch_size_t len = 0;
|
switch_size_t len = 0;
|
||||||
@ -1262,26 +1263,22 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
|
|||||||
|
|
||||||
//sofia_glue_actually_execute_sql(profile, "begin;\n", NULL);
|
//sofia_glue_actually_execute_sql(profile, "begin;\n", NULL);
|
||||||
|
|
||||||
while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
|
while (sql || (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop)) {
|
||||||
char *sql = (char *) pop;
|
|
||||||
|
|
||||||
newlen = strlen(sql) + 2;
|
if (!sql) {
|
||||||
|
sql = (char *) pop;
|
||||||
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;
|
|
||||||
}
|
|
||||||
sprintf(sqlbuf + len, "%s;\n", sql);
|
|
||||||
len += newlen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pop);
|
newlen = strlen(sql) + 2;
|
||||||
|
itterations++;
|
||||||
|
|
||||||
|
if (len + newlen + 10 < sql_len) {
|
||||||
|
sprintf(sqlbuf + len, "%s;\n", sql);
|
||||||
|
len += newlen;
|
||||||
|
switch_safe_free(sql);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("TRANS:\n%s\n", sqlbuf);
|
//printf("TRANS:\n%s\n", sqlbuf);
|
||||||
@ -2860,7 +2857,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||||||
goto done;
|
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;
|
profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833;// | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
|
||||||
|
|
||||||
|
@ -2059,6 +2059,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||||||
nua_invite(tech_pvt->nh,
|
nua_invite(tech_pvt->nh,
|
||||||
NUTAG_AUTOANSWER(0),
|
NUTAG_AUTOANSWER(0),
|
||||||
NUTAG_SESSION_TIMER(session_timeout),
|
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_from, SIPTAG_FROM_STR(invite_full_from)),
|
||||||
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
||||||
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
|
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
|
||||||
@ -2087,6 +2088,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||||||
nua_invite(tech_pvt->nh,
|
nua_invite(tech_pvt->nh,
|
||||||
NUTAG_AUTOANSWER(0),
|
NUTAG_AUTOANSWER(0),
|
||||||
NUTAG_SESSION_TIMER(session_timeout),
|
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_from, SIPTAG_FROM_STR(invite_full_from)),
|
||||||
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
||||||
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
|
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
|
||||||
@ -4644,7 +4646,7 @@ void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||||
sofia_clear_flag(tech_pvt, TFLAG_TRACKED);
|
sofia_clear_flag(tech_pvt, TFLAG_TRACKED);
|
||||||
|
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user