From b7c5a80a70709ba32f010a74c6c684d3271abb38 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 09:33:44 -0500 Subject: [PATCH 01/43] comment out vars --- src/switch_ivr_bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 9cb56b2246..34d53c2bcf 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1408,8 +1408,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu /* change the states and let the chips fall where they may */ - switch_channel_set_variable(originator_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, NULL); - switch_channel_set_variable(originatee_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, NULL); + //switch_channel_set_variable(originator_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, NULL); + //switch_channel_set_variable(originatee_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, NULL); switch_channel_clear_state_handler(originator_channel, NULL); switch_channel_clear_state_handler(originatee_channel, NULL); switch_channel_set_state_flag(originator_channel, CF_BRIDGE_ORIGINATOR); From 7898679b202c7d2add3337f624a89ab2777dfdf7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 09:37:49 -0500 Subject: [PATCH 02/43] tweak --- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 +- src/mod/endpoints/mod_sofia/sofia_glue.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 3723d3582c..98ea119359 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -83,7 +83,7 @@ typedef struct private_object private_object_t; #define MY_EVENT_REINVITE "sofia::reinvite" #define MY_EVENT_GATEWAY_ADD "sofia::gateway_add" #define MY_EVENT_GATEWAY_DEL "sofia::gateway_delete" -#define MY_EVENT_RECOVERY "sofia::recovery" +#define MY_EVENT_RECOVERY "sofia::recovery_recv" #define MY_EVENT_RECOVERY_SEND "sofia::recovery_send" #define MULTICAST_EVENT "multicast::event" diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index c4621a9b8a..eff6f049f1 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -4615,6 +4615,7 @@ void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *se if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS_EVENTS)) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY_SEND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sql", sql); switch_event_fire(&event); } @@ -4657,6 +4658,7 @@ void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *sess switch_event_t *event = NULL; if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY_SEND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sql", sql); switch_event_fire(&event); } From 1fba654845c8202bf84c58b203a3bc9624164c4e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 14:21:44 -0500 Subject: [PATCH 03/43] fix parse err in originate code --- src/include/switch_utils.h | 41 ++++++++++++++++++++++++++++++++++++++ src/switch_event.c | 4 ++-- src/switch_ivr_originate.c | 6 +++--- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 7c4541671e..514f78d0d8 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -92,6 +92,47 @@ static inline switch_bool_t switch_is_moh(const char *s) return SWITCH_TRUE; } +/* find a character (find) in a string (in) and return a pointer to that point in the string where the character was found + using the array (allowed) as allowed non-matching characters, when (allowed) is NULL, behaviour should be identical to strchr() + */ +static inline char *switch_strchr_strict(const char *in, char find, const char *allowed) +{ + const char *p; + + switch_assert(in); + + p = in; + + while(p && *p) { + const char *a = allowed; + int found = 0; + + if (!a) { + found = 1; + } else { + + while(a && *a) { + + if (*p == *a) { + found = 1; + break; + } + + a++; + } + + } + + if (!found) return NULL; + + if (*p == find) break; + + p++; + } + + return (char *) p; +} + #define switch_arraylen(_a) (sizeof(_a) / sizeof(_a[0])) #define switch_split(_data, _delim, _array) switch_separate_string(_data, _delim, _array, switch_arraylen(_array)) diff --git a/src/switch_event.c b/src/switch_event.c index 130032c0ed..ed2b38466a 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -1064,7 +1064,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a, check_a = end; - while (check_a && (check_b = strchr(check_a, a))) { + while (check_a && (check_b = switch_strchr_strict(check_a, a, " "))) { if ((check_b = switch_find_end_paren(check_b, a, b))) { check_a = check_b; } @@ -1090,7 +1090,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a, char *pnext; *next++ = '\0'; - if ((pnext = strchr(next, a))) { + if ((pnext = switch_strchr_strict(next, a, " "))) { next = pnext + 1; } } diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 1edc491be5..9cd71f334e 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -2313,7 +2313,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } if (p == end) { - end = strchr(p, '['); + end = switch_strchr_strict(p, '[', " "); } p++; @@ -2537,7 +2537,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess current_variable = NULL; switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); - + printf("ASS %s\n", vdata); if (vdata) { char *var_array[1024] = { 0 }; int var_count = 0; @@ -2552,7 +2552,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess char *pnext; *next++ = '\0'; - if ((pnext = strchr(next, '['))) { + if ((pnext = switch_strchr_strict(next, '[', " "))) { next = pnext + 1; } } From 21edf395cae6d138dd391c662b1ffc222b8984a0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 15:19:40 -0500 Subject: [PATCH 04/43] de-ass --- src/switch_ivr_originate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 9cd71f334e..e7863ab0c1 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -2537,7 +2537,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess current_variable = NULL; switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false"); - printf("ASS %s\n", vdata); if (vdata) { char *var_array[1024] = { 0 }; int var_count = 0; @@ -3332,7 +3331,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } else { const char *cdr_var = NULL; - switch_xml_t cdr; + switch_xml_t cdr = NULL; char *xml_text; char buf[128] = "", buf2[128] = ""; From 3a6bb506c07846151aa49022ca542e57062f602f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 15:22:13 -0500 Subject: [PATCH 05/43] passing non-null value to generate_xml_cdr now implies its an initalized xml object --- src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c | 4 ++-- src/mod/languages/mod_spidermonkey/mod_spidermonkey.c | 2 +- src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c | 2 +- src/switch_cpp.cpp | 2 +- src/switch_ivr.c | 8 ++++++-- src/switch_ivr_bridge.c | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c index 2edbb6f490..71159654c0 100644 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c +++ b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c @@ -133,7 +133,7 @@ static rc_handle *my_radius_init(void) static switch_status_t my_on_routing(switch_core_session_t *session) { - switch_xml_t cdr; + switch_xml_t cdr = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); rc_handle *rad_config; switch_status_t retval = SWITCH_STATUS_TERM; @@ -377,7 +377,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) static switch_status_t my_on_reporting(switch_core_session_t *session) { - switch_xml_t cdr; + switch_xml_t cdr = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); rc_handle *rad_config; switch_status_t retval = SWITCH_STATUS_TERM; diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 4f6c7aadc4..ccaba559fd 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2090,7 +2090,7 @@ static JSBool session_pre_answer(JSContext * cx, JSObject * obj, uintN argc, jsv static JSBool session_cdr(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) { struct js_session *jss = JS_GetPrivate(cx, obj); - switch_xml_t cdr; + switch_xml_t cdr = NULL; /*Always a pessimist... sheesh! */ *rval = BOOLEAN_TO_JSVAL(JS_FALSE); diff --git a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c index 5f04b11800..83f9f72c09 100644 --- a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c +++ b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c @@ -179,7 +179,7 @@ static switch_status_t set_xml_cdr_log_dirs() static switch_status_t my_on_reporting(switch_core_session_t *session) { - switch_xml_t cdr; + switch_xml_t cdr = NULL; char *xml_text = NULL; char *path = NULL; char *curl_xml_text = NULL; diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 3c71d35370..ec4c9c40b4 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -542,7 +542,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession() SWITCH_DECLARE(char *) CoreSession::getXMLCDR() { - switch_xml_t cdr; + switch_xml_t cdr = NULL; this_check((char *)""); sanity_check((char *)""); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 14f874289a..f42b28ff57 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1859,8 +1859,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_ char tmp[512], *f; int cdr_off = 0, v_off = 0, cd_off = 0; - if (!(cdr = switch_xml_new("cdr"))) { - return SWITCH_STATUS_SUCCESS; + if (*xml_cdr) { + cdr = *xml_cdr; + } else { + if (!(cdr = switch_xml_new("cdr"))) { + return SWITCH_STATUS_SUCCESS; + } } if (!(x_channel_data = switch_xml_add_child_d(cdr, "channel_data", cdr_off++))) { diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 34d53c2bcf..633d4fac34 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1211,7 +1211,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses } if (switch_channel_down(peer_channel) && switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_XML_CDR_VARIABLE))) { - switch_xml_t cdr; + switch_xml_t cdr = NULL; char *xml_text; switch_channel_wait_for_state(peer_channel, caller_channel, CS_DESTROY); From 58b67bc5ccfeb7577ddde85d498ea9dbb993a512 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 15:24:14 -0500 Subject: [PATCH 06/43] add outbound_per_cycle param to control how many outbound calls are made per cycle and normalized some of the output in fifo status --- src/mod/applications/mod_fifo/mod_fifo.c | 324 +++++++++++++++++------ 1 file changed, 240 insertions(+), 84 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 29dbac9b3b..c6c9234c16 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -248,6 +248,7 @@ struct fifo_node { int ready; int busy; int is_static; + int outbound_per_cycle; outbound_strategy_t outbound_strategy; }; @@ -652,27 +653,6 @@ static int node_idle_consumers(fifo_node_t *node) } -static switch_status_t hanguphook(switch_core_session_t *session) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_channel_state_t state = switch_channel_get_state(channel); - const char *uuid = NULL; - char sql[256] = ""; - - if (state == CS_HANGUP || state == CS_ROUTING) { - if ((uuid = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) { - switch_snprintf(sql, sizeof(sql), - "update fifo_outbound set use_count=use_count-1, " - "outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s' and use_count > 0", - (long) switch_epoch_time_now(NULL), uuid); - - fifo_execute_sql(sql, globals.sql_mutex); - } - switch_core_event_hook_remove_state_change(session, hanguphook); - } - return SWITCH_STATUS_SUCCESS; -} - struct call_helper { char *uuid; char *node_name; @@ -697,7 +677,6 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void char *node_name; int i = 0; int timeout = 0; - char sql[256] = ""; switch_stream_handle_t stream = { 0 }; fifo_node_t *node = NULL; char *originate_string; @@ -708,7 +687,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void char *app_name = NULL, *arg = NULL; switch_caller_extension_t *extension = NULL; switch_channel_t *channel; - char *cid_name = NULL, *cid_num = NULL, *id = NULL; + char *caller_id_name = NULL, *cid_num = NULL, *id = NULL; switch_event_t *pop = NULL; fifo_queue_t *q = NULL; int x = 0; @@ -725,7 +704,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void if (node) { switch_mutex_lock(node->mutex); - node->busy = 1; + node->busy++; node->ring_consumer_count++; switch_mutex_unlock(node->mutex); } else { @@ -750,8 +729,6 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void stream.write_function(&stream, "[leg_timeout=%d,fifo_outbound_uuid=%s]%s,", h->timeout, h->uuid, parsed ? parsed : h->originate_string); switch_safe_free(parsed); - switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count+1 where uuid='%s'", h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); } @@ -797,8 +774,8 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void goto end; } - if ((cid_name = switch_event_get_header(pop, "caller-caller-id-name"))) { - switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_name", cid_name); + if ((caller_id_name = switch_event_get_header(pop, "caller-caller-id-name"))) { + switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_name", caller_id_name); } if ((cid_num = switch_event_get_header(pop, "caller-caller-id-number"))) { @@ -815,21 +792,12 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void free(originate_string); if (status != SWITCH_STATUS_SUCCESS) { - for (i = 0; i < cbh->rowcount; i++) { - struct call_helper *h = cbh->rows[i]; - switch_snprintf(sql, sizeof(sql), - "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, " - "next_avail=%ld + lag where uuid='%s' and use_count > 0", - (long) switch_epoch_time_now(NULL), h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - } goto end; } channel = switch_core_session_get_channel(session); switch_channel_set_variable(channel, "fifo_pop_order", NULL); - switch_core_event_hook_add_state_change(session, hanguphook); app_name = "fifo"; arg = switch_core_session_sprintf(session, "%s out nowait", node_name); extension = switch_caller_extension_new(session, app_name, arg); @@ -846,7 +814,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void if (node->ring_consumer_count-- < 0) { node->ring_consumer_count = 0; } - node->busy = 0; + if (node->busy) node->busy--; switch_mutex_unlock(node->mutex); } @@ -864,7 +832,6 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_call_cause_t cause = SWITCH_CAUSE_NONE; switch_caller_extension_t *extension = NULL; char *app_name, *arg = NULL, *originate_string = NULL, *p = NULL; - char sql[256] = ""; const char *member_wait = NULL; fifo_node_t *node = NULL; switch_event_t *ovars = NULL; @@ -877,17 +844,13 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) if (node) { switch_mutex_lock(node->mutex); node->ring_consumer_count++; + node->busy++; switch_mutex_unlock(node->mutex); } - switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count+1 where uuid='%s'", h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_event_create(&ovars, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(ovars); switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "originate_timeout", "%d", h->timeout); - - if (switch_stristr("origination_caller", h->originate_string)) { originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'}%s", @@ -909,11 +872,6 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) if (status != SWITCH_STATUS_SUCCESS) { - switch_snprintf(sql, sizeof(sql), - "update fifo_outbound set use_count=use_count-1, " - "outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s' and use_count > 0", - (long) switch_epoch_time_now(NULL), h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); goto end; } @@ -927,7 +885,6 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) } switch_channel_set_variable(channel, "fifo_outbound_uuid", h->uuid); - switch_core_event_hook_add_state_change(session, hanguphook); app_name = "fifo"; arg = switch_core_session_sprintf(session, "%s out %s", h->node_name, member_wait ? member_wait : "wait"); extension = switch_caller_extension_new(session, app_name, arg); @@ -941,8 +898,10 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_event_destroy(&ovars); if (node) { switch_mutex_lock(node->mutex); - if (node->ring_consumer_count-- < 0) + if (node->ring_consumer_count-- < 0) { node->ring_consumer_count = 0; + } + if (node->busy) node->busy--; switch_mutex_unlock(node->mutex); } switch_core_destroy_memory_pool(&h->pool); @@ -1006,17 +965,25 @@ static void find_consumers(fifo_node_t *node) char *sql; - sql = switch_mprintf("select uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, " "next_avail, expires, static, outbound_call_count, outbound_fail_count, hostname " - "from fifo_outbound where taking_calls = 1 and " - "(fifo_name = '%q') and (use_count < simo_count) and (next_avail = 0 or next_avail <= %ld) " - "order by next_avail", node->name, (long) switch_epoch_time_now(NULL)); + "from fifo_outbound " + "where taking_calls = 1 and (fifo_name = '%q') and (use_count < simo_count) and (next_avail = 0 or next_avail <= %ld) " + "order by next_avail ", + node->name, (long) switch_epoch_time_now(NULL) + ); + + switch(node->outbound_strategy) { case NODE_STRATEGY_ENTERPRISE: { int need = node_consumer_wait_count(node); + + if (node->outbound_per_cycle && node->outbound_per_cycle < need) { + need = node->outbound_per_cycle; + } + fifo_execute_sql_callback(globals.sql_mutex, sql, place_call_enterprise_callback, &need); } @@ -1032,6 +999,11 @@ static void find_consumers(fifo_node_t *node) cbh = switch_core_alloc(pool, sizeof(*cbh)); cbh->pool = pool; cbh->need = node_consumer_wait_count(node); + + if (node->outbound_per_cycle && node->outbound_per_cycle < cbh->need) { + cbh->need = node->outbound_per_cycle; + } + fifo_execute_sql_callback(globals.sql_mutex, sql, place_call_ringall_callback, cbh); switch_threadattr_create(&thd_attr, cbh->pool); @@ -1620,7 +1592,9 @@ SWITCH_STANDARD_APP(fifo_function) const char *url = NULL; const char *caller_uuid = NULL; switch_event_t *call_event; + const char *outbound_id = switch_channel_get_variable(channel, "fifo_outbound_uuid"); + if (!zstr(strat_str)) { if (!strcasecmp(strat_str, "more_ppl")) { strat = STRAT_MORE_PPL; @@ -1866,8 +1840,8 @@ SWITCH_STANDARD_APP(fifo_function) const char *o_announce = NULL; const char *record_template = switch_channel_get_variable(channel, "fifo_record_template"); char *expanded = NULL; - - + char *sql = NULL; + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); @@ -1921,7 +1895,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_core_session_rwunlock(other_session); break; } - + switch_channel_answer(channel); cloned_profile = switch_caller_profile_clone(other_session, switch_channel_get_caller_profile(channel)); switch_assert(cloned_profile); @@ -1966,7 +1940,44 @@ SWITCH_STANDARD_APP(fifo_function) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "bridge-caller"); switch_event_fire(&event); } + + if (outbound_id) { + sql = switch_mprintf("update fifo_outbound set use_count=use_count+1 where uuid='%s'", outbound_id); + + fifo_execute_sql(sql, globals.sql_mutex); + switch_safe_free(sql); + } + + sql = switch_mprintf("insert into fifo_bridge " + "(fifo_name,caller_uuid,caller_caller_id_name,caller_caller_id_number,consumer_uuid,consumer_outgoing_uuid,bridge_start) " + "values ('%q','%q','%q','%q','%q','%q',%ld)", + node->name, + switch_core_session_get_uuid(other_session), + switch_str_nil(switch_channel_get_variable(other_channel, "caller_id_name")), + switch_str_nil(switch_channel_get_variable(other_channel, "caller_id_number")), + switch_core_session_get_uuid(session), + switch_str_nil(outbound_id), + (long) switch_epoch_time_now(NULL) + ); + + + fifo_execute_sql(sql, globals.sql_mutex); + switch_safe_free(sql); + switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session); + + if (outbound_id) { + sql = switch_mprintf("update fifo_outbound set use_count=use_count-1 where uuid='%s' and use_count > 0", outbound_id); + + fifo_execute_sql(sql, globals.sql_mutex); + switch_safe_free(sql); + } + + sql = switch_mprintf("delete from fifo_bridge where consumer_uuid='%q'", switch_core_session_get_uuid(session)); + fifo_execute_sql(sql, globals.sql_mutex); + switch_safe_free(sql); + + switch_core_media_bug_pause(session); switch_core_media_bug_pause(other_session); @@ -2124,6 +2135,7 @@ struct xml_helper { char *container; char *tag; int cc_off; + int row_off; int verbose; }; @@ -2151,8 +2163,9 @@ static int xml_callback(void *pArg, int argc, char **argv, char **columnNames) x_tmp = switch_xml_add_child_d(h->xml, h->container, h->cc_off++); x_out = switch_xml_add_child_d(x_tmp, h->tag, c_off++); - switch_xml_set_attr_d(x_out, "timeout", argv[5]); switch_xml_set_attr_d(x_out, "simo", argv[3]); + switch_xml_set_attr_d(x_out, "use_count", argv[4]); + switch_xml_set_attr_d(x_out, "timeout", argv[5]); switch_xml_set_attr_d(x_out, "lag", argv[6]); switch_xml_set_attr_d(x_out, "outbound-call-count", argv[10]); switch_xml_set_attr_d(x_out, "outbound-fail-count", argv[11]); @@ -2167,7 +2180,7 @@ static int xml_callback(void *pArg, int argc, char **argv, char **columnNames) static int xml_outbound(switch_xml_t xml, fifo_node_t *node, char *container, char *tag, int cc_off, int verbose) { - struct xml_helper h; + struct xml_helper h = { 0 }; char *sql = switch_mprintf("select uuid, fifo_name, originate_string, simo_count, use_count, timeout, " "lag, next_avail, expires, static, outbound_call_count, outbound_fail_count, " "hostname, taking_calls, status from fifo_outbound where fifo_name = '%q'", node->name); @@ -2177,6 +2190,7 @@ static int xml_outbound(switch_xml_t xml, fifo_node_t *node, char *container, ch h.container = container; h.tag = tag; h.cc_off = cc_off; + h.row_off = 0; h.verbose = verbose; fifo_execute_sql_callback(globals.sql_mutex, sql, xml_callback, &h); @@ -2186,15 +2200,108 @@ static int xml_outbound(switch_xml_t xml, fifo_node_t *node, char *container, ch return h.cc_off; } + +static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + struct xml_helper *h = (struct xml_helper *) pArg; + switch_xml_t x_bridge, x_var, x_caller, x_consumer, x_cdr; + char exp_buf[128] = ""; + switch_time_exp_t tm; + switch_time_t etime = 0; + int off = 0, tag_off = 0; + switch_core_session_t *session; + char url_buf[512] = ""; + char *encoded; + + if ((etime = atol(argv[6]))) { + switch_size_t retsize; + + switch_time_exp_lt(&tm, switch_time_from_sec(etime)); + switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm); + } else { + switch_set_string(exp_buf, "now"); + } + + + x_bridge = switch_xml_add_child_d(h->xml, h->tag, h->row_off++); + + switch_xml_set_attr_d(x_bridge, "fifo_name", argv[0]); + switch_xml_set_attr_d(x_bridge, "bridge_start", exp_buf); + switch_xml_set_attr_d(x_bridge, "bridge_start_epoch", argv[6]); + + x_caller = switch_xml_add_child_d(x_bridge, "caller", tag_off++); + + switch_xml_set_attr_d(x_caller, "uuid", argv[1]); + + encoded = switch_url_encode(argv[2], url_buf, sizeof(url_buf)); + switch_xml_set_attr_d(x_caller, "caller_id_name", encoded); + + encoded = switch_url_encode(argv[3], url_buf, sizeof(url_buf)); + switch_xml_set_attr_d(x_caller, "caller_id_number", encoded); + + + + if (h->verbose) { + if ((session = switch_core_session_locate(argv[1]))) { + x_cdr = switch_xml_add_child_d(x_caller, "cdr", 0); + switch_ivr_generate_xml_cdr(session, &x_cdr); + switch_core_session_rwunlock(session); + } + } + + off = 0; + + x_consumer = switch_xml_add_child_d(x_bridge, "consumer", tag_off++); + + x_var = switch_xml_add_child_d(x_consumer, "uuid", off++); + switch_xml_set_txt_d(x_var, argv[4]); + x_var = switch_xml_add_child_d(x_consumer, "outgoing_uuid", off++); + switch_xml_set_txt_d(x_var, argv[5]); + + if (h->verbose) { + if ((session = switch_core_session_locate(argv[1]))) { + x_cdr = switch_xml_add_child_d(x_consumer, "cdr", 0); + switch_ivr_generate_xml_cdr(session, &x_cdr); + switch_core_session_rwunlock(session); + } + } + + return 0; +} + +static int xml_bridges(switch_xml_t xml, fifo_node_t *node, char *container, char *tag, int cc_off, int verbose) +{ + struct xml_helper h = { 0 }; + char *sql = switch_mprintf("select " + "fifo_name,caller_uuid,caller_caller_id_name,caller_caller_id_number,consumer_uuid,consumer_outgoing_uuid,bridge_start " + "from fifo_bridge where fifo_name = '%q'", node->name); + + h.xml = xml; + h.node = node; + h.container = container; + h.tag = tag; + h.cc_off = cc_off; + h.row_off = 0; + h.verbose = verbose; + + h.xml = switch_xml_add_child_d(h.xml, h.container, h.cc_off++); + + fifo_execute_sql_callback(globals.sql_mutex, sql, xml_bridge_callback, &h); + + switch_safe_free(sql); + + return h.cc_off; +} + static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char *tag, int cc_off, int verbose) { - switch_xml_t x_tmp, x_caller, x_cp, variables; + switch_xml_t x_tmp, x_caller, x_cp; switch_hash_index_t *hi; switch_core_session_t *session; switch_channel_t *channel; void *val; const void *var; - + x_tmp = switch_xml_add_child_d(xml, container, cc_off++); switch_assert(x_tmp); @@ -2202,6 +2309,8 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char int c_off = 0, d_off = 0; const char *status; const char *ts; + char url_buf[512] = ""; + char *encoded; switch_hash_this(hi, &var, NULL, &val); session = (switch_core_session_t *) val; @@ -2214,6 +2323,16 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char if ((status = switch_channel_get_variable(channel, "fifo_status"))) { switch_xml_set_attr_d(x_caller, "status", status); } + + if ((status = switch_channel_get_variable(channel, "caller_id_name"))) { + encoded = switch_url_encode(status, url_buf, sizeof(url_buf)); + switch_xml_set_attr_d(x_caller, "caller_id_name", encoded); + } + + if ((status = switch_channel_get_variable(channel, "caller_id_number"))) { + encoded = switch_url_encode(status, url_buf, sizeof(url_buf)); + switch_xml_set_attr_d(x_caller, "caller_id_number", encoded); + } if ((ts = switch_channel_get_variable(channel, "fifo_timestamp"))) { switch_xml_set_attr_d(x_caller, "timestamp", ts); @@ -2223,17 +2342,12 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char switch_xml_set_attr_d(x_caller, "target", ts); } - if (!(x_cp = switch_xml_add_child_d(x_caller, "caller_profile", d_off++))) { - abort(); - } if (verbose) { - d_off += switch_ivr_set_xml_profile_data(x_cp, switch_channel_get_caller_profile(channel), d_off); - - if (!(variables = switch_xml_add_child_d(x_caller, "variables", c_off++))) { + if (!(x_cp = switch_xml_add_child_d(x_caller, "cdr", d_off++))) { abort(); } - switch_ivr_set_xml_chan_vars(variables, channel, c_off); + switch_ivr_generate_xml_cdr(session, &x_cp); } } @@ -2243,7 +2357,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char *tag, int cc_off, int verbose) { - switch_xml_t x_tmp, x_caller, x_cp, variables; + switch_xml_t x_tmp, x_caller, x_cp; int i, x; switch_core_session_t *session; switch_channel_t *channel; @@ -2262,7 +2376,10 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char const char *status; const char *ts; const char *uuid = switch_event_get_header(q->data[i], "unique-id"); - + char sl[30] = ""; + char url_buf[512] = ""; + char *encoded; + if (!uuid) { continue; } @@ -2281,6 +2398,16 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char switch_xml_set_attr_d(x_caller, "status", status); } + if ((status = switch_channel_get_variable(channel, "caller_id_name"))) { + encoded = switch_url_encode(status, url_buf, sizeof(url_buf)); + switch_xml_set_attr_d(x_caller, "caller_id_name", encoded); + } + + if ((status = switch_channel_get_variable(channel, "caller_id_number"))) { + encoded = switch_url_encode(status, url_buf, sizeof(url_buf)); + switch_xml_set_attr_d(x_caller, "caller_id_number", encoded); + } + if ((ts = switch_channel_get_variable(channel, "fifo_timestamp"))) { switch_xml_set_attr_d(x_caller, "timestamp", ts); } @@ -2293,19 +2420,18 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char switch_xml_set_attr_d(x_caller, "position", ts); } - if (!(x_cp = switch_xml_add_child_d(x_caller, "caller_profile", d_off++))) { - abort(); - } - if (verbose) { - d_off += switch_ivr_set_xml_profile_data(x_cp, switch_channel_get_caller_profile(channel), d_off); + switch_snprintf(sl, sizeof(sl), "%d", x); + switch_xml_set_attr_d_buf(x_caller, "slot", sl); - if (!(variables = switch_xml_add_child_d(x_caller, "variables", c_off++))) { + + if (verbose) { + if (!(x_cp = switch_xml_add_child_d(x_caller, "cdr", d_off++))) { abort(); } - - switch_ivr_set_xml_chan_vars(variables, channel, c_off); + + switch_ivr_generate_xml_cdr(session, &x_cp); } - + switch_core_session_rwunlock(session); session = NULL; } @@ -2336,13 +2462,19 @@ static void list_node(fifo_node_t *node, switch_xml_t x_report, int *off, int ve switch_snprintf(tmp, sizeof(buffer), "%u", node->importance); switch_xml_set_attr_d(x_fifo, "importance", tmp); + switch_snprintf(tmp, sizeof(buffer), "%u", node->outbound_per_cycle); + switch_xml_set_attr_d(x_fifo, "outbound_per_cycle", tmp); + switch_xml_set_attr_d(x_fifo, "outbound_strategy", strat_parse(node->outbound_strategy)); cc_off = xml_outbound(x_fifo, node, "outbound", "member", cc_off, verbose); cc_off = xml_caller(x_fifo, node, "callers", "caller", cc_off, verbose); cc_off = xml_hash(x_fifo, node->consumer_hash, "consumers", "consumer", cc_off, verbose); + cc_off = xml_bridges(x_fifo, node, "bridges", "bridge", cc_off, verbose); } + + #define FIFO_API_SYNTAX "list|list_verbose|count|importance []|reparse [del_all]" SWITCH_STANDARD_API(fifo_api_function) { @@ -2495,6 +2627,19 @@ const char outbound_sql[] = ");\n"; +const char bridge_sql[] = + "create table fifo_bridge (\n" + " fifo_name varchar(1024) not null,\n" + " caller_uuid varchar(255) not null,\n" + " caller_caller_id_name varchar(255)," + " caller_caller_id_number varchar(255)," + + " consumer_uuid varchar(255) not null,\n" + " consumer_outgoing_uuid,\n" + " bridge_start integer\n" + ");\n" +; + static switch_status_t load_config(int reload, int del_all) { char *cf = "fifo.conf"; @@ -2553,6 +2698,7 @@ static switch_status_t load_config(int reload, int del_all) } switch_cache_db_test_reactive(dbh, "delete from fifo_outbound where static = 1 or taking_calls < 0", "drop table fifo_outbound", outbound_sql); + switch_cache_db_test_reactive(dbh, "delete from fifo_bridge", "drop table fifo_bridge", bridge_sql); switch_cache_db_release_db_handle(&dbh); if (reload) { @@ -2583,8 +2729,8 @@ static switch_status_t load_config(int reload, int del_all) if ((fifos = switch_xml_child(cfg, "fifos"))) { for (fifo = switch_xml_child(fifos, "fifo"); fifo; fifo = fifo->next) { const char *name, *outbound_strategy; - const char *importance; - int imp = 0; + const char *val; + int imp = 0, outbound_per_cycle = 0; int simo_i = 1; int timeout_i = 60; int lag_i = 10; @@ -2592,13 +2738,20 @@ static switch_status_t load_config(int reload, int del_all) name = switch_xml_attr(fifo, "name"); outbound_strategy = switch_xml_attr(fifo, "outbound_strategy"); + - if ((importance = switch_xml_attr(fifo, "importance"))) { - if ((imp = atoi(importance)) < 0) { + if ((val = switch_xml_attr(fifo, "importance"))) { + if ((imp = atoi(val)) < 0) { imp = 0; } } + if ((val = switch_xml_attr(fifo, "outbound_per_cycle"))) { + if ((outbound_per_cycle = atoi(val)) < 0) { + outbound_per_cycle = 0; + } + } + if (!name) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fifo has no name!\n"); continue; @@ -2614,6 +2767,9 @@ static switch_status_t load_config(int reload, int del_all) switch_mutex_lock(node->mutex); + node->outbound_per_cycle = outbound_per_cycle; + + if (outbound_strategy) { node->outbound_strategy = parse_strat(outbound_strategy); } From 182b030f946d1f5a16ae317cc9e60d0c8f1d0c4b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 16:57:21 -0500 Subject: [PATCH 07/43] fix sql --- src/mod/applications/mod_fifo/mod_fifo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index c6c9234c16..d08272c2f2 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -2631,11 +2631,11 @@ const char bridge_sql[] = "create table fifo_bridge (\n" " fifo_name varchar(1024) not null,\n" " caller_uuid varchar(255) not null,\n" - " caller_caller_id_name varchar(255)," - " caller_caller_id_number varchar(255)," + " caller_caller_id_name varchar(255),\n" + " caller_caller_id_number varchar(255),\n" " consumer_uuid varchar(255) not null,\n" - " consumer_outgoing_uuid,\n" + " consumer_outgoing_uuid varchar(255),\n" " bridge_start integer\n" ");\n" ; From 8009ec0b5c234db1f797088cbd31cb211a359483 Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 1 Jul 2010 18:14:44 -0500 Subject: [PATCH 08/43] FSBUILD-287 --- src/switch_event.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/switch_event.c b/src/switch_event.c index ed2b38466a..c2cbc7cb2e 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -581,7 +581,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool) { switch_threadattr_t *thd_attr;; - switch_assert(switch_arraylen(EVENT_NAMES) == SWITCH_EVENT_ALL + 1); + /* + This statement doesn't do anything commenting it out for now. + + switch_assert(switch_arraylen(EVENT_NAMES) == SWITCH_EVENT_ALL + 1); + */ + switch_assert(pool != NULL); THRUNTIME_POOL = RUNTIME_POOL = pool; From 1ed00b4dbd8cd09d4279eabb022190e18879fef4 Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 1 Jul 2010 18:15:51 -0500 Subject: [PATCH 09/43] cluecon --- configure.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/configure.in b/configure.in index f16d7f71b7..9a66386c2d 100644 --- a/configure.in +++ b/configure.in @@ -1002,6 +1002,25 @@ esac AC_OUTPUT +## +## Registering for ClueCon +## +echo "" +echo "" +echo $ECHO_N "Registering you for ClueCon http://www.cluecon.com $ECHO_C" 1>&6 +sleep 1 +echo $ECHO_N ".$ECHO_C" 1>&6 +sleep 1 +echo $ECHO_N ".$ECHO_C" 1>&6 +sleep 1 +echo $ECHO_N ".$ECHO_C" 1>&6 +sleep 1 +echo $ECHO_N ".$ECHO_C" 1>&6 +sleep 1 +AC_MSG_RESULT([ See you in August. ;-)]) +sleep 2 +echo "" + ## ## Configuration summary ## From 43cbb7eaa7f3b225fb5f2fea3dd83655df8621a5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 Jul 2010 22:14:07 -0500 Subject: [PATCH 10/43] stupid warning --- src/mod/applications/mod_fifo/mod_fifo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index d08272c2f2..830e30b184 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -2226,7 +2226,7 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN x_bridge = switch_xml_add_child_d(h->xml, h->tag, h->row_off++); switch_xml_set_attr_d(x_bridge, "fifo_name", argv[0]); - switch_xml_set_attr_d(x_bridge, "bridge_start", exp_buf); + switch_xml_set_attr_d_buf(x_bridge, "bridge_start", exp_buf); switch_xml_set_attr_d(x_bridge, "bridge_start_epoch", argv[6]); x_caller = switch_xml_add_child_d(x_bridge, "caller", tag_off++); From 611723454999c340d688312f7234df53b32a48d8 Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 1 Jul 2010 23:15:37 -0500 Subject: [PATCH 11/43] FSCORE-627 --- configure.in | 2 ++ src/mod/applications/mod_commands/mod_commands.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/configure.in b/configure.in index 9a66386c2d..b643d69d7a 100644 --- a/configure.in +++ b/configure.in @@ -1017,6 +1017,8 @@ echo $ECHO_N ".$ECHO_C" 1>&6 sleep 1 echo $ECHO_N ".$ECHO_C" 1>&6 sleep 1 +echo $ECHO_N ".$ECHO_C" 1>&6 +sleep 1 AC_MSG_RESULT([ See you in August. ;-)]) sleep 2 echo "" diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 9e0066191c..29d7d17140 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4507,6 +4507,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add complete del"); switch_console_set_complete("add db_cache status"); switch_console_set_complete("add fsctl debug_level"); + switch_console_set_complete("add fsctl last_sps"); switch_console_set_complete("add fsctl default_dtmf_duration"); switch_console_set_complete("add fsctl hupall"); switch_console_set_complete("add fsctl loglevel"); @@ -4524,6 +4525,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add fsctl pause"); switch_console_set_complete("add fsctl reclaim_mem"); switch_console_set_complete("add fsctl resume"); + switch_console_set_complete("add fsctl calibrate_clock"); + switch_console_set_complete("add fsctl crash"); + switch_console_set_complete("add fsctl verbose_events"); + switch_console_set_complete("add fsctl save_history"); + switch_console_set_complete("add fsctl shutdown_check"); switch_console_set_complete("add fsctl shutdown"); switch_console_set_complete("add fsctl shutdown asap"); switch_console_set_complete("add fsctl shutdown now"); From 4294d0a79dea3116936872a63717ad85179f7d09 Mon Sep 17 00:00:00 2001 From: Rupa Schomaker Date: Fri, 2 Jul 2010 00:03:13 -0500 Subject: [PATCH 12/43] if missing db.conf.xml don't fail, just use sqlite --- src/mod/applications/mod_db/mod_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_db/mod_db.c b/src/mod/applications/mod_db/mod_db.c index 6bf08a3c98..f0c1e6109c 100644 --- a/src/mod/applications/mod_db/mod_db.c +++ b/src/mod/applications/mod_db/mod_db.c @@ -292,7 +292,7 @@ static switch_status_t do_config() limit_config_dsn.pool = globals.pool; if (switch_xml_config_parse_module_settings("db.conf", SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_TERM; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "No config file found, defaulting to sqlite\n", DB_USAGE); } if (globals.odbc_dsn) { From 4e1d522198cc1cb7b4e766858fea950fbea75013 Mon Sep 17 00:00:00 2001 From: Rupa Schomaker Date: Fri, 2 Jul 2010 00:13:44 -0500 Subject: [PATCH 13/43] oops, compile fix --- src/mod/applications/mod_db/mod_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_db/mod_db.c b/src/mod/applications/mod_db/mod_db.c index f0c1e6109c..2678b4da38 100644 --- a/src/mod/applications/mod_db/mod_db.c +++ b/src/mod/applications/mod_db/mod_db.c @@ -292,7 +292,7 @@ static switch_status_t do_config() limit_config_dsn.pool = globals.pool; if (switch_xml_config_parse_module_settings("db.conf", SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "No config file found, defaulting to sqlite\n", DB_USAGE); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No config file found, defaulting to sqlite\n"); } if (globals.odbc_dsn) { From b10ea3c0b6558861c56b6047e984c9ff0931de17 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 2 Jul 2010 09:26:04 -0500 Subject: [PATCH 14/43] fifo tweaks --- src/mod/applications/mod_fifo/mod_fifo.c | 135 +++++++++++++++++++---- 1 file changed, 116 insertions(+), 19 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 830e30b184..6d70d2b53e 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -249,6 +249,7 @@ struct fifo_node { int busy; int is_static; int outbound_per_cycle; + char *outbound_name; outbound_strategy_t outbound_strategy; }; @@ -679,7 +680,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void int timeout = 0; switch_stream_handle_t stream = { 0 }; fifo_node_t *node = NULL; - char *originate_string; + char *originate_string = NULL; switch_event_t *ovars = NULL; switch_status_t status; switch_core_session_t *session = NULL; @@ -691,6 +692,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void switch_event_t *pop = NULL; fifo_queue_t *q = NULL; int x = 0; + switch_event_t *event; if (!cbh->rowcount) { goto end; @@ -737,7 +739,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void if (originate_string) { end_of(originate_string) = '\0'; } - + if (!timeout) timeout = 60; for (x = 0; x < MAX_PRI; x++) { @@ -774,28 +776,81 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void goto end; } - if ((caller_id_name = switch_event_get_header(pop, "caller-caller-id-name"))) { - switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_name", caller_id_name); + + if (!switch_event_get_header(ovars, "origination_caller_id_name")) { + if ((caller_id_name = switch_event_get_header(pop, "caller-caller-id-name"))) { + if (node->outbound_name) { + switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_name", "(%s) %s", node->outbound_name, caller_id_name); + } else { + switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_name", caller_id_name); + } + } } - if ((cid_num = switch_event_get_header(pop, "caller-caller-id-number"))) { - switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_number", cid_num); + if (!switch_event_get_header(ovars, "origination_caller_id_number")) { + if ((cid_num = switch_event_get_header(pop, "caller-caller-id-number"))) { + switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "origination_caller_id_number", cid_num); + } } - + if ((id = switch_event_get_header(pop, "unique-id"))) { switch_event_add_header_string(ovars, SWITCH_STACK_BOTTOM, "fifo_bridge_uuid", id); } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_core_session_t *session; + if (id && (session = switch_core_session_locate(id))) { + switch_channel_event_set_data(switch_core_session_get_channel(session), event); + switch_core_session_rwunlock(session); + } + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "pre-dial"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "ringall"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "caller-uuid", id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "originate_string", originate_string); + + for (i = 0; i < cbh->rowcount; i++) { + struct call_helper *h = cbh->rows[i]; + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); + } + + switch_event_fire(&event); + } + switch_mutex_unlock(q->mutex); status = switch_ivr_originate(NULL, &session, &cause, originate_string, timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL); - free(originate_string); - + if (status != SWITCH_STATUS_SUCCESS) { + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "post-dial"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "ringall"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "caller-uuid", id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "result", "failure"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "cause", switch_channel_cause2str(cause)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "originate_string", originate_string); + switch_event_fire(&event); + } goto end; } channel = switch_core_session_get_channel(session); + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "post-dial"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "ringall"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "caller-uuid", id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", switch_channel_get_variable(channel, "fifo_outbound_uuid")); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "result", "success"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "originate_string", originate_string); + switch_event_fire(&event); + } + + switch_channel_set_variable(channel, "fifo_pop_order", NULL); app_name = "fifo"; @@ -808,6 +863,8 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void end: + switch_safe_free(originate_string); + switch_event_destroy(&ovars); if (node) { switch_mutex_lock(node->mutex); @@ -831,11 +888,12 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_channel_t *channel; switch_call_cause_t cause = SWITCH_CAUSE_NONE; switch_caller_extension_t *extension = NULL; - char *app_name, *arg = NULL, *originate_string = NULL, *p = NULL; + char *app_name, *arg = NULL, *originate_string = NULL; const char *member_wait = NULL; fifo_node_t *node = NULL; switch_event_t *ovars = NULL; switch_status_t status = SWITCH_STATUS_FALSE; + switch_event_t *event = NULL; switch_mutex_lock(globals.mutex); node = switch_core_hash_find(globals.fifo_hash, h->node_name); @@ -856,28 +914,62 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'}%s", node->name, h->originate_string); } else { - char *name_dup = strdup(node->name); - if ((p = strchr(name_dup, '@'))) { - *p = '\0'; + if (node->outbound_name) { + originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'," + "origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s", + node->name, node->outbound_name, h->originate_string); + } else { + originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'," + "origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s", + node->name, node->name, h->originate_string); } - - originate_string = switch_mprintf("{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'," - "origination_caller_id_name=Queue,origination_caller_id_number='fifo+%q'}%s", - node->name, name_dup, h->originate_string); - free(name_dup); + } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "pre-dial"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "enterprise"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "originate_string", originate_string); + switch_event_fire(&event); + } + + status = switch_ivr_originate(NULL, &session, &cause, originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL); free(originate_string); if (status != SWITCH_STATUS_SUCCESS) { + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "post-dial"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "enterprise"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "result", "failure"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "cause", switch_channel_cause2str(cause)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "originate_string", originate_string); + switch_event_fire(&event); + } + goto end; } - channel = switch_core_session_get_channel(session); + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "post-dial"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Outbound-UUID", h->uuid); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "outbound-strategy", "enterprise"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "result", "success"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "originate_string", originate_string); + switch_event_fire(&event); + } + + if ((member_wait = switch_channel_get_variable(channel, "fifo_member_wait")) || (member_wait = switch_channel_get_variable(channel, "member_wait"))) { if (strcasecmp(member_wait, "wait") && strcasecmp(member_wait, "nowait")) { member_wait = NULL; @@ -2761,6 +2853,11 @@ static switch_status_t load_config(int reload, int del_all) if (!(node = switch_core_hash_find(globals.fifo_hash, name))) { node = create_node(name, imp, globals.sql_mutex); } + + if ((val = switch_xml_attr(fifo, "outbound_name"))) { + node->outbound_name = switch_core_strdup(node->pool, val); + } + switch_mutex_unlock(globals.mutex); switch_assert(node); From 4a924deb9112379e1981eb374f0dd352402e1552 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 2 Jul 2010 09:50:24 -0500 Subject: [PATCH 15/43] more tweaks for VS2010 --- .../FreeSwitchCore.2010.vcxproj.filters | 333 ++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 w32/Library/FreeSwitchCore.2010.vcxproj.filters diff --git a/w32/Library/FreeSwitchCore.2010.vcxproj.filters b/w32/Library/FreeSwitchCore.2010.vcxproj.filters new file mode 100644 index 0000000000..25fc9a136d --- /dev/null +++ b/w32/Library/FreeSwitchCore.2010.vcxproj.filters @@ -0,0 +1,333 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + + + {a2ba3786-6272-4d39-8004-9afeed96cdc6} + + + {a1474195-5783-4c77-977f-59657b38fd01} + + + \ No newline at end of file From 8c7a976252daa4b937cc1c043a1a81e8e3ebdfeb Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 2 Jul 2010 11:26:42 -0500 Subject: [PATCH 16/43] swigall --- .../languages/mod_managed/freeswitch_wrap.cxx | 46 +++++++++++++++++++ src/mod/languages/mod_managed/managed/swig.cs | 29 +++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 32228026a7..9b5d084b9f 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -10107,6 +10107,14 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_type_name(int jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_dismiss_db_handle(void * jarg1) { + switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; + + arg1 = (switch_cache_db_handle_t **)jarg1; + switch_cache_db_dismiss_db_handle(arg1); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_release_db_handle(void * jarg1) { switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; @@ -10720,6 +10728,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_is_moh(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strchr_strict(char * jarg1, char jarg2, char * jarg3) { + char * jresult ; + char *arg1 = (char *) 0 ; + char arg2 ; + char *arg3 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (char)jarg2; + arg3 = (char *)jarg3; + result = (char *)switch_strchr_strict((char const *)arg1,arg2,(char const *)arg3); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_string_has_escaped_data(char * jarg1) { int jresult ; char *arg1 = (char *) 0 ; @@ -24027,6 +24051,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_json(void * jarg1, char * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_brackets(char * jarg1, char jarg2, char jarg3, char jarg4, void * jarg5, void * jarg6) { + int jresult ; + char *arg1 = (char *) 0 ; + char arg2 ; + char arg3 ; + char arg4 ; + switch_event_t **arg5 = (switch_event_t **) 0 ; + char **arg6 = (char **) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char)jarg2; + arg3 = (char)jarg3; + arg4 = (char)jarg4; + arg5 = (switch_event_t **)jarg5; + arg6 = (char **)jarg6; + result = (switch_status_t)switch_event_create_brackets(arg1,arg2,arg3,arg4,arg5,arg6); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_running() { int jresult ; switch_status_t result; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 6fb37df01c..67bbe24d03 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -71,7 +71,8 @@ public class Api : IDisposable { namespace FreeSWITCH.Native { public enum cache_db_flag_t { - CDF_INUSE = (1 << 0) + CDF_INUSE = (1 << 0), + CDF_PRUNE = (1 << 1) } } @@ -2206,6 +2207,10 @@ public class freeswitch { return ret; } + public static void switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { + freeswitchPINVOKE.switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); + } + public static void switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { freeswitchPINVOKE.switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); } @@ -2427,6 +2432,11 @@ public class freeswitch { return ret; } + public static string switch_strchr_strict(string arg0, char find, string allowed) { + string ret = freeswitchPINVOKE.switch_strchr_strict(arg0, find, allowed); + return ret; + } + public static int switch_string_has_escaped_data(string arg0) { int ret = freeswitchPINVOKE.switch_string_has_escaped_data(arg0); return ret; @@ -3499,6 +3509,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_event_create_brackets(string data, char a, char b, char c, SWIGTYPE_p_p_switch_event arg4, ref string new_data) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_create_brackets(data, a, b, c, SWIGTYPE_p_p_switch_event.getCPtr(arg4), ref new_data); + return ret; + } + public static switch_status_t switch_event_running() { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_running(); return ret; @@ -7595,6 +7610,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_type_name")] public static extern string switch_cache_db_type_name(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_dismiss_db_handle")] + public static extern void switch_cache_db_dismiss_db_handle(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_release_db_handle")] public static extern void switch_cache_db_release_db_handle(HandleRef jarg1); @@ -7742,6 +7760,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_is_moh")] public static extern int switch_is_moh(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_strchr_strict")] + public static extern string switch_strchr_strict(string jarg1, char jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_string_has_escaped_data")] public static extern int switch_string_has_escaped_data(string jarg1); @@ -10928,6 +10949,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_create_json")] public static extern int switch_event_create_json(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_create_brackets")] + public static extern int switch_event_create_brackets(string jarg1, char jarg2, char jarg3, char jarg4, HandleRef jarg5, ref string jarg6); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_running")] public static extern int switch_event_running(); @@ -27547,7 +27571,8 @@ public enum switch_session_ctl_t { SCSC_SAVE_HISTORY, SCSC_CRASH, SCSC_MIN_IDLE_CPU, - SCSC_VERBOSE_EVENTS + SCSC_VERBOSE_EVENTS, + SCSC_SHUTDOWN_CHECK } } From 6c7970f9692e5db7ff0d6ad80312a3c74345467d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 2 Jul 2010 11:54:20 -0500 Subject: [PATCH 17/43] let bypass calls sit in park --- src/switch_ivr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index f42b28ff57..c66c1d1821 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -697,7 +697,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, return SWITCH_STATUS_FALSE; } - if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_get_state(channel) == CS_RESET) { + if (switch_channel_get_state(channel) == CS_RESET) { return SWITCH_STATUS_FALSE; } @@ -737,6 +737,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id); } else { switch_yield(20000); + + if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) { + switch_ivr_parse_event(session, event); + switch_event_destroy(&event); + } + status = SWITCH_STATUS_SUCCESS; } From a7d8f866fd79af7ba2230b19f55329d59ef6c34a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 2 Jul 2010 13:00:29 -0500 Subject: [PATCH 18/43] fix new util function to actually do what it says it will --- src/include/switch_utils.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 514f78d0d8..9c5f7202ac 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -105,16 +105,18 @@ static inline char *switch_strchr_strict(const char *in, char find, const char * while(p && *p) { const char *a = allowed; - int found = 0; + int acceptable = 0; + + if (*p == find) break; if (!a) { - found = 1; + acceptable = 1; } else { while(a && *a) { if (*p == *a) { - found = 1; + acceptable = 1; break; } @@ -123,9 +125,7 @@ static inline char *switch_strchr_strict(const char *in, char find, const char * } - if (!found) return NULL; - - if (*p == find) break; + if (!acceptable) return NULL; p++; } From 23fd8ebb3e59d299cf9ad66d60fff108e42894de Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 2 Jul 2010 13:31:12 -0500 Subject: [PATCH 19/43] add optional exceptions to mod_distributor to list nodes to skip --- .../mod_distributor/mod_distributor.c | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/mod/applications/mod_distributor/mod_distributor.c b/src/mod/applications/mod_distributor/mod_distributor.c index b0ff2d583a..f4070a9bc6 100644 --- a/src/mod/applications/mod_distributor/mod_distributor.c +++ b/src/mod/applications/mod_distributor/mod_distributor.c @@ -27,7 +27,7 @@ * Neal Horman * * - * mod_distributor.c -- Framework Demo Module + * mod_distributor.c -- Load distributor * */ #include @@ -240,14 +240,15 @@ static int reset_list(struct dist_list *list) return 0; } -static struct dist_node *find_next(struct dist_list *list) +static struct dist_node *find_next(struct dist_list *list, int etotal, char **exceptions) { struct dist_node *np, *match = NULL; int x = 0, mx = 0; int matches = 0, loops = 0; for (;;) { - + top: + if (++loops > 1000) { break; } @@ -259,7 +260,7 @@ static struct dist_node *find_next(struct dist_list *list) match = NULL; for (np = list->nodes; np; np = np->next) { if (np->cur_weight < list->target_weight) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s %d/%d\n", np->name, np->cur_weight, list->target_weight); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "%s %d/%d\n", np->name, np->cur_weight, list->target_weight); matches++; if (!match && x > list->last) { match = np; @@ -270,10 +271,23 @@ static struct dist_node *find_next(struct dist_list *list) } if (match) { + int i; + match->cur_weight++; list->lastnode = match; list->last = mx; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choose %s\n", match->name); + + for(i = 0; i < etotal; i++) { + if (!strcmp(match->name, exceptions[i])) { + if (matches == 1) { + reset_list(list); + } + goto top; + } + } + + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Choose %s\n", match->name); return match; } @@ -284,7 +298,7 @@ static struct dist_node *find_next(struct dist_list *list) } } - + return NULL; } @@ -294,11 +308,21 @@ static char *dist_engine(const char *name) struct dist_node *np = NULL; struct dist_list *lp; char *str = NULL; + char *myname = strdup(name); + char *except; + int argc = 0; + char *argv[100] = { 0 }; + + + if ((except = strchr(myname, ' '))) { + *except++ = '\0'; + argc = switch_split(except, ' ', argv); + } switch_mutex_lock(globals.mod_lock); for (lp = globals.list; lp; lp = lp->next) { - if (!strcasecmp(name, lp->name)) { - np = find_next(lp); + if (!strcasecmp(myname, lp->name)) { + np = find_next(lp, argc, argv); break; } } @@ -308,6 +332,8 @@ static char *dist_engine(const char *name) } switch_mutex_unlock(globals.mod_lock); + free(myname); + return str; } @@ -374,9 +400,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_distributor_load) load_config(SWITCH_FALSE); - SWITCH_ADD_API(api_interface, "distributor", "Distributor API", distributor_function, ""); + SWITCH_ADD_API(api_interface, "distributor", "Distributor API", distributor_function, "[ ]"); SWITCH_ADD_API(api_interface, "distributor_ctl", "Distributor API", distributor_ctl_function, "[reload]"); - SWITCH_ADD_APP(app_interface, "distributor", "Distributor APP", "Distributor APP", distributor_exec, "", + SWITCH_ADD_APP(app_interface, "distributor", "Distributor APP", "Distributor APP", distributor_exec, "[ ]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); From 0c826b1fc8ebd34e121a2bbb57e9890a351f97fa Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 2 Jul 2010 14:06:53 -0500 Subject: [PATCH 20/43] add sched_cancel function to cancel any impending sched_X funcs --- src/mod/applications/mod_dptools/mod_dptools.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index aba73df20c..ffffeefe6c 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -816,6 +816,17 @@ SWITCH_STANDARD_APP(deflect_function) switch_core_session_receive_message(session, &msg); } + +SWITCH_STANDARD_APP(sched_cancel_function) +{ + const char *group = data; + + if (zstr(group)) { + group = switch_core_session_get_uuid(session); + } + switch_scheduler_del_task_group(group); +} + SWITCH_STANDARD_APP(set_function) { char *var, *val = NULL; @@ -3300,6 +3311,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "send_dtmf", "Send dtmf to be sent", "Send dtmf to be sent from a session", send_dtmf_function, "", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "sched_cencel", "cancel scheduled tasks", "cancel scheduled tasks", sched_cancel_function, "[group]", + SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "sched_hangup", SCHED_HANGUP_DESCR, SCHED_HANGUP_DESCR, sched_hangup_function, "[+]