mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-12 20:27:19 +00:00
declinatio mortuus obfirmo in fsctl hupall
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12544 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
fbcddd6465
commit
2c364e6cba
@ -81,6 +81,12 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam
|
|||||||
switch_hash_index_t *hi;
|
switch_hash_index_t *hi;
|
||||||
void *val;
|
void *val;
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
|
switch_memory_pool_t *pool;
|
||||||
|
switch_queue_t *queue;
|
||||||
|
void *pop;
|
||||||
|
|
||||||
|
switch_core_new_memory_pool(&pool);
|
||||||
|
switch_queue_create(&queue, 250000, pool);
|
||||||
|
|
||||||
if (!var_val) return;
|
if (!var_val) return;
|
||||||
|
|
||||||
@ -93,13 +99,25 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam
|
|||||||
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (switch_channel_up(session->channel) &&
|
if (switch_channel_up(session->channel) &&
|
||||||
(this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) {
|
(this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) {
|
||||||
switch_channel_hangup(session->channel, cause);
|
switch_queue_push(queue, switch_core_strdup(pool, session->uuid_str));
|
||||||
}
|
}
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(runtime.session_hash_mutex);
|
switch_mutex_unlock(runtime.session_hash_mutex);
|
||||||
|
|
||||||
|
while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
|
||||||
|
char *uuid = (char *) pop;
|
||||||
|
|
||||||
|
if ((session = switch_core_session_locate(uuid))) {
|
||||||
|
switch_channel_hangup(session->channel, cause);
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_core_destroy_memory_pool(&pool);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause)
|
SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause)
|
||||||
@ -107,6 +125,12 @@ SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_i
|
|||||||
switch_hash_index_t *hi;
|
switch_hash_index_t *hi;
|
||||||
void *val;
|
void *val;
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
|
switch_memory_pool_t *pool;
|
||||||
|
switch_queue_t *queue;
|
||||||
|
void *pop;
|
||||||
|
|
||||||
|
switch_core_new_memory_pool(&pool);
|
||||||
|
switch_queue_create(&queue, 250000, pool);
|
||||||
|
|
||||||
switch_mutex_lock(runtime.session_hash_mutex);
|
switch_mutex_lock(runtime.session_hash_mutex);
|
||||||
for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
|
for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
|
||||||
@ -115,13 +139,25 @@ SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_i
|
|||||||
session = (switch_core_session_t *) val;
|
session = (switch_core_session_t *) val;
|
||||||
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (session->endpoint_interface == endpoint_interface) {
|
if (session->endpoint_interface == endpoint_interface) {
|
||||||
switch_channel_hangup(switch_core_session_get_channel(session), cause);
|
switch_queue_push(queue, switch_core_strdup(pool, session->uuid_str));
|
||||||
}
|
}
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(runtime.session_hash_mutex);
|
switch_mutex_unlock(runtime.session_hash_mutex);
|
||||||
|
|
||||||
|
while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
|
||||||
|
char *uuid = (char *) pop;
|
||||||
|
|
||||||
|
if ((session = switch_core_session_locate(uuid))) {
|
||||||
|
switch_channel_hangup(session->channel, cause);
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_core_destroy_memory_pool(&pool);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause)
|
SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause)
|
||||||
@ -129,28 +165,37 @@ SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause)
|
|||||||
switch_hash_index_t *hi;
|
switch_hash_index_t *hi;
|
||||||
void *val;
|
void *val;
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
uint32_t loops = 0;
|
switch_memory_pool_t *pool;
|
||||||
|
switch_queue_t *queue;
|
||||||
|
void *pop;
|
||||||
|
|
||||||
while (session_manager.session_count > 0) {
|
switch_core_new_memory_pool(&pool);
|
||||||
switch_mutex_lock(runtime.session_hash_mutex);
|
switch_queue_create(&queue, 250000, pool);
|
||||||
for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
|
|
||||||
switch_hash_this(hi, NULL, NULL, &val);
|
switch_mutex_lock(runtime.session_hash_mutex);
|
||||||
if (val) {
|
for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
|
||||||
session = (switch_core_session_t *) val;
|
switch_hash_this(hi, NULL, NULL, &val);
|
||||||
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
if (val) {
|
||||||
switch_channel_hangup(switch_core_session_get_channel(session), cause);
|
session = (switch_core_session_t *) val;
|
||||||
switch_core_session_rwunlock(session);
|
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
||||||
}
|
switch_queue_push(queue, switch_core_strdup(pool, session->uuid_str));
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(runtime.session_hash_mutex);
|
}
|
||||||
switch_yield(1000000);
|
switch_mutex_unlock(runtime.session_hash_mutex);
|
||||||
if (++loops == 30) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Giving up with %d session%s remaining\n",
|
while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
|
||||||
session_manager.session_count, session_manager.session_count == 1 ? "" : "s");
|
char *uuid = (char *) pop;
|
||||||
break;
|
|
||||||
|
if ((session = switch_core_session_locate(uuid))) {
|
||||||
|
switch_channel_hangup(session->channel, cause);
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_core_destroy_memory_pool(&pool);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user