Merge branch 'signalwire:master' into bugfix/fix-ivr-zombie

This commit is contained in:
Alexis Lina 2022-12-08 11:30:59 +01:00 committed by GitHub
commit 2f9ee65315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 9 deletions

View File

@ -10299,6 +10299,7 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
}
}
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_HEADER_PREFIX);
switch_channel_execute_on(channel, "execute_on_sip_reinvite");
}

View File

@ -167,9 +167,15 @@ void Session::do_hangup_hook()
arglist = Py_BuildValue("(Os)", Self, what);
}
#if PY_VERSION_HEX <= 0x03080000
if (!PyEval_CallObject(hangup_func, arglist)) {
PyErr_Print();
}
#else
if (!PyObject_CallObject(hangup_func, arglist)) {
PyErr_Print();
}
#endif
Py_XDECREF(arglist);
Py_XDECREF(hangup_func_arg);
@ -287,7 +293,7 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
PyObject *pyresult, *arglist, *io = NULL;
int ts = 0;
char *str = NULL, *what = "";
char *str = NULL, *what = (char*)"";
if (TS) {
ts++;
@ -302,9 +308,9 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
if (itype == SWITCH_INPUT_TYPE_DTMF) {
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
io = mod_python_conjure_DTMF(dtmf->digit, dtmf->duration);
what = "dtmf";
what = (char*)"dtmf";
} else if (itype == SWITCH_INPUT_TYPE_EVENT){
what = "event";
what = (char*)"event";
io = mod_python_conjure_event((switch_event_t *) input);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unsupported type!\n");
@ -320,8 +326,12 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
} else {
arglist = Py_BuildValue("(OsO)", Self, what, io);
}
if ((pyresult = PyEval_CallObject(cb_function, arglist))) {
#if PY_VERSION_HEX <= 0x03080000
pyresult = PyEval_CallObject(cb_function, arglist);
#else
pyresult = PyObject_CallObject(cb_function, arglist);
#endif
if (pyresult) {
str = (char *) PyString_AsString(pyresult);
} else {
PyErr_Print();

View File

@ -1465,6 +1465,7 @@ typedef struct {
int done;
switch_thread_t *thread;
switch_mutex_t *mutex;
switch_mutex_t *fence_mutex;
switch_dial_handle_t *dh;
} enterprise_originate_handle_t;
@ -1479,9 +1480,13 @@ struct ent_originate_ringback {
static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thread, void *obj)
{
enterprise_originate_handle_t *handle = (enterprise_originate_handle_t *) obj;
switch_status_t status;
switch_mutex_lock(handle->fence_mutex);
handle->done = 0;
handle->status = switch_ivr_originate(NULL, &handle->bleg, &handle->cause,
switch_mutex_unlock(handle->fence_mutex);
status = switch_ivr_originate(NULL, &handle->bleg, &handle->cause,
handle->bridgeto, handle->timelimit_sec,
handle->table,
handle->cid_name_override,
@ -1492,8 +1497,11 @@ static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thr
&handle->cancel_cause,
handle->dh);
switch_mutex_lock(handle->fence_mutex);
handle->status = status;
handle->done = 1;
switch_mutex_unlock(handle->fence_mutex);
switch_mutex_lock(handle->mutex);
switch_mutex_unlock(handle->mutex);
@ -1697,6 +1705,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
switch_dial_handle_dup(&handles[i].dh, hl->handles[i]);
}
switch_mutex_init(&handles[i].mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&handles[i].fence_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_lock(handles[i].mutex);
switch_thread_create(&handles[i].thread, thd_attr, enterprise_originate_thread, &handles[i], pool);
}
@ -1738,13 +1747,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
for (i = 0; i < x_argc; i++) {
switch_mutex_lock(handles[i].fence_mutex);
if (handles[i].done == 0) {
running++;
} else if (handles[i].done == 1) {
if (handles[i].status == SWITCH_STATUS_SUCCESS) {
handles[i].done = 2;
hp = &handles[i];
switch_mutex_unlock(handles[i].fence_mutex);
goto done;
} else {
handles[i].done = -1;
@ -1753,6 +1763,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
over++;
}
switch_mutex_unlock(handles[i].fence_mutex);
switch_yield(10000);
}

View File

@ -100,7 +100,14 @@ using System.Diagnostics;
Uri uri = new Uri(package);
string urifilename = Path.GetFileName(uri.LocalPath);
string output = Path.Combine(outputfolder ?? librarypath, (outputfilename ?? urifilename));
string cachedir = Environment.GetEnvironmentVariable("FreeSWITCHBuildCachePath") ?? "";
string cached_file = cachedir != "" ? Path.Combine(cachedir, (outputfilename ?? urifilename)) : "";
if (cached_file != "" && File.Exists(cached_file)) {
Log.LogMessage(MessageImportance.High,
"Found package in cache \"" + cached_file + "\".");
File.Copy(cached_file, output);
} else
//if (!File.Exists(output)) // Uncomment to skip download if exists
{
var syncObject = new State

View File

@ -5,6 +5,9 @@
</ImportGroup>
<PropertyGroup>
<YasmPropsImported>true</YasmPropsImported>
<Is64yasm Condition="$([System.Environment]::Is64BitProcess)">true</Is64yasm>
<PackageToDownload Condition="'$(Is64yasm)' == 'true'">http://files.freeswitch.org/downloads/win64/yasm.exe</PackageToDownload>
<PackageToDownload Condition="'$(Is64yasm)' != 'true'">http://files.freeswitch.org/downloads/win32/yasm.exe</PackageToDownload>
</PropertyGroup>
<!--
@ -28,8 +31,9 @@
-->
<Target Name="YasmDownloadTarget" BeforeTargets="CustomBuild" DependsOnTargets="">
<Message Text="System is 64 bit." Condition="'$(Is64yasm)' == 'true'" Importance="High" />
<DownloadPackageTask
package="http://files.freeswitch.org/downloads/win32/yasm.exe"
package="$(PackageToDownload)"
expectfileordirectory="$(ProjectDir)\yasm.exe"
outputfolder="$(ProjectDir)\"
outputfilename=""