From 671e935d349b8cbafe0272bcef3f4b50ba4a18d0 Mon Sep 17 00:00:00 2001 From: William King Date: Sun, 25 Nov 2012 18:11:04 -0800 Subject: [PATCH 01/32] FS-4872: --resolve In the case of an event injected sms message that doesn't enable blocking mode the event would be queued up indefinately. --- src/mod/applications/mod_sms/mod_sms.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index 15d0de6233..9fd1d896da 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -43,6 +43,8 @@ static void event_handler(switch_event_t *event) { const char *dest_proto = switch_event_get_header(event, "dest_proto"); const char *check_failure = switch_event_get_header(event, "Delivery-Failure"); + const char *check_nonblocking = switch_event_get_header(event, "Nonblocking-Delivery"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "skip_global_process", "true"); if (switch_true(check_failure)) { @@ -54,6 +56,9 @@ static void event_handler(switch_event_t *event) } else if ( check_failure && switch_false(check_failure) ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS Delivery Success\n"); return; + } else if ( check_nonblocking && switch_true(check_nonblocking) ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS Delivery assumed successful due to being sent in non-blocking manner\n"); + return; } switch_core_chat_send(dest_proto, event); From 942e800be532b7e21a23093bc7379a45ffa6270c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 07:49:16 -0600 Subject: [PATCH 02/32] FS-4823 --resolve --- src/mod/endpoints/mod_sofia/sofia_reg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 2dbdeaf5a8..d2bea6e5ea 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -562,7 +562,8 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames switch_assert(dst); nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url), - SIPTAG_CALL_ID_STR(argv[0]), TAG_END()); + TAG_END()); + //SIPTAG_CALL_ID_STR(argv[0]), TAG_END()); nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_options(nh, NTATAG_SIP_T2(5000), From 44b4ab099577464f17c2fbaada192a8543b2a720 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 10:56:57 -0600 Subject: [PATCH 03/32] FS-4869 can you try this more centralized patch please --- src/switch_core_sqldb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index c8cdfe049e..3ad163b54e 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -152,7 +152,7 @@ static switch_cache_db_handle_t *get_handle(const char *db_str, const char *user if (!r) { for (dbh_ptr = sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->next) { - if (dbh_ptr->hash == hash && !dbh_ptr->use_count && !switch_test_flag(dbh_ptr, CDF_PRUNE) && + if (dbh_ptr->hash == hash && (dbh_ptr->type != SCDB_TYPE_PGSQL || !dbh_ptr->use_count) && !switch_test_flag(dbh_ptr, CDF_PRUNE) && switch_mutex_trylock(dbh_ptr->mutex) == SWITCH_STATUS_SUCCESS) { r = dbh_ptr; break; From a7f8e4259ee5b90c0bd9deb843480633ba1123a6 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Mon, 26 Nov 2012 14:26:41 -0500 Subject: [PATCH 04/32] OPENZAP-201 --resolve --- libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index 8abfce78df..2c6eda0295 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c @@ -779,6 +779,9 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) case FTDM_CHANNEL_STATE_GET_CALLERID: { memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Initializing cid data!\n"); + ftdm_set_string(ftdmchan->caller_data.ani.digits, "unknown"); + ftdm_set_string(ftdmchan->caller_data.cid_name, ftdmchan->caller_data.ani.digits); ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_CALLERID_DETECT, NULL); continue; } From 0b148a85b94be33fe70b692240e0d449a59f0ef2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 11:59:29 -0600 Subject: [PATCH 05/32] this breaks the auto rate hunting code in mod_sndfile --- src/mod/applications/mod_dptools/mod_dptools.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index d672e2a3db..0cee939286 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -4478,11 +4478,6 @@ static switch_status_t next_file(switch_file_handle_t *handle) } } - if (switch_file_exists(file, handle->memory_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File [%s] does not exist.\n", file); - goto top; - } - if (switch_core_file_open(&context->fh, file, handle->channels, handle->samplerate, handle->flags, NULL) != SWITCH_STATUS_SUCCESS) { goto top; } From c7c528cd7c8104622df97a1f4e7fdc59ba6a930e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 13:52:06 -0600 Subject: [PATCH 06/32] FS-4867 --resolve --- src/include/switch_channel.h | 4 ++++ src/switch_channel.c | 15 +++++++++++++++ src/switch_core_io.c | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index cd8cbb47f0..4225a9bd88 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -541,6 +541,10 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan \return number of digits in the queue */ SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(_In_ switch_channel_t *channel); +SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_lock(switch_channel_t *channel); +SWITCH_DECLARE(switch_status_t) switch_channel_try_dtmf_lock(switch_channel_t *channel); +SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_unlock(switch_channel_t *channel); + /*! \brief Queue DTMF on a given channel diff --git a/src/switch_channel.c b/src/switch_channel.c index 5fa30564d2..903bb6be76 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -363,6 +363,21 @@ SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, return SWITCH_STATUS_SUCCESS; } +SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_lock(switch_channel_t *channel) +{ + return switch_mutex_lock(channel->dtmf_mutex); +} + +SWITCH_DECLARE(switch_status_t) switch_channel_try_dtmf_lock(switch_channel_t *channel) +{ + return switch_mutex_trylock(channel->dtmf_mutex); +} + +SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_unlock(switch_channel_t *channel) +{ + return switch_mutex_unlock(channel->dtmf_mutex); +} + SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel) { switch_size_t has; diff --git a/src/switch_core_io.c b/src/switch_core_io.c index ba4874d81f..8e99fcd472 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -151,7 +151,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi for(i = 0; i < 2; i++) { if (session->dmachine[i] && !switch_channel_test_flag(session->channel, CF_BROADCAST)) { - switch_ivr_dmachine_ping(session->dmachine[i], NULL); + if (switch_channel_try_dtmf_lock(session->channel) == SWITCH_STATUS_SUCCESS) { + switch_ivr_dmachine_ping(session->dmachine[i], NULL); + switch_channel_dtmf_unlock(session->channel); + } } } From ff43048997191ca16b3ead85ac58d790c50e1b71 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 14:04:58 -0600 Subject: [PATCH 07/32] FS-4877 --resolve --- src/mod/endpoints/mod_sofia/sofia_presence.c | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 53b524a236..7bbb0c78ac 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -939,6 +939,17 @@ static void send_conference_data(sofia_profile_t *profile, switch_event_t *event } if (call_id) { + if (switch_true(final)) { + sql = switch_mprintf("update sip_subscriptions set expires=%ld where " + "hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q' " + "and call_id = '%q' ", + (long)0, + mod_sofia_globals.hostname, profile->name, + from_user, from_host, event_str, call_id); + + sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + } + sql = switch_mprintf("select full_to, full_from, contact %q ';_;isfocus', expires, call_id, event, network_ip, network_port, " "'%q' as ct,'%q' as pt " " from sip_subscriptions where " @@ -950,6 +961,16 @@ static void send_conference_data(sofia_profile_t *profile, switch_event_t *event mod_sofia_globals.hostname, profile->name, from_user, from_host, event_str, call_id); } else { + if (switch_true(final)) { + sql = switch_mprintf("update sip_subscriptions set expires=%ld where " + "hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q'", + (long)0, + mod_sofia_globals.hostname, profile->name, + from_user, from_host, event_str); + + sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + } + sql = switch_mprintf("select full_to, full_from, contact %q ';_;isfocus', expires, call_id, event, network_ip, network_port, " "'%q' as ct,'%q' as pt " " from sip_subscriptions where " From 428cd029decf824b1272612ef5af4e4953aaa547 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 15:18:58 -0600 Subject: [PATCH 08/32] FS-4868 --resolve This patch also adds freeswitch.ready() which will return false once shutdown has started --- src/include/switch_core.h | 2 + src/include/switch_cpp.h | 1 + .../src/org/freeswitch/swig/CoreSession.java | 2 +- .../src/org/freeswitch/swig/JavaSession.java | 4 + .../src/org/freeswitch/swig/freeswitch.java | 8 + .../org/freeswitch/swig/freeswitchJNI.java | 3 + .../languages/mod_java/switch_swig_wrap.cpp | 50 ++++ src/mod/languages/mod_lua/mod_lua_wrap.cpp | 19 ++ .../languages/mod_managed/freeswitch_wrap.cxx | 230 +++++++++++++++++- src/mod/languages/mod_managed/managed/swig.cs | 183 ++++++++++++-- src/mod/languages/mod_perl/freeswitch.pm | 1 + src/mod/languages/mod_perl/mod_perl_wrap.cpp | 19 ++ src/mod/languages/mod_python/freeswitch.py | 1 + .../languages/mod_python/mod_python_wrap.cpp | 14 ++ src/switch_core.c | 5 + src/switch_cpp.cpp | 5 + 16 files changed, 515 insertions(+), 32 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 210b676b1e..7b164af20a 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2042,6 +2042,8 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel); */ SWITCH_DECLARE(switch_bool_t) switch_core_ready(void); +SWITCH_DECLARE(switch_bool_t) switch_core_running(void); + /*! \brief Determines if the core is ready to take inbound calls \return SWITCH_TRUE or SWITCH_FALSE diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 83adac6867..8f50b70fe3 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -71,6 +71,7 @@ SWITCH_DECLARE(char *) getGlobalVariable(char *var_name); SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg); SWITCH_DECLARE(void) consoleCleanLog(char *msg); +SWITCH_DECLARE(bool) running(void); SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *body = NULL, char *file = NULL, char *convert_cmd = NULL, char *convert_ext = NULL); diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java index 5b192d350d..ca8c27b123 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java @@ -177,7 +177,7 @@ public class CoreSession { return freeswitchJNI.CoreSession_recordFile(swigCPtr, this, file_name, time_limit, silence_threshold, silence_hits); } - public int originate(CoreSession a_leg_session, String dest, int timeout, SWIGTYPE_p_switch_state_handler_table_t handlers) { + protected int originate(CoreSession a_leg_session, String dest, int timeout, SWIGTYPE_p_switch_state_handler_table_t handlers) { return freeswitchJNI.CoreSession_originate(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest, timeout, SWIGTYPE_p_switch_state_handler_table_t.getCPtr(handlers)); } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/JavaSession.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/JavaSession.java index f75f1cafee..b2bf611a4e 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/JavaSession.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/JavaSession.java @@ -69,4 +69,8 @@ public class JavaSession extends CoreSession { return new SWIGTYPE_p_switch_status_t(freeswitchJNI.JavaSession_run_dtmf_callback(swigCPtr, this, SWIGTYPE_p_void.getCPtr(input), SWIGTYPE_p_switch_input_type_t.getCPtr(itype)), true); } + public int originate(JavaSession aleg, String destination, int timeout) { + return freeswitchJNI.JavaSession_originate(swigCPtr, this, JavaSession.getCPtr(aleg), aleg, destination, timeout); + } + } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java index 7d832dbea0..48c03c2f10 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java @@ -25,6 +25,10 @@ public class freeswitch { freeswitchJNI.consoleCleanLog(msg); } + public static boolean running() { + return freeswitchJNI.running(); + } + public static boolean email(String to, String from, String headers, String body, String file, String convert_cmd, String convert_ext) { return freeswitchJNI.email(to, from, headers, body, file, convert_cmd, convert_ext); } @@ -62,4 +66,8 @@ public class freeswitch { return (cPtr == 0) ? null : new SWIGTYPE_p_JavaVM(cPtr, false); } + public static void setOriginateStateHandler(org.freeswitch.StateHandler stateHandler) throws java.util.TooManyListenersException { + freeswitchJNI.setOriginateStateHandler(stateHandler); + } + } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java index 40f856cb41..cc2f7f7cf7 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java @@ -13,6 +13,7 @@ class freeswitchJNI { public final static native String getGlobalVariable(String jarg1); public final static native void consoleLog(String jarg1, String jarg2); public final static native void consoleCleanLog(String jarg1); + public final static native boolean running(); public final static native boolean email(String jarg1, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6, String jarg7); public final static native long new_IVRMenu(long jarg1, IVRMenu jarg1_, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16); public final static native void delete_IVRMenu(long jarg1); @@ -162,6 +163,7 @@ class freeswitchJNI { public final static native long dtmf_callback(long jarg1, long jarg2, long jarg3, long jarg4, long jarg5); public final static native void javaVM_set(long jarg1); public final static native long javaVM_get(); + public final static native void setOriginateStateHandler(org.freeswitch.StateHandler jarg1) throws java.util.TooManyListenersException; public final static native long new_JavaSession__SWIG_0(); public final static native long new_JavaSession__SWIG_1(String jarg1); public final static native long new_JavaSession__SWIG_2(long jarg1); @@ -172,5 +174,6 @@ class freeswitchJNI { public final static native void JavaSession_setHangupHook(long jarg1, JavaSession jarg1_, org.freeswitch.HangupHook jarg2); public final static native void JavaSession_check_hangup_hook(long jarg1, JavaSession jarg1_); public final static native long JavaSession_run_dtmf_callback(long jarg1, JavaSession jarg1_, long jarg2, long jarg3); + public final static native int JavaSession_originate(long jarg1, JavaSession jarg1_, long jarg2, JavaSession jarg2_, String jarg3, int jarg4); public final static native long SWIGJavaSessionUpcast(long jarg1); } diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index 93499b61ab..83ddb6db02 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -199,6 +199,7 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else +#include "switch.h" #include "switch_cpp.h" #include "freeswitch_java.h" @@ -286,6 +287,18 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_consoleCleanLog(J } +SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_running(JNIEnv *jenv, jclass jcls) { + jboolean jresult = 0 ; + bool result; + + (void)jenv; + (void)jcls; + result = (bool)running(); + jresult = (jboolean)result; + return jresult; +} + + SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_email(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6, jstring jarg7) { jboolean jresult = 0 ; char *arg1 = (char *) 0 ; @@ -3176,6 +3189,16 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_javaVM_1get(JNIE } +SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_setOriginateStateHandler(JNIEnv *jenv, jclass jcls, jobject jarg1) { + jobject arg1 ; + + (void)jenv; + (void)jcls; + arg1 = jarg1; + setOriginateStateHandler(arg1); +} + + SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1JavaSession_1_1SWIG_10(JNIEnv *jenv, jclass jcls) { jlong jresult = 0 ; JavaSession *result = 0 ; @@ -3331,6 +3354,33 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_JavaSession_1run } +SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_JavaSession_1originate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jstring jarg3, jint jarg4) { + jint jresult = 0 ; + JavaSession *arg1 = (JavaSession *) 0 ; + JavaSession *arg2 = (JavaSession *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + int result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + (void)jarg2_; + arg1 = *(JavaSession **)&jarg1; + arg2 = *(JavaSession **)&jarg2; + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + arg4 = (int)jarg4; + result = (int)(arg1)->originate(arg2,arg3,arg4); + jresult = (jint)result; + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + return jresult; +} + + SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_SWIGJavaSessionUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { jlong baseptr = 0; (void)jenv; diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index 679b852a81..3f9ad57fb5 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -1627,6 +1627,24 @@ fail: } +static int _wrap_running(lua_State* L) { + int SWIG_arg = -1; + bool result; + + SWIG_check_num_args("running",0,0) + result = (bool)running(); + SWIG_arg=0; + lua_pushboolean(L,(int)(result==true)); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_email(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) 0 ; @@ -7774,6 +7792,7 @@ static const struct luaL_reg swig_commands[] = { { "getGlobalVariable", _wrap_getGlobalVariable}, { "consoleLog", _wrap_consoleLog}, { "consoleCleanLog", _wrap_consoleCleanLog}, + { "running", _wrap_running}, { "email", _wrap_email}, { "console_log", _wrap_console_log}, { "console_clean_log", _wrap_console_clean_log}, diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index a1fed17362..4f885e481b 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -1267,6 +1267,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VA } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "execute_on_pre_originate"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1344,6 +1355,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIAB } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "api_on_pre_originate"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1982,6 +2004,17 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_DTMF_LOG_LEN_get() { } +SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_TRANS_get() { + int jresult ; + int result; + + result = (int) 2000; + + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_digit_set(void * jarg1, char jarg2) { switch_dtmf_t *arg1 = (switch_dtmf_t *) 0 ; char arg2 ; @@ -2801,6 +2834,36 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_directories_sounds_dir_get(void * ja } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_lib_dir_set(void * jarg1, char * jarg2) { + switch_directories *arg1 = (switch_directories *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_directories *)jarg1; + arg2 = (char *)jarg2; + { + if (arg1->lib_dir) delete [] arg1->lib_dir; + if (arg2) { + arg1->lib_dir = (char *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->lib_dir, (const char *)arg2); + } else { + arg1->lib_dir = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_directories_lib_dir_get(void * jarg1) { + char * jresult ; + switch_directories *arg1 = (switch_directories *) 0 ; + char *result = 0 ; + + arg1 = (switch_directories *)jarg1; + result = (char *) ((arg1)->lib_dir); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_directories() { void * jresult ; switch_directories *result = 0 ; @@ -8237,6 +8300,18 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_channel(void * jarg } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_mutex(void * jarg1) { + void * jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_mutex_t *result = 0 ; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_mutex_t *)switch_core_session_get_mutex(arg1); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_wake_session_thread(void * jarg1) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -8535,15 +8610,21 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_hupall(int jarg1) { } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_hupall_matching_var(char * jarg1, char * jarg2, int jarg3) { +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_session_hupall_matching_var_ans(char * jarg1, char * jarg2, int jarg3, int jarg4) { + unsigned long jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; switch_call_cause_t arg3 ; + switch_hup_type_t arg4 ; + uint32_t result; arg1 = (char *)jarg1; arg2 = (char *)jarg2; arg3 = (switch_call_cause_t)jarg3; - switch_core_session_hupall_matching_var((char const *)arg1,(char const *)arg2,arg3); + arg4 = (switch_hup_type_t)jarg4; + result = (uint32_t)switch_core_session_hupall_matching_var_ans((char const *)arg1,(char const *)arg2,arg3,arg4); + jresult = (unsigned long)result; + return jresult; } @@ -10712,6 +10793,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_ready() { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_running() { + int jresult ; + switch_bool_t result; + + result = (switch_bool_t)switch_core_running(); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_ready_inbound() { int jresult ; switch_bool_t result; @@ -11390,13 +11481,13 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_preprocess_session(void * jarg1, ch } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_stop_thread() { - switch_core_sqldb_stop_thread(); +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_pause() { + switch_core_sqldb_pause(); } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_start_thread() { - switch_core_sqldb_start_thread(); +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_resume() { + switch_core_sqldb_resume(); } @@ -12324,6 +12415,20 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_flush(char * jarg1, char } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_sql_queue_manager_size(void * jarg1, unsigned long jarg2) { + int jresult ; + switch_sql_queue_manager_t *arg1 = (switch_sql_queue_manager_t *) 0 ; + uint32_t arg2 ; + int result; + + arg1 = (switch_sql_queue_manager_t *)jarg1; + arg2 = (uint32_t)jarg2; + result = (int)switch_sql_queue_manager_size(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_sql_queue_manager_push_confirm(void * jarg1, char * jarg2, unsigned long jarg3, int jarg4) { int jresult ; switch_sql_queue_manager_t *arg1 = (switch_sql_queue_manager_t *) 0 ; @@ -12372,27 +12477,29 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_sql_queue_manager_destroy(void * jarg1) } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_sql_queue_manager_init_name(char * jarg1, void * jarg2, unsigned long jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_sql_queue_manager_init_name(char * jarg1, void * jarg2, unsigned long jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8, char * jarg9) { int jresult ; char *arg1 = (char *) 0 ; switch_sql_queue_manager_t **arg2 = (switch_sql_queue_manager_t **) 0 ; uint32_t arg3 ; char *arg4 = (char *) 0 ; - char *arg5 = (char *) 0 ; + uint32_t arg5 ; char *arg6 = (char *) 0 ; char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; + char *arg9 = (char *) 0 ; switch_status_t result; arg1 = (char *)jarg1; arg2 = (switch_sql_queue_manager_t **)jarg2; arg3 = (uint32_t)jarg3; arg4 = (char *)jarg4; - arg5 = (char *)jarg5; + arg5 = (uint32_t)jarg5; arg6 = (char *)jarg6; arg7 = (char *)jarg7; arg8 = (char *)jarg8; - result = (switch_status_t)switch_sql_queue_manager_init_name((char const *)arg1,arg2,arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + arg9 = (char *)jarg9; + result = (switch_status_t)switch_sql_queue_manager_init_name((char const *)arg1,arg2,arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8,(char const *)arg9); jresult = result; return jresult; } @@ -23976,6 +24083,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_codec_session_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_codec_cur_frame_set(void * jarg1, void * jarg2) { + switch_codec *arg1 = (switch_codec *) 0 ; + switch_frame_t *arg2 = (switch_frame_t *) 0 ; + + arg1 = (switch_codec *)jarg1; + arg2 = (switch_frame_t *)jarg2; + if (arg1) (arg1)->cur_frame = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_codec_cur_frame_get(void * jarg1) { + void * jresult ; + switch_codec *arg1 = (switch_codec *) 0 ; + switch_frame_t *result = 0 ; + + arg1 = (switch_codec *)jarg1; + result = (switch_frame_t *) ((arg1)->cur_frame); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_codec() { void * jresult ; switch_codec *result = 0 ; @@ -27217,6 +27347,42 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_has_dtmf(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_dtmf_lock(void * jarg1) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_status_t result; + + arg1 = (switch_channel_t *)jarg1; + result = (switch_status_t)switch_channel_dtmf_lock(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_try_dtmf_lock(void * jarg1) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_status_t result; + + arg1 = (switch_channel_t *)jarg1; + result = (switch_status_t)switch_channel_try_dtmf_lock(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_dtmf_unlock(void * jarg1) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_status_t result; + + arg1 = (switch_channel_t *)jarg1; + result = (switch_status_t)switch_channel_dtmf_unlock(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_queue_dtmf(void * jarg1, void * jarg2) { int jresult ; switch_channel_t *arg1 = (switch_channel_t *) 0 ; @@ -27691,6 +27857,22 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_hold_record(void * jarg1 } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_state_thread_lock(void * jarg1) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + + arg1 = (switch_channel_t *)jarg1; + switch_channel_state_thread_lock(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_state_thread_unlock(void * jarg1) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + + arg1 = (switch_channel_t *)jarg1; + switch_channel_state_thread_unlock(arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg2, void * jarg3) { int jresult ; switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ; @@ -32155,6 +32337,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_uuid_exists(char * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_uuid_force_exists(char * jarg1) { + int jresult ; + char *arg1 = (char *) 0 ; + switch_bool_t result; + + arg1 = (char *)jarg1; + result = (switch_bool_t)switch_ivr_uuid_force_exists((char const *)arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_dmachine_last_ping(void * jarg1) { int jresult ; switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ; @@ -35117,15 +35311,17 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_xml_parse_section_string(char } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_xml_std_datetime_check(void * jarg1, void * jarg2) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_xml_std_datetime_check(void * jarg1, void * jarg2, char * jarg3) { int jresult ; switch_xml_t arg1 = (switch_xml_t) 0 ; int *arg2 = (int *) 0 ; + char *arg3 = (char *) 0 ; int result; arg1 = (switch_xml_t)jarg1; arg2 = (int *)jarg2; - result = (int)switch_xml_std_datetime_check(arg1,arg2); + arg3 = (char *)jarg3; + result = (int)switch_xml_std_datetime_check(arg1,arg2,(char const *)arg3); jresult = result; return jresult; } @@ -37107,6 +37303,16 @@ SWIGEXPORT void SWIGSTDCALL CSharp_consoleCleanLog(char * jarg1) { } +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_running() { + unsigned int jresult ; + bool result; + + result = (bool)running(); + jresult = result; + return jresult; +} + + SWIGEXPORT unsigned int SWIGSTDCALL CSharp_email(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7) { unsigned int jresult ; char *arg1 = (char *) 0 ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index e3eea0582d..e560b2046c 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -1473,6 +1473,12 @@ public class freeswitch { return ret; } + public static SWIGTYPE_p_switch_mutex_t switch_core_session_get_mutex(SWIGTYPE_p_switch_core_session session) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_mutex(SWIGTYPE_p_switch_core_session.getCPtr(session)); + SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); + return ret; + } + public static switch_status_t switch_core_session_wake_session_thread(SWIGTYPE_p_switch_core_session session) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_wake_session_thread(SWIGTYPE_p_switch_core_session.getCPtr(session)); return ret; @@ -1594,8 +1600,9 @@ public class freeswitch { freeswitchPINVOKE.switch_core_session_hupall((int)cause); } - public static void switch_core_session_hupall_matching_var(string var_name, string var_val, switch_call_cause_t cause) { - freeswitchPINVOKE.switch_core_session_hupall_matching_var(var_name, var_val, (int)cause); + public static uint switch_core_session_hupall_matching_var_ans(string var_name, string var_val, switch_call_cause_t cause, switch_hup_type_t type) { + uint ret = freeswitchPINVOKE.switch_core_session_hupall_matching_var_ans(var_name, var_val, (int)cause, (int)type); + return ret; } public static switch_console_callback_match switch_core_session_findall_matching_var(string var_name, string var_val) { @@ -2344,6 +2351,11 @@ public class freeswitch { return ret; } + public static switch_bool_t switch_core_running() { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_core_running(); + return ret; + } + public static switch_bool_t switch_core_ready_inbound() { switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_core_ready_inbound(); return ret; @@ -2630,12 +2642,12 @@ public class freeswitch { return ret; } - public static void switch_core_sqldb_stop_thread() { - freeswitchPINVOKE.switch_core_sqldb_stop_thread(); + public static void switch_core_sqldb_pause() { + freeswitchPINVOKE.switch_core_sqldb_pause(); } - public static void switch_core_sqldb_start_thread() { - freeswitchPINVOKE.switch_core_sqldb_start_thread(); + public static void switch_core_sqldb_resume() { + freeswitchPINVOKE.switch_core_sqldb_resume(); } public static string switch_cache_db_type_name(switch_cache_db_handle_type_t type) { @@ -2830,6 +2842,11 @@ public class freeswitch { freeswitchPINVOKE.switch_core_recovery_flush(technology, profile_name); } + public static int switch_sql_queue_manager_size(SWIGTYPE_p_switch_sql_queue_manager qm, uint index) { + int ret = freeswitchPINVOKE.switch_sql_queue_manager_size(SWIGTYPE_p_switch_sql_queue_manager.getCPtr(qm), index); + return ret; + } + public static switch_status_t switch_sql_queue_manager_push_confirm(SWIGTYPE_p_switch_sql_queue_manager qm, string sql, uint pos, switch_bool_t dup) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_sql_queue_manager_push_confirm(SWIGTYPE_p_switch_sql_queue_manager.getCPtr(qm), sql, pos, (int)dup); return ret; @@ -2845,8 +2862,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_sql_queue_manager_init_name(string name, SWIGTYPE_p_p_switch_sql_queue_manager qmp, uint numq, string dsn, string pre_trans_execute, string post_trans_execute, string inner_pre_trans_execute, string inner_post_trans_execute) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_sql_queue_manager_init_name(name, SWIGTYPE_p_p_switch_sql_queue_manager.getCPtr(qmp), numq, dsn, pre_trans_execute, post_trans_execute, inner_pre_trans_execute, inner_post_trans_execute); + public static switch_status_t switch_sql_queue_manager_init_name(string name, SWIGTYPE_p_p_switch_sql_queue_manager qmp, uint numq, string dsn, uint max_trans, string pre_trans_execute, string post_trans_execute, string inner_pre_trans_execute, string inner_post_trans_execute) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_sql_queue_manager_init_name(name, SWIGTYPE_p_p_switch_sql_queue_manager.getCPtr(qmp), numq, dsn, max_trans, pre_trans_execute, post_trans_execute, inner_pre_trans_execute, inner_post_trans_execute); return ret; } @@ -4103,6 +4120,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_channel_dtmf_lock(SWIGTYPE_p_switch_channel channel) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_dtmf_lock(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + + public static switch_status_t switch_channel_try_dtmf_lock(SWIGTYPE_p_switch_channel channel) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_try_dtmf_lock(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + + public static switch_status_t switch_channel_dtmf_unlock(SWIGTYPE_p_switch_channel channel) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_dtmf_unlock(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + public static switch_status_t switch_channel_queue_dtmf(SWIGTYPE_p_switch_channel channel, switch_dtmf_t dtmf) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_queue_dtmf(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_dtmf_t.getCPtr(dtmf)); return ret; @@ -4283,6 +4315,14 @@ public class freeswitch { return ret; } + public static void switch_channel_state_thread_lock(SWIGTYPE_p_switch_channel channel) { + freeswitchPINVOKE.switch_channel_state_thread_lock(SWIGTYPE_p_switch_channel.getCPtr(channel)); + } + + public static void switch_channel_state_thread_unlock(SWIGTYPE_p_switch_channel channel) { + freeswitchPINVOKE.switch_channel_state_thread_unlock(SWIGTYPE_p_switch_channel.getCPtr(channel)); + } + public static switch_status_t switch_buffer_create(SWIGTYPE_p_apr_pool_t pool, SWIGTYPE_p_p_switch_buffer buffer, SWIGTYPE_p_switch_size_t max_len) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_buffer_create(SWIGTYPE_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_p_switch_buffer.getCPtr(buffer), SWIGTYPE_p_switch_size_t.getCPtr(max_len)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -5228,6 +5268,11 @@ public class freeswitch { return ret; } + public static switch_bool_t switch_ivr_uuid_force_exists(string uuid) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_ivr_uuid_force_exists(uuid); + return ret; + } + public static switch_status_t switch_ivr_dmachine_last_ping(SWIGTYPE_p_switch_ivr_dmachine dmachine) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_dmachine_last_ping(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine)); return ret; @@ -5984,8 +6029,8 @@ public class freeswitch { return ret; } - public static int switch_xml_std_datetime_check(switch_xml xcond, SWIGTYPE_p_int offset) { - int ret = freeswitchPINVOKE.switch_xml_std_datetime_check(switch_xml.getCPtr(xcond), SWIGTYPE_p_int.getCPtr(offset)); + public static int switch_xml_std_datetime_check(switch_xml xcond, SWIGTYPE_p_int offset, string tzname) { + int ret = freeswitchPINVOKE.switch_xml_std_datetime_check(switch_xml.getCPtr(xcond), SWIGTYPE_p_int.getCPtr(offset), tzname); return ret; } @@ -6169,6 +6214,11 @@ public class freeswitch { freeswitchPINVOKE.consoleCleanLog(msg); } + public static bool running() { + bool ret = freeswitchPINVOKE.running(); + return ret; + } + public static bool email(string to, string from, string headers, string body, string file, string convert_cmd, string convert_ext) { bool ret = freeswitchPINVOKE.email(to, from, headers, body, file, convert_cmd, convert_ext); return ret; @@ -6289,6 +6339,7 @@ public class freeswitch { public static readonly string SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get(); + public static readonly string SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE_get(); @@ -6296,6 +6347,7 @@ public class freeswitch { public static readonly string SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get(); + public static readonly string SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CALL_TIMEOUT_VARIABLE = freeswitchPINVOKE.SWITCH_CALL_TIMEOUT_VARIABLE_get(); public static readonly string SWITCH_HOLDING_UUID_VARIABLE = freeswitchPINVOKE.SWITCH_HOLDING_UUID_VARIABLE_get(); public static readonly string SWITCH_SOFT_HOLDING_UUID_VARIABLE = freeswitchPINVOKE.SWITCH_SOFT_HOLDING_UUID_VARIABLE_get(); @@ -6354,6 +6406,7 @@ public class freeswitch { public static readonly int SWITCH_BITS_PER_BYTE = freeswitchPINVOKE.SWITCH_BITS_PER_BYTE_get(); public static readonly int SWITCH_DEFAULT_FILE_BUFFER_LEN = freeswitchPINVOKE.SWITCH_DEFAULT_FILE_BUFFER_LEN_get(); public static readonly int SWITCH_DTMF_LOG_LEN = freeswitchPINVOKE.SWITCH_DTMF_LOG_LEN_get(); + public static readonly int SWITCH_MAX_TRANS = freeswitchPINVOKE.SWITCH_MAX_TRANS_get(); public static readonly int SWITCH_MAX_STACKS = freeswitchPINVOKE.SWITCH_MAX_STACKS_get(); public static readonly int SWITCH_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_THREAD_STACKSIZE_get(); public static readonly int SWITCH_SYSTEM_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_SYSTEM_THREAD_STACKSIZE_get(); @@ -6868,6 +6921,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get")] public static extern string SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE_get")] + public static extern string SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get")] public static extern string SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get(); @@ -6889,6 +6945,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get")] public static extern string SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABLE_get")] + public static extern string SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get")] public static extern string SWITCH_CALL_TIMEOUT_VARIABLE_get(); @@ -7063,6 +7122,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_DTMF_LOG_LEN_get")] public static extern int SWITCH_DTMF_LOG_LEN_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_MAX_TRANS_get")] + public static extern int SWITCH_MAX_TRANS_get(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_digit_set")] public static extern void switch_dtmf_t_digit_set(HandleRef jarg1, char jarg2); @@ -7255,6 +7317,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_directories_sounds_dir_get")] public static extern string switch_directories_sounds_dir_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_directories_lib_dir_set")] + public static extern void switch_directories_lib_dir_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_directories_lib_dir_get")] + public static extern string switch_directories_lib_dir_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_directories")] public static extern IntPtr new_switch_directories(); @@ -8575,6 +8643,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_channel")] public static extern IntPtr switch_core_session_get_channel(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_mutex")] + public static extern IntPtr switch_core_session_get_mutex(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_wake_session_thread")] public static extern int switch_core_session_wake_session_thread(HandleRef jarg1); @@ -8650,8 +8721,8 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_hupall")] public static extern void switch_core_session_hupall(int jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_hupall_matching_var")] - public static extern void switch_core_session_hupall_matching_var(string jarg1, string jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_hupall_matching_var_ans")] + public static extern uint switch_core_session_hupall_matching_var_ans(string jarg1, string jarg2, int jarg3, int jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_findall_matching_var")] public static extern IntPtr switch_core_session_findall_matching_var(string jarg1, string jarg2); @@ -9103,6 +9174,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_ready")] public static extern int switch_core_ready(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_running")] + public static extern int switch_core_running(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_ready_inbound")] public static extern int switch_core_ready_inbound(); @@ -9280,11 +9354,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_preprocess_session")] public static extern int switch_ivr_preprocess_session(HandleRef jarg1, string jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_stop_thread")] - public static extern void switch_core_sqldb_stop_thread(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_pause")] + public static extern void switch_core_sqldb_pause(); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_start_thread")] - public static extern void switch_core_sqldb_start_thread(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_resume")] + public static extern void switch_core_sqldb_resume(); [DllImport("mod_managed", EntryPoint="CSharp_CACHE_DB_LEN_get")] public static extern int CACHE_DB_LEN_get(); @@ -9508,6 +9582,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_flush")] public static extern void switch_core_recovery_flush(string jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_sql_queue_manager_size")] + public static extern int switch_sql_queue_manager_size(HandleRef jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_sql_queue_manager_push_confirm")] public static extern int switch_sql_queue_manager_push_confirm(HandleRef jarg1, string jarg2, uint jarg3, int jarg4); @@ -9518,7 +9595,7 @@ class freeswitchPINVOKE { public static extern int switch_sql_queue_manager_destroy(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_sql_queue_manager_init_name")] - public static extern int switch_sql_queue_manager_init_name(string jarg1, HandleRef jarg2, uint jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8); + public static extern int switch_sql_queue_manager_init_name(string jarg1, HandleRef jarg2, uint jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8, string jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_sql_queue_manager_start")] public static extern int switch_sql_queue_manager_start(HandleRef jarg1); @@ -12313,6 +12390,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_codec_session_get")] public static extern IntPtr switch_codec_session_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_codec_cur_frame_set")] + public static extern void switch_codec_cur_frame_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_codec_cur_frame_get")] + public static extern IntPtr switch_codec_cur_frame_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_codec")] public static extern IntPtr new_switch_codec(); @@ -13078,6 +13161,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_has_dtmf")] public static extern IntPtr switch_channel_has_dtmf(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_dtmf_lock")] + public static extern int switch_channel_dtmf_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_try_dtmf_lock")] + public static extern int switch_channel_try_dtmf_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_dtmf_unlock")] + public static extern int switch_channel_dtmf_unlock(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_queue_dtmf")] public static extern int switch_channel_queue_dtmf(HandleRef jarg1, HandleRef jarg2); @@ -13192,6 +13284,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_hold_record")] public static extern IntPtr switch_channel_get_hold_record(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_state_thread_lock")] + public static extern void switch_channel_state_thread_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_state_thread_unlock")] + public static extern void switch_channel_state_thread_unlock(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_buffer_create")] public static extern int switch_buffer_create(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); @@ -14101,6 +14199,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_uuid_exists")] public static extern int switch_ivr_uuid_exists(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_uuid_force_exists")] + public static extern int switch_ivr_uuid_force_exists(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_last_ping")] public static extern int switch_ivr_dmachine_last_ping(HandleRef jarg1); @@ -14762,7 +14863,7 @@ class freeswitchPINVOKE { public static extern uint switch_xml_parse_section_string(string jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_xml_std_datetime_check")] - public static extern int switch_xml_std_datetime_check(HandleRef jarg1, HandleRef jarg2); + public static extern int switch_xml_std_datetime_check(HandleRef jarg1, HandleRef jarg2, string jarg3); [DllImport("mod_managed", EntryPoint="CSharp_switch_xml_locate_language")] public static extern int switch_xml_locate_language(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4, HandleRef jarg5, HandleRef jarg6, string jarg7); @@ -15271,6 +15372,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_consoleCleanLog")] public static extern void consoleCleanLog(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_running")] + public static extern bool running(); + [DllImport("mod_managed", EntryPoint="CSharp_email")] public static extern bool email(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7); @@ -21736,7 +21840,8 @@ namespace FreeSWITCH.Native { SAF_SUPPORT_NOMEDIA = (1 << 0), SAF_ROUTING_EXEC = (1 << 1), SAF_MEDIA_TAP = (1 << 2), - SAF_ZOMBIE_EXEC = (1 << 3) + SAF_ZOMBIE_EXEC = (1 << 3), + SAF_NO_LOOPBACK = (1 << 4) } } @@ -24116,6 +24221,7 @@ public enum switch_channel_flag_t { CF_OUTBOUND, CF_EARLY_MEDIA, CF_BRIDGE_ORIGINATOR, + CF_UUID_BRIDGE_ORIGINATOR, CF_TRANSFER, CF_ACCEPT_CNG, CF_REDIRECT, @@ -24197,6 +24303,7 @@ public enum switch_channel_flag_t { CF_NO_CDR, CF_EARLY_OK, CF_MEDIA_TRANS, + CF_HOLD_ON_BRIDGE, CF_FLAG_MAX } @@ -24876,6 +24983,17 @@ public class switch_codec : IDisposable { } } + public switch_frame cur_frame { + set { + freeswitchPINVOKE.switch_codec_cur_frame_set(swigCPtr, switch_frame.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_codec_cur_frame_get(swigCPtr); + switch_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_frame(cPtr, false); + return ret; + } + } + public switch_codec() : this(freeswitchPINVOKE.new_switch_codec(), true) { } @@ -26639,6 +26757,16 @@ public class switch_directories : IDisposable { } } + public string lib_dir { + set { + freeswitchPINVOKE.switch_directories_lib_dir_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_directories_lib_dir_get(swigCPtr); + return ret; + } + } + public switch_directories() : this(freeswitchPINVOKE.new_switch_directories(), true) { } @@ -28678,6 +28806,23 @@ public class switch_hold_record_t : IDisposable { namespace FreeSWITCH.Native { +public enum switch_hup_type_t { + SHT_NONE = 0, + SHT_UNANSWERED = (1 << 0), + SHT_ANSWERED = (1 << 1) +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.35 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + using System; using System.Runtime.InteropServices; diff --git a/src/mod/languages/mod_perl/freeswitch.pm b/src/mod/languages/mod_perl/freeswitch.pm index ffae0be801..17fdc67677 100644 --- a/src/mod/languages/mod_perl/freeswitch.pm +++ b/src/mod/languages/mod_perl/freeswitch.pm @@ -52,6 +52,7 @@ package freeswitch; *getGlobalVariable = *freeswitchc::getGlobalVariable; *consoleLog = *freeswitchc::consoleLog; *consoleCleanLog = *freeswitchc::consoleCleanLog; +*running = *freeswitchc::running; *email = *freeswitchc::email; *console_log = *freeswitchc::console_log; *console_clean_log = *freeswitchc::console_clean_log; diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index dd4b385299..e2ffffeea9 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -2051,6 +2051,24 @@ XS(_wrap_consoleCleanLog) { } +XS(_wrap_running) { + { + bool result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: running();"); + } + result = (bool)running(); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + XS(_wrap_email) { { char *arg1 = (char *) 0 ; @@ -9642,6 +9660,7 @@ static swig_command_info swig_commands[] = { {"freeswitchc::getGlobalVariable", _wrap_getGlobalVariable}, {"freeswitchc::consoleLog", _wrap_consoleLog}, {"freeswitchc::consoleCleanLog", _wrap_consoleCleanLog}, +{"freeswitchc::running", _wrap_running}, {"freeswitchc::email", _wrap_email}, {"freeswitchc::new_IVRMenu", _wrap_new_IVRMenu}, {"freeswitchc::delete_IVRMenu", _wrap_delete_IVRMenu}, diff --git a/src/mod/languages/mod_python/freeswitch.py b/src/mod/languages/mod_python/freeswitch.py index 1df258dc0c..51e3e652f6 100644 --- a/src/mod/languages/mod_python/freeswitch.py +++ b/src/mod/languages/mod_python/freeswitch.py @@ -52,6 +52,7 @@ setGlobalVariable = _freeswitch.setGlobalVariable getGlobalVariable = _freeswitch.getGlobalVariable consoleLog = _freeswitch.consoleLog consoleCleanLog = _freeswitch.consoleCleanLog +running = _freeswitch.running email = _freeswitch.email class IVRMenu(_object): __swig_setmethods__ = {} diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index d2098edd1c..b12d4c7614 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -3133,6 +3133,19 @@ fail: } +SWIGINTERN PyObject *_wrap_running(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + bool result; + + if (!PyArg_ParseTuple(args,(char *)":running")) SWIG_fail; + result = (bool)running(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_email(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; @@ -9169,6 +9182,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"getGlobalVariable", _wrap_getGlobalVariable, METH_VARARGS, NULL}, { (char *)"consoleLog", _wrap_consoleLog, METH_VARARGS, NULL}, { (char *)"consoleCleanLog", _wrap_consoleCleanLog, METH_VARARGS, NULL}, + { (char *)"running", _wrap_running, METH_VARARGS, NULL}, { (char *)"email", _wrap_email, METH_VARARGS, NULL}, { (char *)"new_IVRMenu", _wrap_new_IVRMenu, METH_VARARGS, NULL}, { (char *)"delete_IVRMenu", _wrap_delete_IVRMenu, METH_VARARGS, NULL}, diff --git a/src/switch_core.c b/src/switch_core.c index 1cc0dd0569..23e08d857a 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -2428,6 +2428,11 @@ SWITCH_DECLARE(switch_core_flag_t) switch_core_flags(void) return runtime.flags; } +SWITCH_DECLARE(switch_bool_t) switch_core_running(void) +{ + return runtime.running ? SWITCH_TRUE : SWITCH_FALSE; +} + SWITCH_DECLARE(switch_bool_t) switch_core_ready(void) { return (switch_test_flag((&runtime), SCF_SHUTTING_DOWN) || switch_test_flag((&runtime), SCF_NO_NEW_SESSIONS) == SCF_NO_NEW_SESSIONS) ? SWITCH_FALSE : SWITCH_TRUE; diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 64ca2fc120..f1ebe3f4e6 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -1205,6 +1205,11 @@ SWITCH_DECLARE(char *) getGlobalVariable(char *var_name) } +SWITCH_DECLARE(bool) running(void) +{ + return switch_core_running() ? true : false; +} + SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg) { return console_log(level_str, msg); From ad49dabd8c5c6ed0f2c708a9fc2ec42d08d1990a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 16:19:49 -0600 Subject: [PATCH 09/32] fix regression in media for recovered calls --- src/mod/endpoints/mod_sofia/sofia_glue.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 31ea2bb66b..388e647cc0 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3254,13 +3254,11 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f } - if (!sofia_test_flag(tech_pvt, TFLAG_REINVITE)) { - if (switch_rtp_ready(tech_pvt->rtp_session)) { - if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && !switch_rtp_ready(tech_pvt->video_rtp_session)) { - goto video; - } else { - goto end; - } + if (!sofia_test_flag(tech_pvt, TFLAG_REINVITE) && !sofia_test_flag(tech_pvt, TFLAG_SDP) && switch_rtp_ready(tech_pvt->rtp_session)) { + if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && !switch_rtp_ready(tech_pvt->video_rtp_session)) { + goto video; + } else { + goto end; } } From 92945f8a01851c6833d3f0106a7b6333a7d1c507 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Nov 2012 18:09:04 -0600 Subject: [PATCH 10/32] FS-4836 --- src/switch_core_session.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index e1093c50f3..c2fb0ea8d6 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -891,9 +891,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_se switch_core_session_kill_channel(session, SWITCH_SIG_BREAK); - if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) { - switch_core_session_wake_session_thread(session); - } + switch_core_session_wake_session_thread(session); + } return status; @@ -975,9 +974,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_signal_data(switch_cor switch_core_session_kill_channel(session, SWITCH_SIG_BREAK); - if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) { - switch_core_session_wake_session_thread(session); - } + switch_core_session_wake_session_thread(session); + } return status; @@ -1048,9 +1046,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_sess *event = NULL; status = SWITCH_STATUS_SUCCESS; - if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) { - switch_core_session_wake_session_thread(session); - } + switch_core_session_wake_session_thread(session); } } From 827b680afc3d8d4a65764ddd4655427f36dd10e4 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 27 Nov 2012 13:48:57 -0500 Subject: [PATCH 11/32] fix regressions in sql stuff --- src/mod/endpoints/mod_sofia/mod_sofia.h | 5 +++- src/mod/endpoints/mod_sofia/sofia_reg.c | 31 ++++++++++++++----------- src/switch_core_sqldb.c | 13 +++++++---- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 45f73c5866..dc62141f2e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -859,6 +859,9 @@ struct callback_t { switch_size_t len; switch_console_callback_match_t *list; int matches; + time_t time; + const char *contact_str; + long exptime; }; typedef enum { @@ -1189,7 +1192,7 @@ switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *sess char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type); void sofia_glue_tech_simplify(private_object_t *tech_pvt); switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host); -switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_multi(sofia_profile_t *profile, const char *user, const char *host); +switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_multi(sofia_profile_t *profile, const char *user, const char *host, time_t reg_time, const char *contact_str, long exptime); switch_bool_t sofia_glue_profile_exists(const char *key); void sofia_glue_global_siptrace(switch_bool_t on); void sofia_glue_global_capture(switch_bool_t on); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index d2bea6e5ea..7961f24e08 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -524,7 +524,11 @@ int sofia_reg_find_reg_with_positive_expires_callback(void *pArg, int argc, char long int expires; char *contact = NULL; - expires = atol(argv[1]) - 60 - (long) switch_epoch_time_now(NULL); + if (argv[0] && cbt->contact_str && !strcasecmp(argv[0], cbt->contact_str)) { + expires = cbt->exptime; + } else { + expires = atol(argv[1]) - 60 - (long) cbt->time; + } if (expires > 0) { dst = sofia_glue_get_destination(argv[0]); @@ -930,7 +934,7 @@ switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *p } -switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_multi(sofia_profile_t *profile, const char *user, const char *host) +switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_multi(sofia_profile_t *profile, const char *user, const char *host, time_t reg_time, const char *contact_str, long exptime) { struct callback_t cbt = { 0 }; char *sql; @@ -947,6 +951,10 @@ switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_mu sql = switch_mprintf("select contact,expires from sip_registrations where sip_user='%q'", user); } + cbt.time = reg_time; + cbt.contact_str = contact_str; + cbt.exptime = exptime; + sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_find_reg_with_positive_expires_callback, &cbt); free(sql); @@ -1075,6 +1083,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand int send_pres = 0; int is_tls = 0, is_tcp = 0; char expbuf[35] = ""; + time_t reg_time = switch_epoch_time_now(NULL); + if (v_event && *v_event) pres_on_reg = switch_event_get_header(*v_event, "send-presence-on-register"); @@ -1577,7 +1587,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand contact = sofia_glue_get_url_from_contact(contact_str, 1); url = switch_mprintf("sofia/%q/sip:%q", profile->name, sofia_glue_strip_proto(contact)); - switch_core_add_registration(to_user, reg_host, call_id, url, (long) switch_epoch_time_now(NULL) + (long) exptime + 60, + switch_core_add_registration(to_user, reg_host, call_id, url, (long) reg_time + (long) exptime + 60, network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp", reg_meta); switch_safe_free(url); @@ -1590,7 +1600,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand "mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host) " "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q')", call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : "", - contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime + 60, + contact_str, reg_desc, rpid, (long) reg_time + (long) exptime + 60, agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host); } else { @@ -1602,7 +1612,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand sub_host, network_ip, network_port_c, profile->presence_hosts ? profile->presence_hosts : "", guess_ip4, guess_ip4, mod_sofia_globals.hostname, mod_sofia_globals.hostname, - (long) switch_epoch_time_now(NULL) + (long) exptime + 60, + (long) reg_time + (long) exptime + 60, to_user, username, reg_host, contact_str); } @@ -1794,7 +1804,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand TAG_IF(!zstr(expbuf), SIPTAG_EXPIRES_STR(expbuf)), NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_END()); - } else if ((contact_list = sofia_reg_find_reg_url_with_positive_expires_multi(profile, from_user, reg_host))) { + } else if ((contact_list = sofia_reg_find_reg_url_with_positive_expires_multi(profile, from_user, reg_host, reg_time, contact_str, exptime))) { /* all + 1 tag_i elements initialized as NULL - last one implies TAG_END() */ switch_zmalloc(contact_tags, sizeof(*contact_tags) * (contact_list->count + 1)); i = 0; @@ -2358,7 +2368,6 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, if (zstr(np)) { nonce_cb_t cb = { 0 }; long nc_long = 0; - int sanity = 0; first = 1; @@ -2374,13 +2383,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, switch_assert(sql != NULL); - do { - if (sanity) { - switch_yield(100000 * sanity); - } - sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_nonce_callback, &cb); - } while(nc_long < 2 && ++sanity < 10 && zstr(np)); - + sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_nonce_callback, &cb); free(sql); //if (!sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, np, nplen)) { diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 3ad163b54e..c1381bd351 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -1706,11 +1706,14 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread, check: - if ((lc = qm_ttl(qm)) < qm->max_trans / 4) { - switch_yield(500000); - if ((lc = qm_ttl(qm)) == 0) { - switch_thread_cond_wait(qm->cond, qm->cond_mutex); - } + if ((lc = qm_ttl(qm)) == 0) { + switch_thread_cond_wait(qm->cond, qm->cond_mutex); + } + + i = 4; + + while (--i > 0 && (lc = qm_ttl(qm)) < qm->max_trans / 4) { + switch_yield(50000); } } From f1a89fb016dbefe6310702a68450c21dd5a42765 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 28 Nov 2012 23:11:31 -0600 Subject: [PATCH 12/32] let mod_fifo use sql_queue_manager --- src/mod/applications/mod_fifo/mod_fifo.c | 124 +++++++++++++---------- 1 file changed, 73 insertions(+), 51 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 78e8950b40..8970803f44 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -594,6 +594,11 @@ static struct { switch_thread_t *node_thread; int debug; struct fifo_node *nodes; + char *pre_trans_execute; + char *post_trans_execute; + char *inner_pre_trans_execute; + char *inner_post_trans_execute; + switch_sql_queue_manager_t *qm; } globals; @@ -742,7 +747,29 @@ switch_cache_db_handle_t *fifo_get_db_handle(void) return dbh; } +static switch_status_t fifo_execute_sql_queued(char **sqlp, switch_bool_t sql_already_dynamic, switch_bool_t block) +{ + int index = 1; + char *sql; + switch_assert(sqlp && *sqlp); + sql = *sqlp; + + + if (switch_stristr("insert", sql)) { + index = 0; + } + + switch_sql_queue_manager_push(globals.qm, sql, index, !sql_already_dynamic); + + if (sql_already_dynamic) { + *sqlp = NULL; + } + + return SWITCH_STATUS_SUCCESS; + +} +#if 0 static switch_status_t fifo_execute_sql(char *sql, switch_mutex_t *mutex) { switch_cache_db_handle_t *dbh = NULL; @@ -771,6 +798,7 @@ static switch_status_t fifo_execute_sql(char *sql, switch_mutex_t *mutex) return status; } +#endif static switch_bool_t fifo_execute_sql_callback(switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata) { @@ -937,9 +965,7 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); sql = switch_mprintf("delete from fifo_bridge where consumer_uuid='%q'", switch_core_session_get_uuid(consumer_session)); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); - + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); switch_channel_set_variable(consumer_channel, "fifo_status", "WAITING"); @@ -1025,8 +1051,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ switch_str_nil(msg->string_array_arg[0]), switch_str_nil(msg->string_array_arg[1]), switch_core_session_get_uuid(session)); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); goto end; default: goto end; @@ -1124,8 +1149,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ ); } - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); epoch_start = (long)switch_epoch_time_now(NULL); @@ -1381,8 +1405,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void struct call_helper *h = cbh->rows[i]; char *sql = switch_mprintf("update fifo_outbound set ring_count=ring_count+1 where uuid='%s'", h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } @@ -1424,8 +1447,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void struct call_helper *h = cbh->rows[i]; char *sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1 " "where uuid='%q' and ring_count > 0", h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } } @@ -1439,8 +1461,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void "outbound_fail_total_count = outbound_fail_total_count+1, " "next_avail=%ld + lag + 1 where uuid='%q' and ring_count > 0", (long) switch_epoch_time_now(NULL), h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } } @@ -1497,8 +1518,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void for (i = 0; i < cbh->rowcount; i++) { struct call_helper *h = cbh->rows[i]; char *sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1 where uuid='%q' and ring_count > 0", h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } end: @@ -1608,8 +1628,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) sql = switch_mprintf("update fifo_outbound set ring_count=ring_count+1 where uuid='%s'", h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); status = switch_ivr_originate(NULL, &session, &cause, originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL); free(originate_string); @@ -1619,8 +1638,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1, " "outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag + 1 where uuid='%q'", (long) switch_epoch_time_now(NULL), h->uuid); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); 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); @@ -2123,15 +2141,12 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve 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); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); del_bridge_call(outbound_id); sql = switch_mprintf("update fifo_outbound set use_count=use_count-1, stop_time=%ld, next_avail=%ld + lag + 1 where use_count > 0 and uuid='%q'", now, now, outbound_id); - - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } if (send_event) { @@ -2198,9 +2213,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function) sql = switch_mprintf("update fifo_outbound set stop_time=0,start_time=%ld,outbound_fail_count=0,use_count=use_count+1,%s=%s+1,%s=%s+1 where uuid='%q'", (long) switch_epoch_time_now(NULL), col1, col1, col2, col2, data); - fifo_execute_sql(sql, globals.sql_mutex); - - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { @@ -2235,8 +2248,7 @@ static void fifo_caller_add(fifo_node_t *node, switch_core_session_t *session) switch_str_nil(switch_channel_get_variable(channel, "caller_id_number")), switch_epoch_time_now(NULL)); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); } static void fifo_caller_del(const char *uuid) @@ -2249,8 +2261,7 @@ static void fifo_caller_del(const char *uuid) sql = switch_mprintf("delete from fifo_callers"); } - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); } @@ -3018,8 +3029,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_epoch_time_now(NULL), outbound_id); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } add_bridge_call(switch_core_session_get_uuid(other_session)); @@ -3038,8 +3048,7 @@ SWITCH_STANDARD_APP(fifo_function) ); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(other_session)); @@ -3055,8 +3064,7 @@ SWITCH_STANDARD_APP(fifo_function) "outbound_call_count=outbound_call_count+1, next_avail=%ld + lag + 1 where uuid='%s' and use_count > 0", now, now, outbound_id); - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); del_bridge_call(outbound_id); @@ -3088,8 +3096,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_channel_set_variable_printf(other_channel, "fifo_bridge_seconds", "%d", epoch_end - epoch_start); 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); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); switch_core_media_bug_pause(session); @@ -4009,6 +4016,14 @@ static switch_status_t load_config(int reload, int del_all) } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); } + } else if (!strcasecmp(var, "db-pre-trans-execute") && !zstr(val)) { + globals.pre_trans_execute = switch_core_strdup(globals.pool, val); + } else if (!strcasecmp(var, "db-post-trans-execute") && !zstr(val)) { + globals.post_trans_execute = switch_core_strdup(globals.pool, val); + } else if (!strcasecmp(var, "db-inner-pre-trans-execute") && !zstr(val)) { + globals.inner_pre_trans_execute = switch_core_strdup(globals.pool, val); + } else if (!strcasecmp(var, "db-inner-post-trans-execute") && !zstr(val)) { + globals.inner_post_trans_execute = switch_core_strdup(globals.pool, val); } else if (!strcasecmp(var, "delete-all-outbound-member-on-startup")) { delete_all_outbound_member_on_startup = switch_true(val); } @@ -4019,6 +4034,18 @@ static switch_status_t load_config(int reload, int del_all) globals.dbname = "fifo"; } + switch_sql_queue_manager_init_name("fifo", + &globals.qm, + 2, + globals.odbc_dsn ? globals.odbc_dsn : globals.dbname, + SWITCH_MAX_TRANS, + globals.pre_trans_execute, + globals.post_trans_execute, + globals.inner_pre_trans_execute, + globals.inner_post_trans_execute); + + switch_sql_queue_manager_start(globals.qm); + if (!(dbh = fifo_get_db_handle())) { @@ -4036,8 +4063,8 @@ static switch_status_t load_config(int reload, int del_all) switch_cache_db_release_db_handle(&dbh); if (!reload) { - fifo_execute_sql("update fifo_outbound set start_time=0,stop_time=0,ring_count=0,use_count=0," - "outbound_call_count=0,outbound_fail_count=0 where static=0", globals.sql_mutex); + char *sql= "update fifo_outbound set start_time=0,stop_time=0,ring_count=0,use_count=0,outbound_call_count=0,outbound_fail_count=0 where static=0"; + fifo_execute_sql_queued(&sql, SWITCH_FALSE, SWITCH_TRUE); } if (reload) { @@ -4060,8 +4087,7 @@ static switch_status_t load_config(int reload, int del_all) sql = switch_mprintf("delete from fifo_outbound where static=1 and hostname='%q'", globals.hostname); } - fifo_execute_sql(sql, globals.sql_mutex); - switch_safe_free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); if (!(node = switch_core_hash_find(globals.fifo_hash, MANUAL_QUEUE_NAME))) { node = create_node(MANUAL_QUEUE_NAME, 0, globals.sql_mutex); @@ -4214,8 +4240,7 @@ static switch_status_t load_config(int reload, int del_all) (long) switch_epoch_time_now(NULL)); switch_assert(sql); - fifo_execute_sql(sql, globals.sql_mutex); - free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); free(name_dup); node->has_outbound = 1; node->member_count++; @@ -4270,8 +4295,7 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co sql = switch_mprintf("delete from fifo_outbound where fifo_name='%q' and uuid = '%q'", fifo_name, digest); switch_assert(sql); - fifo_execute_sql(sql, globals.sql_mutex); - free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); switch_mutex_lock(globals.mutex); @@ -4293,8 +4317,7 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co digest, fifo_name, originate_string, simo_count, 0, timeout, lag, 0, (long) expires, globals.hostname, taking_calls, (long)switch_epoch_time_now(NULL)); switch_assert(sql); - fifo_execute_sql(sql, globals.sql_mutex); - free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); free(name_dup); cbt.buf = outbound_count; @@ -4329,8 +4352,7 @@ static void fifo_member_del(char *fifo_name, char *originate_string) sql = switch_mprintf("delete from fifo_outbound where fifo_name='%q' and uuid = '%q' and hostname='%q'", fifo_name, digest, globals.hostname); switch_assert(sql); - fifo_execute_sql(sql, globals.sql_mutex); - free(sql); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); switch_mutex_lock(globals.mutex); if (!(node = switch_core_hash_find(globals.fifo_hash, fifo_name))) { From d4f8a79299c132b9226c8b09a36f5b35f31a8a02 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 28 Nov 2012 23:12:35 -0600 Subject: [PATCH 13/32] try to improve audio stream sync --- src/mod/endpoints/mod_sofia/mod_sofia.c | 12 +++++- src/mod/endpoints/mod_sofia/mod_sofia.h | 3 ++ src/mod/endpoints/mod_sofia/sofia.c | 2 +- src/switch_channel.c | 4 +- src/switch_ivr_bridge.c | 5 ++- src/switch_ivr_originate.c | 14 +++---- src/switch_rtp.c | 55 ++++++++++++++++--------- 7 files changed, 62 insertions(+), 33 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index deedea0802..0b11abf703 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1565,7 +1565,17 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (switch_core_session_in_thread(session)) { de->session = session; } - sofia_process_dispatch_event(&de); + + if (de->data->e_event == nua_i_cancel || de->data->e_event == nua_i_bye) { + sofia_set_flag(tech_pvt, TFLAG_SIGDEAD); + } + + if (!sofia_test_flag(tech_pvt, TFLAG_SIGDEAD) && (switch_channel_media_up(channel) || switch_channel_get_state(channel) > CS_ROUTING)) { + sofia_queue_message(de); + } else { + sofia_process_dispatch_event(&de); + } + switch_mutex_unlock(tech_pvt->sofia_mutex); goto end; } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index dc62141f2e..44f17a320f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -353,6 +353,7 @@ typedef enum { TFLAG_PASS_ACK, TFLAG_CRYPTO_RECOVER, TFLAG_DROP_DTMF, + TFLAG_SIGDEAD, /* No new flags below this line */ TFLAG_MAX } TFLAGS; @@ -1205,6 +1206,7 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np); void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on); void sofia_process_dispatch_event(sofia_dispatch_event_t **dep); +void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep); char *sofia_glue_get_host(const char *str, switch_memory_pool_t *pool); void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now); void sofia_msg_thread_start(int idx); @@ -1215,6 +1217,7 @@ private_object_t *sofia_glue_new_pvt(switch_core_session_t *session); switch_status_t sofia_init(void); void sofia_glue_fire_events(sofia_profile_t *profile); void sofia_event_fire(sofia_profile_t *profile, switch_event_t **event); +void sofia_queue_message(sofia_dispatch_event_t *de); /* For Emacs: * Local Variables: diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 092b1dca27..ed3428555e 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1686,7 +1686,7 @@ void sofia_msg_thread_start(int idx) } //static int foo = 0; -static void sofia_queue_message(sofia_dispatch_event_t *de) +void sofia_queue_message(sofia_dispatch_event_t *de) { int launch = 0; diff --git a/src/switch_channel.c b/src/switch_channel.c index 903bb6be76..9ac36c589a 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -291,7 +291,7 @@ SWITCH_DECLARE(switch_channel_callstate_t) switch_channel_str2callstate(const ch SWITCH_DECLARE(void) switch_channel_perform_audio_sync(switch_channel_t *channel, const char *file, const char *func, int line) { - if (switch_channel_media_ready(channel)) { + if (switch_channel_media_up(channel)) { switch_core_session_message_t msg = { 0 }; msg.message_id = SWITCH_MESSAGE_INDICATE_AUDIO_SYNC; msg.from = channel->name; @@ -3446,7 +3446,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan switch_channel_presence(channel, "unknown", "answered", NULL); - switch_channel_audio_sync(channel); + //switch_channel_audio_sync(channel); switch_core_recovery_track(channel->session); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 7eb96b287a..b8b04cdbd0 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1232,8 +1232,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_channel_set_flag_recursive(caller_channel, CF_BRIDGE_ORIGINATOR); switch_channel_clear_flag(peer_channel, CF_BRIDGE_ORIGINATOR); - switch_channel_audio_sync(caller_channel); - switch_channel_audio_sync(peer_channel); + //switch_channel_audio_sync(caller_channel); + //switch_channel_audio_sync(peer_channel); b_leg->session = peer_session; switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid)); @@ -1368,6 +1368,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_channel_set_private(peer_channel, "_bridge_", b_leg); switch_channel_set_state(peer_channel, CS_EXCHANGE_MEDIA); + audio_bridge_thread(NULL, (void *) a_leg); switch_channel_clear_flag_recursive(caller_channel, CF_BRIDGE_ORIGINATOR); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index d8a555c512..52d903c79d 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -3115,7 +3115,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess do_continue: if (!read_packet) { - switch_cond_next(); + switch_yield(20000); } } @@ -3373,13 +3373,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) { status = SWITCH_STATUS_SUCCESS; } else { - status = switch_channel_answer(caller_channel); + status = switch_channel_answer(caller_channel); } } else if (switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) { if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) { status = SWITCH_STATUS_SUCCESS; } else { - status = switch_channel_pre_answer(caller_channel); + status = switch_channel_pre_answer(caller_channel); } } else { status = SWITCH_STATUS_SUCCESS; @@ -3707,11 +3707,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_cond_next(); } - switch_channel_audio_sync(bchan); + //switch_channel_audio_sync(bchan); - if (caller_channel) { - switch_channel_audio_sync(caller_channel); - } + //if (caller_channel) { + // switch_channel_audio_sync(caller_channel); + //} } if (oglobals.session) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index e469066fce..ec003f9569 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -67,6 +67,7 @@ static switch_port_t START_PORT = RTP_START_PORT; static switch_port_t END_PORT = RTP_END_PORT; static switch_port_t NEXT_PORT = RTP_START_PORT; static switch_mutex_t *port_lock = NULL; +static void do_flush(switch_rtp_t *rtp_session); typedef srtp_hdr_t rtp_hdr_t; @@ -2071,6 +2072,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, rtp_session->ready = 2; rtp_session->rx_host = switch_core_strdup(rtp_session->pool, rx_host); rtp_session->rx_port = rx_port; + //switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); } else { switch_rtp_release_port(rx_host, rx_port); } @@ -2761,7 +2763,7 @@ SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session, switch_rtp if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { - switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); + switch (flush) { case SWITCH_RTP_FLUSH_STICK: switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_STICKY_FLUSH); @@ -2780,6 +2782,7 @@ static void do_flush(switch_rtp_t *rtp_session) { int was_blocking = 0; switch_size_t bytes; + uint32_t flushed = 0; if (!switch_rtp_ready(rtp_session) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || @@ -2787,11 +2790,11 @@ static void do_flush(switch_rtp_t *rtp_session) ) { return; } + READ_INC(rtp_session); if (switch_rtp_ready(rtp_session)) { - uint32_t flushed = 0; if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ)) { switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session"); @@ -2869,34 +2872,35 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t if (rtp_session->last_seq && rtp_session->last_seq+1 != seq) { #ifdef DEBUG_MISSED_SEQ + //2012-11-28 18:33:11.799070 [ERR] switch_rtp.c:2883 Missed -65536 RTP frames from sequence [65536] to [-1] (missed). Time since last read [20021] switch_size_t flushed_packets_diff = rtp_session->stats.inbound.flush_packet_count - rtp_session->last_flush_packet_count; switch_size_t num_missed = (switch_size_t)seq - (rtp_session->last_seq+1); if (num_missed == 1) { /* We missed one packet */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missed one RTP frame with sequence [%d]%s. Time since last read [%d]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missed one RTP frame with sequence [%d]%s. Time since last read [%ld]\n", rtp_session->last_seq+1, (flushed_packets_diff == 1) ? " (flushed by FS)" : " (missed)", rtp_session->last_read_time ? switch_micro_time_now()-rtp_session->last_read_time : 0); } else { /* We missed multiple packets */ if (flushed_packets_diff == 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, - "Missed %d RTP frames from sequence [%d] to [%d] (missed). Time since last read [%d]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Missed %ld RTP frames from sequence [%d] to [%d] (missed). Time since last read [%ld]\n", num_missed, rtp_session->last_seq+1, seq-1, rtp_session->last_read_time ? switch_micro_time_now()-rtp_session->last_read_time : 0); } else if (flushed_packets_diff == num_missed) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, - "Missed %d RTP frames from sequence [%d] to [%d] (flushed by FS). Time since last read [%d]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Missed %ld RTP frames from sequence [%d] to [%d] (flushed by FS). Time since last read [%ld]\n", num_missed, rtp_session->last_seq+1, seq-1, rtp_session->last_read_time ? switch_micro_time_now()-rtp_session->last_read_time : 0); } else if (num_missed > flushed_packets_diff) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, - "Missed %d RTP frames from sequence [%d] to [%d] (%d packets flushed by FS, %d packets missed)." - " Time since last read [%d]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Missed %ld RTP frames from sequence [%d] to [%d] (%ld packets flushed by FS, %ld packets missed)." + " Time since last read [%ld]\n", num_missed, rtp_session->last_seq+1, seq-1, flushed_packets_diff, num_missed-flushed_packets_diff, rtp_session->last_read_time ? switch_micro_time_now()-rtp_session->last_read_time : 0); } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, - "Missed %d RTP frames from sequence [%d] to [%d] (%d packets flushed by FS). Time since last read [%d]\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Missed %ld RTP frames from sequence [%d] to [%d] (%ld packets flushed by FS). Time since last read [%ld]\n", num_missed, rtp_session->last_seq+1, seq-1, flushed_packets_diff, rtp_session->last_read_time ? switch_micro_time_now()-rtp_session->last_read_time : 0); } @@ -3240,15 +3244,17 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ if (bytes) { if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { - /* switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Trigger %d\n", rtp_session->hot_hits); */ - rtp_session->hot_hits += rtp_session->samples_per_interval; + rtp_session->hot_hits++;//+= rtp_session->samples_per_interval; + + //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s Trigger %d\n", + //switch_core_session_get_name(session), + // rtp_session->hot_hits); } else { rtp_session->hot_hits = 0; } } - if (rtp_session->hot_hits >= rtp_session->samples_per_second * 5) { - switch_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH); + if (rtp_session->hot_hits > 1 && !rtp_session->sync_packets) {// >= (rtp_session->samples_per_second * 30)) { hot_socket = 1; } } else { @@ -3256,19 +3262,27 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ } } - if (hot_socket) { + + if (hot_socket) { + //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Skip timer\n"); rtp_session->sync_packets++; switch_core_timer_sync(&rtp_session->timer); + } else { + if (rtp_session->sync_packets) { #if 0 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Auto-Flush catching up %d packets (%d)ms.\n", rtp_session->sync_packets, (rtp_session->ms_per_packet * rtp_session->sync_packets) / 1000); #endif - rtp_session->sync_packets = 0; + //switch_core_timer_sync(&rtp_session->timer); + } else { + + switch_core_timer_next(&rtp_session->timer); } - switch_core_timer_next(&rtp_session->timer); + + rtp_session->sync_packets = 0; } } @@ -4787,3 +4801,4 @@ SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session) * For VIM: * vim:set softtabstop=4 shiftwidth=4 tabstop=4: */ + From fdca268aed9daa35a618cb9ac98732a44ce204fd Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 29 Nov 2012 01:33:12 -0600 Subject: [PATCH 14/32] tweak --- src/mod/applications/mod_snapshot/mod_snapshot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_snapshot/mod_snapshot.c b/src/mod/applications/mod_snapshot/mod_snapshot.c index 08c83dea00..bdbbcb4bc4 100644 --- a/src/mod/applications/mod_snapshot/mod_snapshot.c +++ b/src/mod/applications/mod_snapshot/mod_snapshot.c @@ -328,7 +328,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_snapshot_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_API(api_interface, "uuid_snapshot", "Snapshot API", snapshot_function, SNAP_API_SYNTAX); - SWITCH_ADD_APP(app_interface, "snapshot", "", "", snapshot_app_function, SNAP_SYNTAX, SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "snapshot", "", "", snapshot_app_function, SNAP_SYNTAX, SAF_MEDIA_TAP); switch_console_set_complete("add uuid_snapshot ::console::list_uuid"); /* indicate that the module should continue to be loaded */ From 16eaa729b1499efb117d7c54b9f8708d18c144f5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 08:30:29 -0600 Subject: [PATCH 15/32] FS-4889 --resolve --- src/mod/applications/mod_conference/mod_conference.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index d5ea7e702a..2f5456106f 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -8620,6 +8620,7 @@ static void call_setup_event_handler(switch_event_t *event) switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "conference_track_status", "true"); switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "conference_track_call_id", call_id); + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "sip_invite_domain", domain); if (!strncasecmp(ostr, "url+", 4)) { ostr += 4; From a9267b1faf684b5d50c7014b6b9bb7645aac4757 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 08:35:28 -0600 Subject: [PATCH 16/32] add mutex around hash as this code can now be executed concurrently --- src/mod/endpoints/mod_sofia/sofia_reg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 7961f24e08..507ace4391 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1019,6 +1019,7 @@ static int debounce_check(sofia_profile_t *profile, const char *user, const char snprintf(key, sizeof(key), "%s%s", user, host); + switch_mutex_lock(profile->ireg_mutex); if ((last = switch_core_hash_find(profile->mwi_debounce_hash, key))) { if (now - *last > 30) { *last = now; @@ -1030,6 +1031,7 @@ static int debounce_check(sofia_profile_t *profile, const char *user, const char switch_core_hash_insert(profile->mwi_debounce_hash, key, last); r = 1; } + switch_mutex_unlock(profile->ireg_mutex); return r; } From 081e261956cf36c6692e1035d41cfd8f8d29475a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 08:58:44 -0600 Subject: [PATCH 17/32] FS-4883 --resolve I can add this but if it leads to issues in the loaded code we may not have resoures to investigate --- src/include/switch_core.h | 7 +++++ src/include/switch_core_db.h | 5 ++++ src/mod/languages/mod_lua/freeswitch.i | 1 + src/mod/languages/mod_lua/freeswitch_lua.cpp | 8 +++++ src/mod/languages/mod_lua/freeswitch_lua.h | 1 + src/mod/languages/mod_lua/mod_lua_wrap.cpp | 29 +++++++++++++++++++ .../languages/mod_managed/freeswitch_wrap.cxx | 28 ++++++++++++++++++ src/mod/languages/mod_managed/managed/swig.cs | 16 ++++++++++ src/switch_core_db.c | 17 +++++++++++ src/switch_core_sqldb.c | 23 +++++++++++++++ 10 files changed, 135 insertions(+) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 7b164af20a..68e592b9df 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2360,6 +2360,13 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach */ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh); +/*! + \brief load an external extension to db + \param [in] dbh The handle + \param [out] the path to the extension +*/ +SWITCH_DECLARE(int) switch_cache_db_load_extension(switch_cache_db_handle_t *dbh, const char *extension); + /*! \brief Provides some feedback as to the status of the db connection pool \param [in] stream stream for status diff --git a/src/include/switch_core_db.h b/src/include/switch_core_db.h index e5fbf76a95..002a6ec7b6 100644 --- a/src/include/switch_core_db.h +++ b/src/include/switch_core_db.h @@ -462,6 +462,11 @@ SWITCH_DECLARE(void) switch_core_db_free(char *z); */ SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db); +/** + * Call this routine to load an external extension + */ +SWITCH_DECLARE(int) switch_core_db_load_extension(switch_core_db_t *db, const char *extension); + /** Return values for switch_core_db_exec() and switch_core_db_step()*/ #define SWITCH_CORE_DB_OK 0 /* Successful result */ /* beginning-of-error-codes */ diff --git a/src/mod/languages/mod_lua/freeswitch.i b/src/mod/languages/mod_lua/freeswitch.i index a615fcd742..6fca226001 100644 --- a/src/mod/languages/mod_lua/freeswitch.i +++ b/src/mod/languages/mod_lua/freeswitch.i @@ -93,6 +93,7 @@ class Dbh { bool test_reactive(char *test_sql, char *drop_sql = NULL, char *reactive_sql = NULL); bool query(char *sql, SWIGLUA_FN lua_fun); int affected_rows(); + int load_extension(const char *extension); }; } diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index 811a8a7bd6..c8918aee97 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -438,3 +438,11 @@ int Dbh::affected_rows() } return 0; } + +int Dbh::load_extension(const char *extension) +{ + if (m_connected) { + return switch_cache_db_load_extension(dbh, extension); + } + return 0; +} diff --git a/src/mod/languages/mod_lua/freeswitch_lua.h b/src/mod/languages/mod_lua/freeswitch_lua.h index 36c0afae5c..a1a289a70b 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.h +++ b/src/mod/languages/mod_lua/freeswitch_lua.h @@ -65,6 +65,7 @@ namespace LUA { bool test_reactive(char *test_sql, char *drop_sql = NULL, char *reactive_sql = NULL); bool query(char *sql, SWIGLUA_FN lua_fun); int affected_rows(); + int load_extension(const char *extension); }; } #endif diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index 3f9ad57fb5..98c50f081d 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -7764,6 +7764,34 @@ fail: } +static int _wrap_Dbh_load_extension(lua_State* L) { + int SWIG_arg = -1; + LUA::Dbh *arg1 = (LUA::Dbh *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + SWIG_check_num_args("load_extension",2,2) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("load_extension",1,"LUA::Dbh *"); + if(!lua_isstring(L,2)) SWIG_fail_arg("load_extension",2,"char const *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){ + SWIG_fail_ptr("Dbh_load_extension",1,SWIGTYPE_p_LUA__Dbh); + } + + arg2 = (char *)lua_tostring(L, 2); + result = (int)(arg1)->load_extension((char const *)arg2); + SWIG_arg=0; + lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static void swig_delete_Dbh(void *obj) { LUA::Dbh *arg1 = (LUA::Dbh *) obj; delete arg1; @@ -7774,6 +7802,7 @@ static swig_lua_method swig_LUA_Dbh_methods[] = { {"test_reactive", _wrap_Dbh_test_reactive}, {"query", _wrap_Dbh_query}, {"affected_rows", _wrap_Dbh_affected_rows}, + {"load_extension", _wrap_Dbh_load_extension}, {0,0} }; static swig_lua_attribute swig_LUA_Dbh_attributes[] = { diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 4f885e481b..64f38107f7 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -5444,6 +5444,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_db_changes(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_db_load_extension(void * jarg1, char * jarg2) { + int jresult ; + switch_core_db_t *arg1 = (switch_core_db_t *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (switch_core_db_t *)jarg1; + arg2 = (char *)jarg2; + result = (int)switch_core_db_load_extension(arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_OK_get() { int jresult ; int result; @@ -12035,6 +12049,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_affected_rows(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_load_extension(void * jarg1, char * jarg2) { + int jresult ; + switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (switch_cache_db_handle_t *)jarg1; + arg2 = (char *)jarg2; + result = (int)switch_cache_db_load_extension(arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_status(void * jarg1) { switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index e560b2046c..7364cce845 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -986,6 +986,11 @@ public class freeswitch { return ret; } + public static int switch_core_db_load_extension(SWIGTYPE_p_sqlite3 db, string extension) { + int ret = freeswitchPINVOKE.switch_core_db_load_extension(SWIGTYPE_p_sqlite3.getCPtr(db), extension); + return ret; + } + public static string switch_sql_concat() { string ret = freeswitchPINVOKE.switch_sql_concat(); return ret; @@ -2698,6 +2703,11 @@ public class freeswitch { return ret; } + public static int switch_cache_db_load_extension(SWIGTYPE_p_switch_cache_db_handle dbh, string extension) { + int ret = freeswitchPINVOKE.switch_cache_db_load_extension(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), extension); + return ret; + } + public static void switch_cache_db_status(switch_stream_handle stream) { freeswitchPINVOKE.switch_cache_db_status(switch_stream_handle.getCPtr(stream)); } @@ -7968,6 +7978,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_db_changes")] public static extern int switch_core_db_changes(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_db_load_extension")] + public static extern int switch_core_db_load_extension(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CORE_DB_OK_get")] public static extern int SWITCH_CORE_DB_OK_get(); @@ -9489,6 +9502,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_affected_rows")] public static extern int switch_cache_db_affected_rows(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_load_extension")] + public static extern int switch_cache_db_load_extension(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_status")] public static extern void switch_cache_db_status(HandleRef jarg1); diff --git a/src/switch_core_db.c b/src/switch_core_db.c index 7cc151dc5b..6cc8896fab 100644 --- a/src/switch_core_db.c +++ b/src/switch_core_db.c @@ -178,6 +178,23 @@ SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db) return sqlite3_changes(db); } +SWITCH_DECLARE(int) switch_core_db_load_extension(switch_core_db_t *db, const char *extension) +{ + int ret = 0; + char *err = NULL; + + sqlite3_enable_load_extension(db, 1); + ret = sqlite3_load_extension(db, extension, 0, &err); + sqlite3_enable_load_extension(db, 0); + + if (err) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LOAD EXTENSION ERR [%s]\n", err); + switch_core_db_free(err); + err = NULL; + } + return ret; +} + SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(const char *filename) { switch_core_db_t *db; diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index c1381bd351..3860af15d4 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -703,6 +703,29 @@ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh) return 0; } +SWITCH_DECLARE(int) switch_cache_db_load_extension(switch_cache_db_handle_t *dbh, const char *extension) +{ + switch (dbh->type) { + case SCDB_TYPE_CORE_DB: + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "try to load extension [%s]!\n", extension); + return switch_core_db_load_extension(dbh->native_handle.core_db_dbh, extension); + } + break; + case SCDB_TYPE_ODBC: + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "load extension not supported by type ODBC!\n"); + } + break; + case SCDB_TYPE_PGSQL: + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "load extension not supported by type PGSQL!\n"); + } + break; + } + return 0; +} + SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err) { From bce107b5fcf7c1854dc4dcc3bd2e6bdd2c435a88 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 09:00:03 -0600 Subject: [PATCH 18/32] FS-4883 --resolve I can add this but if it leads to issues in the loaded code we may not have resoures to investigate --- Makefile.am | 2 +- libs/sqlite/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f1e98e05e1..6e08f68a05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -472,7 +472,7 @@ libs/speex/libspeex/libspeexdsp.la: libs/speex/.update libs/sqlite/libsqlite3.la: libs/sqlite libs/sqlite/.update touch src/include/switch.h - @cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)" + @cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)" LIBREADLINE="-lreadline -lncurses -ldl" @$(TOUCH_TARGET) libs/pcre/libpcre.la: libs/pcre libs/pcre/.update diff --git a/libs/sqlite/Makefile.in b/libs/sqlite/Makefile.in index 1d01aadf34..01ff7496a9 100644 --- a/libs/sqlite/Makefile.in +++ b/libs/sqlite/Makefile.in @@ -116,7 +116,7 @@ NAWK = @AWK@ # You should not have to change anything below this line ############################################################################### -TCC += -DSQLITE_OMIT_LOAD_EXTENSION=1 +#TCC += -DSQLITE_OMIT_LOAD_EXTENSION=1 # Object files for the SQLite library. # From 435443c9f6ca3cd4772dc6563c1ca00c1f25e763 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 10:40:47 -0600 Subject: [PATCH 19/32] fix build --- libs/sqlite/src/os_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/sqlite/src/os_common.h b/libs/sqlite/src/os_common.h index 863e3cde2b..cd43f93a7e 100644 --- a/libs/sqlite/src/os_common.h +++ b/libs/sqlite/src/os_common.h @@ -26,7 +26,7 @@ #ifdef MEMORY_DEBUG # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif - +#undef SQLITE_OMIT_LOAD_EXTENSION /* * When testing, this global variable stores the location of the From 03531329d3981d7bd5f568690c1d58189d2e1220 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 10:44:27 -0600 Subject: [PATCH 20/32] bring back 'make sure' it will git clean and fully reset and build latest git and wipe out any uncomitted changes, you can pass CONFIGURE_ARGS=--foo from the make command line to pass the flags to the reconfigure --- Makefile.am | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6e08f68a05..094701142c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -606,6 +606,10 @@ version: reinstall: modwipe uninstall install +pristine: + git clean -fdx + git reset --hard + update-clean: clean libs/openzap/Makefile python-reconf cd libs/sofia-sip && $(MAKE) clean cd libs/openzap && $(MAKE) clean @@ -618,13 +622,6 @@ swigall: @echo reswigging all sh $(switch_srcdir)/build/swigall.sh -sure: current - -speedy-sure: update-clean - $(MAKE) -j core - cd libs/sofia-sip && $(MAKE) -j - $(MAKE) -j modules - speex-reconf: cd libs/speex && autoreconf cd libs/speex && ./config.status --recheck @@ -680,6 +677,14 @@ cluecon: @echo @echo http://www.cluecon.com @sleep 5 + +sure: is-scm pristine update + git pull + sh bootstrap.sh + sh configure $(CONFIGURE_ARGS) + make $(MAKE_ARGS) + make reinstall + current: cluecon update-clean is-scm $(MAKE) update $(MAKE) all From 7e03199529d74c99efe742594b9198d37a0fa1e9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 10:47:16 -0600 Subject: [PATCH 21/32] fix build again --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 094701142c..28b076ddec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -472,7 +472,7 @@ libs/speex/libspeex/libspeexdsp.la: libs/speex/.update libs/sqlite/libsqlite3.la: libs/sqlite libs/sqlite/.update touch src/include/switch.h - @cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)" LIBREADLINE="-lreadline -lncurses -ldl" + @cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)" LIBREADLINE="-ldl" @$(TOUCH_TARGET) libs/pcre/libpcre.la: libs/pcre libs/pcre/.update From ddd6382280aa87c893b9e6bbb37d9e1a1ad3e86f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 11:00:43 -0600 Subject: [PATCH 22/32] FS-4887 --resolve --- src/switch_event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/switch_event.c b/src/switch_event.c index 259a5fa25c..32bc5b2d2d 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -1613,6 +1613,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a, if (vnext) { vdata = vnext; + vnext = NULL; } else { break; } From a59a319e0dc781858d435fd300742a504b87c0a6 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 29 Nov 2012 15:21:09 -0500 Subject: [PATCH 23/32] fix full build again --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 28b076ddec..2104db9b75 100644 --- a/Makefile.am +++ b/Makefile.am @@ -472,7 +472,7 @@ libs/speex/libspeex/libspeexdsp.la: libs/speex/.update libs/sqlite/libsqlite3.la: libs/sqlite libs/sqlite/.update touch src/include/switch.h - @cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)" LIBREADLINE="-ldl" + @cd libs/sqlite && $(MAKE) CFLAGS="$(SWITCH_AM_CFLAGS)" @$(TOUCH_TARGET) libs/pcre/libpcre.la: libs/pcre libs/pcre/.update From 026da2b33d6c363739fba8b09f2d9ea61d971dc3 Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Thu, 29 Nov 2012 15:42:46 -0500 Subject: [PATCH 24/32] FS-4890 --resolve I've also added the CC-Agent-Called-Time and CC-Agent-Aborted-Time in case you find this useful also. --- src/mod/applications/mod_callcenter/mod_callcenter.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 2e20f3c969..076009ac53 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -1762,10 +1762,13 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Hangup-Cause", switch_channel_cause2str(cause)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent", h->agent_name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Agent-System", h->agent_system); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "CC-Agent-Called-Time", "%" SWITCH_TIME_T_FMT, t_agent_called); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "CC-Agent-Aborted-Time", "%" SWITCH_TIME_T_FMT, local_epoch_time_now(NULL)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Member-UUID", h->member_uuid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Member-Session-UUID", h->member_session_uuid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Member-CID-Name", h->member_cid_name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CC-Member-CID-Number", h->member_cid_number); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "CC-Member-Joined-Time", "%" SWITCH_TIME_T_FMT, t_member_called); switch_event_fire(&event); } From 685da11d0d7c2aad85c48f91be9ed14623d2fae9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 12:37:41 -0600 Subject: [PATCH 25/32] FS-4885 --resolve this is not the best solution but it will work --- src/mod/endpoints/mod_sofia/mod_sofia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 0b11abf703..f483321e36 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2403,7 +2403,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)), TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END()); - } else if ((ua && (switch_stristr("aastra", ua)))) { + } else if ((ua && (switch_stristr("aastra", ua) && !switch_stristr("Intelligate", ua)))) { snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" ", name, number, tech_pvt->profile->sipip); sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY); From 395b7a97997496ca0758df64521d173a24593940 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 12:59:33 -0600 Subject: [PATCH 26/32] FS-4882 --resolve --- src/mod/endpoints/mod_sofia/sofia.c | 4 ++-- src/mod/endpoints/mod_sofia/sofia_reg.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index ed3428555e..a00a0d21bd 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4781,10 +4781,10 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq; sofia_reg_release_gateway(gateway); gateway->pinging = 0; - } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to) { + } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to && strchr(sip->sip_call_id->i_id, '_')) { char *sql; time_t now = switch_epoch_time_now(NULL); - const char *call_id = sip->sip_call_id->i_id; + const char *call_id = strchr(sip->sip_call_id->i_id, '_') + 1; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 507ace4391..f3d3bb205b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -557,17 +557,23 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames { sofia_profile_t *profile = (sofia_profile_t *) pArg; nua_handle_t *nh; - char to[512] = ""; + char to[512] = "", call_id[512] = ""; sofia_destination_t *dst = NULL; + switch_uuid_t uuid; switch_snprintf(to, sizeof(to), "sip:%s@%s", argv[1], argv[2]); + // create call-id for OPTIONS in the form "_" + switch_uuid_get(&uuid); + switch_uuid_format(call_id, &uuid); + strcat(call_id, "_"); + strncat(call_id, argv[0], sizeof(call_id) - SWITCH_UUID_FORMATTED_LENGTH - 2); + dst = sofia_glue_get_destination(argv[3]); switch_assert(dst); nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url), - TAG_END()); - //SIPTAG_CALL_ID_STR(argv[0]), TAG_END()); + SIPTAG_CALL_ID_STR(call_id), TAG_END()); nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_options(nh, NTATAG_SIP_T2(5000), From 35f98c13506b719790d84ba571b81390753e2a43 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 13:02:30 -0600 Subject: [PATCH 27/32] FS-4841 --resolve we will remove this, it clearly is not helping --- src/switch_time.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/switch_time.c b/src/switch_time.c index 54bf9338ef..6ce27b90c4 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -150,7 +150,6 @@ SWITCH_DECLARE(void) switch_os_yield(void) #if defined(WIN32) SwitchToThread(); #else - usleep(1); sched_yield(); #endif } From b4d7c2ab2ce22b52857a067e5e4e63b0291a64af Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 29 Nov 2012 16:49:05 -0500 Subject: [PATCH 28/32] FS-4882: fix potential seg --- src/mod/endpoints/mod_sofia/sofia.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index a00a0d21bd..c74a61cfd2 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4781,7 +4781,8 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq; sofia_reg_release_gateway(gateway); gateway->pinging = 0; - } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to && strchr(sip->sip_call_id->i_id, '_')) { + } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && + sip && sip->sip_to && sip->sip_call_id && sip->sip_call_id->i_id && strchr(sip->sip_call_id->i_id, '_')) { char *sql; time_t now = switch_epoch_time_now(NULL); const char *call_id = strchr(sip->sip_call_id->i_id, '_') + 1; From 1073f70b6fd2c2ef892982017eab5c5572e824c6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 13:42:56 -0600 Subject: [PATCH 29/32] spread out timer skips to smooth out socket catch-up --- src/switch_rtp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index ec003f9569..8726beabe8 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -3246,9 +3246,9 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { rtp_session->hot_hits++;//+= rtp_session->samples_per_interval; - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s Trigger %d\n", - //switch_core_session_get_name(session), - // rtp_session->hot_hits); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s Hot Hit %d\n", + switch_core_session_get_name(session), + rtp_session->hot_hits); } else { rtp_session->hot_hits = 0; } @@ -3262,21 +3262,21 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ } } - - if (hot_socket) { - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Skip timer\n"); + if (hot_socket && (rtp_session->hot_hits % 10) != 0) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s timer while HOT\n", switch_core_session_get_name(session)); + switch_core_timer_next(&rtp_session->timer); + } else if (hot_socket) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s skip timer once\n", switch_core_session_get_name(session)); rtp_session->sync_packets++; switch_core_timer_sync(&rtp_session->timer); - } else { if (rtp_session->sync_packets) { -#if 0 - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, - "Auto-Flush catching up %d packets (%d)ms.\n", + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, + "%s Auto-Flush catching up %d packets (%d)ms.\n", + switch_core_session_get_name(session), rtp_session->sync_packets, (rtp_session->ms_per_packet * rtp_session->sync_packets) / 1000); -#endif - //switch_core_timer_sync(&rtp_session->timer); } else { switch_core_timer_next(&rtp_session->timer); From 495ed50571e62494349bd0654ba23e754443a3cc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 14:16:36 -0600 Subject: [PATCH 30/32] bump --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index c96f9f8dd9..d1ccc9229a 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.3.7b], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.3.7], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [3]) -AC_SUBST(SWITCH_VERSION_MICRO, [7b]) +AC_SUBST(SWITCH_VERSION_MICRO, [7]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) From de53b3983d6b4bbd2c6c4575317c1a944019c693 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 14:18:40 -0600 Subject: [PATCH 31/32] bump --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index d1ccc9229a..5ff62afc36 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.3.7], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.3.8b], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [3]) -AC_SUBST(SWITCH_VERSION_MICRO, [7]) +AC_SUBST(SWITCH_VERSION_MICRO, [8b]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) From b35ac6b3bd5c970eeeb0239fe4e174f4a1799ee5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 Nov 2012 18:34:27 -0600 Subject: [PATCH 32/32] fix auto_simplify --- src/mod/endpoints/mod_sofia/mod_sofia.c | 9 ++++++--- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 +- src/mod/endpoints/mod_sofia/sofia_glue.c | 17 +++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index f483321e36..73c50565fe 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1097,8 +1097,9 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f if (sofia_test_flag(tech_pvt, TFLAG_SIMPLIFY) && sofia_test_flag(tech_pvt, TFLAG_GOT_ACK)) { - sofia_glue_tech_simplify(tech_pvt); - sofia_clear_flag(tech_pvt, TFLAG_SIMPLIFY); + if (sofia_glue_tech_simplify(tech_pvt)) { + sofia_clear_flag(tech_pvt, TFLAG_SIMPLIFY); + } } while (sofia_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) { @@ -1714,7 +1715,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, NULL); - sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY); + if (switch_true(switch_channel_get_variable(tech_pvt->channel, "sip_auto_simplify"))) { + sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY); + } if (switch_rtp_ready(tech_pvt->rtp_session)) { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 44f17a320f..146ef4fd44 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -1191,7 +1191,7 @@ uint32_t sofia_reg_reg_count(sofia_profile_t *profile, const char *user, const c void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session); switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *session, const char *r_sdp); char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type); -void sofia_glue_tech_simplify(private_object_t *tech_pvt); +int sofia_glue_tech_simplify(private_object_t *tech_pvt); switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host); switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_multi(sofia_profile_t *profile, const char *user, const char *host, time_t reg_time, const char *contact_str, long exptime); switch_bool_t sofia_glue_profile_exists(const char *key); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 388e647cc0..efdce9449e 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -6785,21 +6785,19 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use } -void sofia_glue_tech_simplify(private_object_t *tech_pvt) +int sofia_glue_tech_simplify(private_object_t *tech_pvt) { const char *uuid, *network_addr_a = NULL, *network_addr_b = NULL, *simplify, *simplify_other_channel; switch_channel_t *other_channel = NULL, *inbound_channel = NULL; switch_core_session_t *other_session = NULL, *inbound_session = NULL; uint8_t did_simplify = 0; + int r = 0; if (!switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) || switch_channel_test_flag(tech_pvt->channel, CF_SIMPLIFY)) { - return; + goto end; } - - - if ((uuid = switch_channel_get_partner_uuid(tech_pvt->channel)) - && (other_session = switch_core_session_locate(uuid))) { + if ((uuid = switch_channel_get_partner_uuid(tech_pvt->channel)) && (other_session = switch_core_session_locate(uuid))) { other_channel = switch_core_session_get_channel(other_session); @@ -6807,6 +6805,8 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt) simplify = switch_channel_get_variable(tech_pvt->channel, "sip_auto_simplify"); simplify_other_channel = switch_channel_get_variable(other_channel, "sip_auto_simplify"); + r = 1; + if (switch_true(simplify) && !switch_channel_test_flag(tech_pvt->channel, CF_BRIDGE_ORIGINATOR)) { network_addr_a = switch_channel_get_variable(tech_pvt->channel, "network_addr"); network_addr_b = switch_channel_get_variable(other_channel, "network_addr"); @@ -6851,6 +6851,11 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt) switch_core_session_rwunlock(other_session); } + + + end: + + return r; } void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on)