forked from Mirrors/freeswitch
pass originate flags into session_request so we can selectivly skip throttling
This commit is contained in:
parent
ab2529d4e1
commit
46c6650a94
|
@ -614,8 +614,10 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_e
|
|||
*/
|
||||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface,
|
||||
_In_ switch_call_direction_t direction,
|
||||
_Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid);
|
||||
#define switch_core_session_request(_ep, _d, _p) switch_core_session_request_uuid(_ep, _d, _p, NULL)
|
||||
switch_originate_flag_t originate_flags,
|
||||
_Inout_opt_ switch_memory_pool_t **pool,
|
||||
_In_opt_z_ const char *use_uuid);
|
||||
#define switch_core_session_request(_ep, _d, _f, _p) switch_core_session_request_uuid(_ep, _d, _f, _p, NULL)
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(_In_ switch_core_session_t *session, _In_z_ const char *use_uuid);
|
||||
|
||||
|
|
|
@ -220,7 +220,8 @@ typedef enum {
|
|||
SOF_NOBLOCK = (1 << 0),
|
||||
SOF_FORKED_DIAL = (1 << 1),
|
||||
SOF_NO_EFFECTIVE_CID_NUM = (1 << 2),
|
||||
SOF_NO_EFFECTIVE_CID_NAME = (1 << 3)
|
||||
SOF_NO_EFFECTIVE_CID_NAME = (1 << 3),
|
||||
SOF_NO_LIMITS = (1 << 4)
|
||||
} switch_originate_flag_enum_t;
|
||||
typedef uint32_t switch_originate_flag_t;
|
||||
|
||||
|
|
|
@ -4771,7 +4771,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
|
|||
|
||||
if (conference == NULL) {
|
||||
char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto);
|
||||
status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL);
|
||||
status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NO_LIMITS, NULL);
|
||||
switch_safe_free(dialstr);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -4804,7 +4804,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
|
|||
|
||||
/* establish an outbound call leg */
|
||||
|
||||
if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) !=
|
||||
if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NO_LIMITS, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n",
|
||||
switch_channel_cause2str(*cause));
|
||||
|
|
|
@ -2814,6 +2814,10 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
|||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
if ((flags & SOF_NO_LIMITS)) {
|
||||
myflags |= SOF_NO_LIMITS;
|
||||
}
|
||||
|
||||
if ((flags & SOF_FORKED_DIAL)) {
|
||||
myflags |= SOF_NOBLOCK;
|
||||
}
|
||||
|
|
|
@ -766,7 +766,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
|
@ -1437,7 +1437,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
|||
}
|
||||
dest = argv[0];
|
||||
|
||||
if ((session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
|
||||
if ((session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
char *dialplan = globals.dialplan;
|
||||
|
|
|
@ -1628,7 +1628,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
|
||||
if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
switch_caller_profile_t *caller_profile = NULL;
|
||||
|
@ -2948,7 +2948,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
|||
goto done;
|
||||
}
|
||||
|
||||
if ((session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
|
||||
if ((session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) {
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
|
|
|
@ -2274,7 +2274,7 @@ int new_inbound_channel(private_t * tech_pvt)
|
|||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
tech_pvt->ib_calls++;
|
||||
if ((session = switch_core_session_request(gsmopen_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
|
||||
if ((session = switch_core_session_request(gsmopen_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) {
|
||||
DEBUGA_GSMOPEN("2 SESSION_REQUEST %s\n", GSMOPEN_P_LOG, switch_core_session_get_uuid(session));
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
|
|
@ -211,7 +211,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
|||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {
|
||||
|
||||
if (!(b_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL))) {
|
||||
if (!(b_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure.\n");
|
||||
goto end;
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_channel_pre_answer(channel);
|
||||
}
|
||||
|
||||
if ((*new_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
|
||||
if ((*new_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
|
|
|
@ -735,7 +735,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
|
||||
if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
|
||||
if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
|
@ -1750,7 +1750,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
|||
}
|
||||
dest = argv[0];
|
||||
|
||||
if ((session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
|
||||
if ((session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
char *dialplan = globals.dialplan;
|
||||
|
|
|
@ -418,7 +418,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(reference_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
|
||||
if ((*new_session = switch_core_session_request(reference_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
|
|
|
@ -1039,7 +1039,7 @@ switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, swi
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (!(nsession = switch_core_session_request(skinny_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool))) {
|
||||
if (!(nsession = switch_core_session_request(skinny_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -1806,7 +1806,7 @@ int new_inbound_channel(private_t * p)
|
|||
switch_core_session_t *session = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
|
||||
if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
|
||||
if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) {
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
skypiax_tech_init(tech_pvt, session);
|
||||
|
|
|
@ -1056,7 +1056,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
private_t *tech_pvt = NULL;
|
||||
if ((*new_session = switch_core_session_request(skypopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
|
||||
if ((*new_session = switch_core_session_request(skypopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) {
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
char *rdest;
|
||||
|
@ -1964,7 +1964,7 @@ int new_inbound_channel(private_t * tech_pvt)
|
|||
switch_core_session_t *session = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
|
||||
if ((session = switch_core_session_request(skypopen_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
|
||||
if ((session = switch_core_session_request(skypopen_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) {
|
||||
DEBUGA_SKYPE("2 SESSION_REQUEST %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(session));
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
|
|
@ -3544,13 +3544,6 @@ SWITCH_STANDARD_API(sofia_function)
|
|||
sofia_glue_recover(SWITCH_TRUE);
|
||||
stream->write_function(stream, "Flushing recovery database.\n");
|
||||
} else {
|
||||
int32_t old = 0, x = 0;
|
||||
|
||||
switch_core_session_ctl(SCSC_SPS, &old);
|
||||
|
||||
x = 10000000;
|
||||
switch_core_session_ctl(SCSC_SPS, &x);
|
||||
|
||||
x = sofia_glue_recover(SWITCH_FALSE);
|
||||
|
||||
if (x) {
|
||||
|
@ -3558,8 +3551,6 @@ SWITCH_STANDARD_API(sofia_function)
|
|||
} else {
|
||||
stream->write_function(stream, "No calls to recover.\n");
|
||||
}
|
||||
|
||||
switch_core_session_ctl(SCSC_SPS, &old);
|
||||
}
|
||||
|
||||
goto done;
|
||||
|
@ -3632,7 +3623,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (!(nsession = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool))) {
|
||||
if (!(nsession = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -6119,9 +6119,9 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
|
||||
if (sofia_endpoint_interface) {
|
||||
if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) {
|
||||
session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL, sip->sip_call_id->i_id);
|
||||
session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL, sip->sip_call_id->i_id);
|
||||
} else {
|
||||
session = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL);
|
||||
session = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ static switch_call_cause_t unicall_incoming_channel(zap_sigmsg_t *sigmsg, switch
|
|||
|
||||
*sp = NULL;
|
||||
|
||||
if (!(session = switch_core_session_request(openzap_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL))) {
|
||||
if (!(session = switch_core_session_request(openzap_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Initialization Error!\n");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
@ -1513,7 +1513,7 @@ static switch_call_cause_t unicall_outgoing_channel(switch_core_session_t *sessi
|
|||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_outgoing_channel(%p)\n", (void *) session);
|
||||
|
||||
if ((*new_session = switch_core_session_request(unicall_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) == NULL) {
|
||||
if ((*new_session = switch_core_session_request(unicall_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) == NULL) {
|
||||
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
}
|
||||
|
||||
|
|
|
@ -1382,7 +1382,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_e
|
|||
parse_array(flag_str, flags, CF_FLAG_MAX);
|
||||
parse_array(cap_str, caps, CC_FLAG_MAX);
|
||||
|
||||
if (!(session = switch_core_session_request_uuid(endpoint_interface, direction, pool, uuid))) {
|
||||
if (!(session = switch_core_session_request_uuid(endpoint_interface, direction, SOF_NO_LIMITS, pool, uuid))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1517,6 +1517,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_e
|
|||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_endpoint_interface_t
|
||||
*endpoint_interface,
|
||||
switch_call_direction_t direction,
|
||||
switch_originate_flag_t originate_flags,
|
||||
switch_memory_pool_t **pool, const char *use_uuid)
|
||||
{
|
||||
switch_memory_pool_t *usepool;
|
||||
|
@ -1542,22 +1543,25 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_
|
|||
|
||||
PROTECT_INTERFACE(endpoint_interface);
|
||||
|
||||
switch_mutex_lock(runtime.throttle_mutex);
|
||||
count = session_manager.session_count;
|
||||
sps = --runtime.sps;
|
||||
switch_mutex_unlock(runtime.throttle_mutex);
|
||||
if (!(originate_flags & SOF_NO_LIMITS)) {
|
||||
switch_mutex_lock(runtime.throttle_mutex);
|
||||
count = session_manager.session_count;
|
||||
sps = --runtime.sps;
|
||||
switch_mutex_unlock(runtime.throttle_mutex);
|
||||
|
||||
if (sps <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Throttle Error! %d\n", session_manager.session_count);
|
||||
UNPROTECT_INTERFACE(endpoint_interface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sps <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Throttle Error! %d\n", session_manager.session_count);
|
||||
UNPROTECT_INTERFACE(endpoint_interface);
|
||||
return NULL;
|
||||
if ((count + 1) > session_manager.session_limit) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Limit! %d\n", session_manager.session_limit);
|
||||
UNPROTECT_INTERFACE(endpoint_interface);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((count + 1) > session_manager.session_limit) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Limit! %d\n", session_manager.session_limit);
|
||||
UNPROTECT_INTERFACE(endpoint_interface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pool && *pool) {
|
||||
usepool = *pool;
|
||||
|
@ -1654,7 +1658,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(cons
|
|||
return NULL;
|
||||
}
|
||||
|
||||
session = switch_core_session_request(endpoint_interface, direction, pool);
|
||||
session = switch_core_session_request(endpoint_interface, direction, SOF_NONE, pool);
|
||||
|
||||
UNPROTECT_INTERFACE(endpoint_interface);
|
||||
|
||||
|
|
|
@ -2244,10 +2244,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
|
||||
}
|
||||
|
||||
if (flags & SOF_NO_LIMITS) {
|
||||
dftflags |= SOF_NO_LIMITS;
|
||||
}
|
||||
|
||||
if (cid_num_override) {
|
||||
dftflags |= SOF_NO_EFFECTIVE_CID_NUM;
|
||||
}
|
||||
|
||||
|
||||
if (cid_name_override) {
|
||||
dftflags |= SOF_NO_EFFECTIVE_CID_NAME;
|
||||
}
|
||||
|
@ -2450,11 +2454,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
|
||||
if (and_argc > 1 || or_argc > 1) {
|
||||
myflags |= SOF_FORKED_DIAL;
|
||||
} else if (var_event) {
|
||||
}
|
||||
|
||||
if (var_event) {
|
||||
const char *vvar;
|
||||
if ((vvar = switch_event_get_header(var_event, "forked_dial")) && switch_true(vvar)) {
|
||||
myflags |= SOF_FORKED_DIAL;
|
||||
}
|
||||
if ((vvar = switch_event_get_header(var_event, "no_throttle_limits")) && switch_true(vvar)) {
|
||||
myflags |= SOF_NO_LIMITS;
|
||||
}
|
||||
}
|
||||
|
||||
/* only valid in [] since it's unique to each channel leg */
|
||||
|
|
Loading…
Reference in New Issue