From ded2a4c1beaf9bed6d7666fe505e8392fff5eca6 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 30 Nov 2022 23:18:55 +0300 Subject: [PATCH 01/28] [Core] Fix crash in enterprise originate: memory fence the handles. --- src/switch_ivr_originate.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 31b326bc1f..f1e3e39de1 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -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); } From 62d3e52cf90621bb71a1d2b66edfc7692a3e90ef Mon Sep 17 00:00:00 2001 From: morwin1 <118400677+morwin1@users.noreply.github.com> Date: Wed, 7 Dec 2022 04:07:19 +1100 Subject: [PATCH 02/28] [mod_python3] Fix compiler warnings --- .../mod_python3/freeswitch_python.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/mod/languages/mod_python3/freeswitch_python.cpp b/src/mod/languages/mod_python3/freeswitch_python.cpp index 77c04fa9fc..e35c7ed464 100644 --- a/src/mod/languages/mod_python3/freeswitch_python.cpp +++ b/src/mod/languages/mod_python3/freeswitch_python.cpp @@ -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(); From 4454ea58fd1fc2cfb9560bc7c1290b8fc1a6a02d Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 7 Dec 2022 23:31:51 +0300 Subject: [PATCH 03/28] [Build-System] Improve build time on Windows: Do not download a pre-compiled binary if it's found in a folder pointed by the FreeSWITCHBuildCachePath environment variable. --- w32/downloadpackage.task | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/w32/downloadpackage.task b/w32/downloadpackage.task index 0c7081a0fb..ef5322cfd7 100644 --- a/w32/downloadpackage.task +++ b/w32/downloadpackage.task @@ -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 From 52e97e8d0a361f6d5de2ede664b5e18c2fe84e3c Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Thu, 8 Dec 2022 03:02:42 +0300 Subject: [PATCH 04/28] [Build-System] Fix build on Windows 11: yasm tool compiled for x86 does not work on x64 system. Download yasm.exe 64bit instead. --- w32/yasm.props | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/w32/yasm.props b/w32/yasm.props index 3ebcc6c84c..ffc4151426 100644 --- a/w32/yasm.props +++ b/w32/yasm.props @@ -5,6 +5,9 @@ true + true + http://files.freeswitch.org/downloads/win64/yasm.exe + http://files.freeswitch.org/downloads/win32/yasm.exe + Date: Fri, 9 Dec 2022 01:43:10 +0300 Subject: [PATCH 05/28] [Build-System] Update SQLite to 3.40.0 on Windows --- libs/.gitignore | 1 + libs/win32/sqlite/sqlite.2017.vcxproj | 4 ++-- w32/Library/FreeSwitchCore.2017.vcxproj | 8 ++++---- w32/download_sqlite.props | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/.gitignore b/libs/.gitignore index 7ed9df2c58..87da2671c6 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -617,6 +617,7 @@ srtp/build/compile /curl-*/ /sqlite-*.zip /sqlite-*/ +/sqlite/ /ldns/ /portaudio/ portaudio.*.log diff --git a/libs/win32/sqlite/sqlite.2017.vcxproj b/libs/win32/sqlite/sqlite.2017.vcxproj index fb218bc89b..22becd5fff 100644 --- a/libs/win32/sqlite/sqlite.2017.vcxproj +++ b/libs/win32/sqlite/sqlite.2017.vcxproj @@ -323,10 +323,10 @@ - + - + diff --git a/w32/Library/FreeSwitchCore.2017.vcxproj b/w32/Library/FreeSwitchCore.2017.vcxproj index e30868d48c..2f7a3239bd 100644 --- a/w32/Library/FreeSwitchCore.2017.vcxproj +++ b/w32/Library/FreeSwitchCore.2017.vcxproj @@ -128,7 +128,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\" Disabled - ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite-amalgamation-3080401;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) + ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions) true EnableFastChecks @@ -178,7 +178,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\" Disabled - ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite-amalgamation-3080401;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) + ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions) true EnableFastChecks @@ -219,7 +219,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\" MaxSpeed - ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite-amalgamation-3080401;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) + ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;CRASH_PROT;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions) MultiThreadedDLL Create @@ -257,7 +257,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\" MaxSpeed - ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite-amalgamation-3080401;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) + ..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\sqlite;..\..\libs\speex-1.2rc1\include;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\freetype\include;..\..\libs\libpng;..\..\libs\libvpx;%(AdditionalIncludeDirectories) CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;CRASH_PROT;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions) MultiThreadedDLL Create diff --git a/w32/download_sqlite.props b/w32/download_sqlite.props index 5ec04a3774..8f4788d264 100644 --- a/w32/download_sqlite.props +++ b/w32/download_sqlite.props @@ -5,6 +5,7 @@ true + 3400000