fix double sessions on auth challenged calls
This commit is contained in:
parent
9544d7a49e
commit
8e5f5baa06
|
@ -673,6 +673,7 @@ SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(_In_ switch_core_sessio
|
||||||
\return the total number of allocated sessions since core startup
|
\return the total number of allocated sessions since core startup
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_size_t) switch_core_session_id(void);
|
SWITCH_DECLARE(switch_size_t) switch_core_session_id(void);
|
||||||
|
SWITCH_DECLARE(switch_size_t) switch_core_session_id_dec(void);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Allocate and return a new session from the core based on a given endpoint module name
|
\brief Allocate and return a new session from the core based on a given endpoint module name
|
||||||
|
|
|
@ -1241,6 +1241,7 @@ typedef enum {
|
||||||
CF_RECOVERING_BRIDGE,
|
CF_RECOVERING_BRIDGE,
|
||||||
CF_TRACKED,
|
CF_TRACKED,
|
||||||
CF_TRACKABLE,
|
CF_TRACKABLE,
|
||||||
|
CF_NO_CDR,
|
||||||
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
||||||
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
|
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
|
||||||
CF_FLAG_MAX
|
CF_FLAG_MAX
|
||||||
|
|
|
@ -1658,6 +1658,20 @@ void sofia_event_callback(nua_event_t event,
|
||||||
uint32_t sess_max = switch_core_session_limit(0);
|
uint32_t sess_max = switch_core_session_limit(0);
|
||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
|
case nua_i_terminated:
|
||||||
|
if (status > 300 && sofia_private && sofia_private->uuid) {
|
||||||
|
switch_core_session_t *session;
|
||||||
|
|
||||||
|
if ((session = switch_core_session_force_locate(sofia_private->uuid))) {
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
switch_channel_set_flag(channel, CF_NO_CDR);
|
||||||
|
switch_channel_hangup(channel, status == 403 ? SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL : SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH);
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
switch_core_session_id_dec();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
case nua_i_invite:
|
case nua_i_invite:
|
||||||
case nua_i_register:
|
case nua_i_register:
|
||||||
case nua_i_options:
|
case nua_i_options:
|
||||||
|
@ -1718,8 +1732,20 @@ void sofia_event_callback(nua_event_t event,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session) {
|
if (session) {
|
||||||
|
const char *channel_name = NULL;
|
||||||
private_object_t *tech_pvt = sofia_glue_new_pvt(session);
|
private_object_t *tech_pvt = sofia_glue_new_pvt(session);
|
||||||
sofia_glue_attach_private(session, profile, tech_pvt, NULL);
|
|
||||||
|
if (sip->sip_from) {
|
||||||
|
channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from);
|
||||||
|
}
|
||||||
|
if (!channel_name && sip->sip_contact && sip->sip_contact->m_url) {
|
||||||
|
channel_name = url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
|
||||||
|
}
|
||||||
|
if (sip->sip_referred_by) {
|
||||||
|
channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
|
||||||
|
}
|
||||||
|
|
||||||
|
sofia_glue_attach_private(session, profile, tech_pvt, channel_name);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||||
|
@ -8016,7 +8042,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||||
sip_call_info_t *call_info = NULL;
|
sip_call_info_t *call_info = NULL;
|
||||||
private_object_t *tech_pvt = NULL;
|
private_object_t *tech_pvt = NULL;
|
||||||
switch_channel_t *channel = NULL;
|
switch_channel_t *channel = NULL;
|
||||||
const char *channel_name = NULL;
|
//const char *channel_name = NULL;
|
||||||
const char *displayname = NULL;
|
const char *displayname = NULL;
|
||||||
const char *destination_number = NULL;
|
const char *destination_number = NULL;
|
||||||
const char *from_user = NULL, *from_host = NULL;
|
const char *from_user = NULL, *from_host = NULL;
|
||||||
|
@ -8323,7 +8349,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||||
if (sip->sip_from && sip->sip_from->a_url) {
|
if (sip->sip_from && sip->sip_from->a_url) {
|
||||||
from_user = sip->sip_from->a_url->url_user;
|
from_user = sip->sip_from->a_url->url_user;
|
||||||
from_host = sip->sip_from->a_url->url_host;
|
from_host = sip->sip_from->a_url->url_host;
|
||||||
channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from);
|
//channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from);
|
||||||
|
|
||||||
if (sip->sip_from->a_url->url_params) {
|
if (sip->sip_from->a_url->url_params) {
|
||||||
aniii = switch_find_parameter(sip->sip_from->a_url->url_params, "isup-oli", switch_core_session_get_pool(session));
|
aniii = switch_find_parameter(sip->sip_from->a_url->url_params, "isup-oli", switch_core_session_get_pool(session));
|
||||||
|
@ -8550,16 +8576,13 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sip->sip_contact && sip->sip_contact->m_url) {
|
if (sip->sip_contact && sip->sip_contact->m_url) {
|
||||||
const char *contact_uri = url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
|
url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
|
||||||
if (!channel_name) {
|
|
||||||
channel_name = contact_uri;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sip->sip_referred_by) {
|
if (sip->sip_referred_by) {
|
||||||
referred_by_user = sip->sip_referred_by->b_url->url_user;
|
referred_by_user = sip->sip_referred_by->b_url->url_user;
|
||||||
//referred_by_host = sip->sip_referred_by->b_url->url_host;
|
//referred_by_host = sip->sip_referred_by->b_url->url_host;
|
||||||
channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
|
//channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
|
||||||
|
|
||||||
check_decode(referred_by_user, session);
|
check_decode(referred_by_user, session);
|
||||||
|
|
||||||
|
@ -8578,7 +8601,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sofia_glue_set_name(tech_pvt, channel_name);
|
//sofia_glue_set_name(tech_pvt, channel_name);
|
||||||
sofia_glue_tech_prepare_codecs(tech_pvt);
|
sofia_glue_tech_prepare_codecs(tech_pvt);
|
||||||
|
|
||||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
|
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
|
||||||
|
|
|
@ -2130,6 +2130,14 @@ SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(switch_core_session_t *
|
||||||
return session->id;
|
return session->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_size_t) switch_core_session_id_dec(void)
|
||||||
|
{
|
||||||
|
switch_mutex_lock(runtime.session_hash_mutex);
|
||||||
|
session_manager.session_id--;
|
||||||
|
switch_mutex_unlock(runtime.session_hash_mutex);
|
||||||
|
return session_manager.session_id;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_size_t) switch_core_session_id(void)
|
SWITCH_DECLARE(switch_size_t) switch_core_session_id(void)
|
||||||
{
|
{
|
||||||
return session_manager.session_id;
|
return session_manager.session_id;
|
||||||
|
|
|
@ -697,6 +697,11 @@ SWITCH_DECLARE(void) switch_core_session_reporting_state(switch_core_session_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_channel_test_flag(session->channel, CF_NO_CDR)) {
|
||||||
|
do_extra_handlers = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
STATE_MACRO(reporting, "REPORTING");
|
STATE_MACRO(reporting, "REPORTING");
|
||||||
|
|
||||||
if ((hook_var = switch_channel_get_variable(session->channel, SWITCH_API_REPORTING_HOOK_VARIABLE))) {
|
if ((hook_var = switch_channel_get_variable(session->channel, SWITCH_API_REPORTING_HOOK_VARIABLE))) {
|
||||||
|
|
Loading…
Reference in New Issue