diff options
56 files changed, 436 insertions, 959 deletions
@@ -12,6 +12,25 @@ --- Functionality changes from Asterisk 14 to Asterisk 15 -------------------- ------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +--- Functionality changes from Asterisk 14.4.0 to Asterisk 14.5.0 ------------ +------------------------------------------------------------------------------ + +res_pjsip_config_wizard +------------------ + * Two new parameters have been added to the pjsip config wizard. + Setting 'sends_line_with_registrations' to true will cause the wizard + to skip the creation of an identify object to match incoming requests + to the endpoint and instead add the line and endpoint parameters to + the outbound registration object. + Setting 'outbound_proxy' is a shortcut for adding individual + endpoint/outbound_proxy, aor/outbound_proxy and registration/outbound_proxy + parameters. + +------------------------------------------------------------------------------ +--- Functionality changes from Asterisk 14.3.0 to Asterisk 14.4.0 ------------ +------------------------------------------------------------------------------ + Build System ------------------ * LOW_MEMORY no longer has an effect on Asterisk ABI. Symbols that were @@ -253,9 +253,6 @@ SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install) SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean) SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean) SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall) -MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript) -MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags) -MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs) MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree) ifneq ($(findstring darwin,$(OSARCH)),) @@ -344,41 +341,14 @@ ifeq ($(filter %.menuselect,$(MAKECMDGOALS)),) menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) endif -$(MOD_SUBDIRS_EMBED_LDSCRIPT): - +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules - -$(MOD_SUBDIRS_EMBED_LDFLAGS): - +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules - -$(MOD_SUBDIRS_EMBED_LIBS): - +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules - $(MOD_SUBDIRS_MENUSELECT_TREE): +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts -makeopts.embed_rules: menuselect.makeopts - @echo "Generating embedded module rules ..." - @rm -f $@ - +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT) - +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS) - +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS) - -$(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules +$(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h ifeq ($(findstring $(OSARCH), mingw32 cygwin ),) - ifeq ($(shell grep ^MENUSELECT_EMBED=$$ menuselect.makeopts 2>/dev/null),) - # Non-windows: - # ensure that all module subdirectories are processed before 'main' during - # a parallel build, since if there are modules selected to be embedded the - # directories containing them must be completed before the main Asterisk - # binary can be built. - # If MENUSELECT_EMBED is empty, we don't need this and allow 'main' to be - # be built with only third_party first. -main: $(filter-out main,$(MOD_SUBDIRS)) - else main: third-party - endif else # Windows: we need to build main (i.e. the asterisk dll) first, # followed by res, followed by the other directories, because @@ -443,7 +413,6 @@ distclean: $(SUBDIRS_DIST_CLEAN) _clean @$(MAKE) -C menuselect dist-clean @$(MAKE) -C sounds dist-clean rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps - rm -f makeopts.embed_rules rm -f config.log config.status config.cache rm -rf autom4te.cache rm -f include/asterisk/autoconfig.h @@ -637,26 +606,56 @@ oldmodcheck: ld-cache-update: ifneq ($(LDCONFIG),) +ifeq ($(DESTDIR),) # DESTDIR means binary archive creation; ldconfig should be run on postinst @if [ $${EUID} -eq 0 ] ; then \ - $(LDCONFIG) "$(DESTDIR)$(ASTLIBDIR)/" ; \ + $(LDCONFIG) "$(ASTLIBDIR)/" ; \ else \ echo " WARNING WARNING WARNING" ;\ echo "" ;\ echo " You cannot rebuild the system linker cache unless you are root. " ;\ - echo " You MUST do one of the follwing..." ;\ + echo " You MUST do one of the following..." ;\ echo " * Re-run 'make install' as root. " ;\ - echo " * Run 'ldconfig $(DESTDIR)$(ASTLIBDIR)' as root. " ;\ - echo " * Run asterisk with 'LD_LIBRARY_PATH=$(DESTDIR)$(ASTLIBDIR) asterisk' " ;\ + echo " * Run 'ldconfig $(ASTLIBDIR)' as root. " ;\ + echo " * Run asterisk with 'LD_LIBRARY_PATH=$(ASTLIBDIR) asterisk' " ;\ echo "" ;\ echo " WARNING WARNING WARNING" ;\ fi endif +endif -ifeq ($(and $(findstring 64,$(HOST_CPU)),$(findstring lib64,$(DESTDIR)$(ASTLIBDIR))),lib64) -_oldlibdir = $(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR)) +export _oldlibdir = +export _oldmoddir = +ifeq ($(findstring 64,$(HOST_CPU)),64) + # Strip any trailing '/' so the dir and notdir functions work correctly + _current_libdir = $(patsubst %/,%,$(DESTDIR)$(ASTLIBDIR)) + + # Only process if the paths end in lib64 or lib. + # If we're installing to lib64, check lib for orphans. + # If we're installing to lib, check lib64 for orphans. + # Otherwise, leave _oldlibdir empty. + ifeq ($(notdir $(_current_libdir)),lib64) + _oldlibdir = $(dir $(_current_libdir))lib + else ifeq ($(notdir $(_current_libdir)),lib) + _oldlibdir = $(dir $(_current_libdir))lib64 + endif + + # Strip any trailing '/' so the dir and notdir functions work correctly + _current_moddir = $(patsubst %/,%,$(DESTDIR)$(ASTMODDIR)) + + # Only process if the paths contain /lib64/ or /lib/. + # If we're installing to lib64, check lib for orphans. + # If we're installing to lib, check lib64 for orphans. + # Otherwise, leave _oldmoddir empty. + ifeq ($(findstring /lib64/,$(_current_moddir)),/lib64/) + _oldmoddir = $(subst /lib64/,/lib/,$(_current_moddir)) + else ifeq ($(findstring /lib/,$(_current_moddir)),/lib/) + _oldmoddir = $(subst /lib/,/lib64/,$(_current_moddir)) + endif +endif check-old-libdir: - @oldfiles=`find "$(_oldlibdir)" -name libasterisk* -print -quit -o \( -path *asterisk/modules/* -a -name *.so \) -print -quit` ;\ + @test -n "$(_oldlibdir)" -a -d "$(_oldlibdir)" || exit 0 ;\ + oldfiles=`find "$(_oldlibdir)" -name libasterisk* -print -quit -o \( -path *asterisk/modules/* -a -name *.so \) -print -quit 2>/dev/null` ;\ if [ "x$$oldfiles" != "x" ] ; then \ echo " WARNING WARNING WARNING" ;\ echo "" ;\ @@ -678,10 +677,6 @@ check-old-libdir: echo "" ;\ echo " WARNING WARNING WARNING" ;\ fi -else -check-old-libdir: - -endif badshell: ifneq ($(filter ~%,$(DESTDIR)),) @@ -943,7 +938,7 @@ main-binuninstall: _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall rm -f "$(DESTDIR)$(ASTMODDIR)/"* - rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))/"* + test -n "$(_oldmoddir)" -a -d "$(_oldmoddir)" && rm -f "$(_oldmoddir)/"* || : rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey" rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport" rm -rf "$(DESTDIR)$(ASTHEADERDIR)" @@ -976,7 +971,7 @@ uninstall: _uninstall uninstall-all: _uninstall rm -rf "$(DESTDIR)$(ASTMODDIR)" - rm -rf "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))" + test -n "$(_oldmoddir)" -a -d "$(_oldmoddir)" && rm -rf "$(_oldmoddir)" || : rm -rf "$(DESTDIR)$(ASTVARLIBDIR)" rm -rf "$(DESTDIR)$(ASTDATADIR)" rm -rf "$(DESTDIR)$(ASTSPOOLDIR)" @@ -1033,7 +1028,7 @@ menuselect/nmenuselect: menuselect/makeopts .lastclean menuselect/makeopts: makeopts .lastclean +$(MAKE_MENUSELECT) makeopts -menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc) $(wildcard $(dir)/*.xml)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts +menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc) $(wildcard $(dir)/*.xml)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml utils/utils.xml agi/agi.xml configure makeopts @echo "Generating input for menuselect ..." @echo "<?xml version=\"1.0\"?>" > $@ @echo >> $@ @@ -1046,7 +1041,6 @@ menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(di fi @cat utils/utils.xml >> $@ @cat agi/agi.xml >> $@ - @cat build_tools/embed_modules.xml >> $@ @cat sounds/sounds.xml >> $@ @echo "</menu>" >> $@ @@ -1097,9 +1091,6 @@ check-alembic: makeopts .PHONY: $(SUBDIRS_CLEAN) .PHONY: $(SUBDIRS_UNINSTALL) .PHONY: $(SUBDIRS) -.PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT) -.PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS) -.PHONY: $(MOD_SUBDIRS_EMBED_LIBS) FORCE: diff --git a/Makefile.moddir_rules b/Makefile.moddir_rules index 95e62788f..59190bece 100644 --- a/Makefile.moddir_rules +++ b/Makefile.moddir_rules @@ -18,10 +18,6 @@ # Also note that we can only set one variable per rule, so we have to # repeat the left hand side to set multiple variables. -ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) - _ASTCFLAGS+=${GC_CFLAGS} -endif - ifneq ($(findstring STATIC_BUILD,$(MENUSELECT_CFLAGS)),) STATIC_BUILD=-static endif @@ -29,7 +25,7 @@ endif include $(ASTTOPDIR)/Makefile.rules # If MODULE_PREFIX is defined, use it to run the standard functions to set -# C_MODS, CC_MODS, LOADABLE_MODS and EMBEDDED_MODS. +# C_MODS, CC_MODS and LOADABLE_MODS # Each word of MODULE_PREFIX is a prefix for filenames that we consider # valid C or CC modules (eg. app, func ...). Note that the underscore # is added here, and does not need to be in MODULE_PREFIX @@ -46,11 +42,7 @@ endif C_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_C_MODS)) CC_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_CC_MODS)) -ifneq ($(findstring EMBED_$(MENUSELECT_CATEGORY),$(MENUSELECT_EMBED)),) - EMBEDDED_MODS:=$(C_MODS) $(CC_MODS) -else - LOADABLE_MODS:=$(C_MODS) $(CC_MODS) -endif +LOADABLE_MODS:=$(C_MODS) $(CC_MODS) # Both C++ and C++ sources need their module name in AST_MODULE # We also pass whatever _INCLUDE list is generated by menuselect @@ -67,7 +59,7 @@ MOD_ASTCFLAGS=\ $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE)) define MOD_ADD_SOURCE -$$(if $$(filter $(1),$$(EMBEDDED_MODS)),modules.link,$(1).so): $$(subst $(3),$(5),$(2)) +$(1).so: $$(subst $(3),$(5),$(2)) $$(subst $(3),$(5),$(2)): _ASTCFLAGS+=$$(call MOD_ASTCFLAGS,$(1)) .$(1).moduleinfo: MODULEINFO_EXTRA_OUTPUT=" $$(addprefix $$(SUBDIR)/,$$(subst $(3),$(5),$(2)) $$(subst $(3),$(4),$(2)))" # The use of wildcard ensures that 'make menuselect' will not fail for modules that @@ -96,16 +88,11 @@ endif $(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB)) $(LOADABLE_MODS:%=%.so): _ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS)) -$(EMBEDDED_MODS:%=%.o): _ASTCFLAGS+=-DEMBEDDED_MODULE=$* - $(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o $(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo -modules.link: $(addsuffix .eo,$(filter $(EMBEDDED_MODS),$(C_MODS))) - .PHONY: clean uninstall _all moduleinfo makeopts -ifneq ($(LOADABLE_MODS),) _all: $(LOADABLE_MODS:%=%.so) ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) # linker options and extra libraries for cygwin @@ -113,28 +100,6 @@ ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) LIBS+=-L$(ASTTOPDIR)/main -lasterisk -L$(ASTTOPDIR)/res $($@_LIBS) # additional libraries in res/ endif -endif - -ifneq ($(EMBEDDED_MODS),) -_all: modules.link -__embed_ldscript: - @echo "../$(SUBDIR)/modules.link" -__embed_ldflags: - @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))" - @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))" -__embed_libs: - @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))" - @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))" -else -__embed_ldscript: -__embed_ldflags: -__embed_libs: -endif - -modules.link: - @rm -f $@ - @for file in $(patsubst %,$(SUBDIR)/%,$(filter %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done - @for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done clean:: rm -f *.so *.o *.oo *.eo *.i *.ii @@ -177,7 +142,7 @@ dist-clean:: echo "</member>" >> $@ .moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(sort $(ALL_C_MODS) $(ALL_CC_MODS)))) $(wildcard $(call tolower,$(MENUSELECT_CATEGORY)).xml) - @echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\" remove_on_change=\"$(SUBDIR)/modules.link\">" > $@ + @echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\">" > $@ @cat $^ >> $@ @echo "</category>" >> $@ diff --git a/Makefile.rules b/Makefile.rules index 45989d684..ee8eabd6f 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -185,18 +185,6 @@ endif $(ECHO_PREFIX) echo " [LDXX] $^ -> $@" $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(CXX_LDFLAGS_SO) $^ $(CXX_LIBS) -%.eo: %.o - $(ECHO_PREFIX) echo " [EMBED] $< -> $@" - $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/make_linker_eo_script $* > .$@.ld - $(CMD_PREFIX) $(LD) -r -T .$@.ld -o $@ $< - $(CMD_PREFIX) rm -f .$@.ld - -%.eo: %.oo - $(ECHO_PREFIX) echo " [EMBED] $< -> $@" - $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/make_linker_eo_script $* > .$@.ld - $(CMD_PREFIX) $(LD) -r -T .$@.ld -o $@ $< - $(CMD_PREFIX) rm -f .$@.ld - %: %.o $(ECHO_PREFIX) echo " [LD] $^ -> $@" $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(PTHREAD_CFLAGS) $(_ASTLDFLAGS) $^ $(CXX_LIBS) $(ASTLDFLAGS) diff --git a/UPGRADE.txt b/UPGRADE.txt index 1afacf2a4..62bb80182 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -23,6 +23,13 @@ === UPGRADE-14.txt -- Upgrade info for 13 to 14 =========================================================== +From 14.4.0 to 14.5.0: + +Core: + - Support for embedded modules has been removed. This has not worked in + many years. LOADABLE_MODULES menuselect option is also removed as + loadable module support is now always enabled. + From 14.3.0 to 14.4.0: res_rtp_asterisk: diff --git a/addons/Makefile b/addons/Makefile index a02d35f7d..d12d0fd3b 100644 --- a/addons/Makefile +++ b/addons/Makefile @@ -59,7 +59,7 @@ endif include $(ASTTOPDIR)/Makefile.moddir_rules -$(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): _ASTCFLAGS+=$(H323CFLAGS) +chan_ooh323.so: _ASTCFLAGS+=$(H323CFLAGS) $(call MOD_ADD_C,chan_ooh323,$(H323SOURCE)) $(call MOD_ADD_C,format_mp3,mp3/common.c mp3/dct64_i386.c mp3/decode_ntom.c mp3/layer3.c mp3/tabinit.c mp3/interface.c) diff --git a/apps/app_dial.c b/apps/app_dial.c index 1cb91811f..c8fcf4696 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1186,9 +1186,6 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, int prestart = num.busy + num.congestion + num.nochan; int orig = *to; struct ast_channel *peer = NULL; -#ifdef HAVE_EPOLL - struct chanlist *epollo; -#endif struct chanlist *outgoing = AST_LIST_FIRST(out_chans); /* single is set if only one destination is enabled */ int single = outgoing && !AST_LIST_NEXT(outgoing, node); @@ -1227,12 +1224,6 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, is_cc_recall = ast_cc_is_recall(in, &cc_recall_core_id, NULL); -#ifdef HAVE_EPOLL - AST_LIST_TRAVERSE(out_chans, epollo, node) { - ast_poll_channel_add(in, epollo->chan); - } -#endif - while ((*to = ast_remaining_ms(start, orig)) && !peer) { struct chanlist *o; int pos = 0; /* how many channels do we handle */ @@ -1359,9 +1350,6 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, f = ast_read(winner); if (!f) { ast_channel_hangupcause_set(in, ast_channel_hangupcause(c)); -#ifdef HAVE_EPOLL - ast_poll_channel_del(in, c); -#endif ast_channel_publish_dial(in, c, NULL, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(c))); ast_hangup(c); c = o->chan = NULL; @@ -1786,13 +1774,6 @@ skip_frame:; publish_dial_end_event(in, out_chans, NULL, "NOANSWER"); } -#ifdef HAVE_EPOLL - AST_LIST_TRAVERSE(out_chans, epollo, node) { - if (epollo->chan) - ast_poll_channel_del(in, epollo->chan); - } -#endif - if (is_cc_recall) { ast_cc_completed(in, "Recall completed!"); } diff --git a/apps/app_queue.c b/apps/app_queue.c index 946869612..9bba6762d 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -4794,9 +4794,6 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte char membername[80] = ""; long starttime = 0; long endtime = 0; -#ifdef HAVE_EPOLL - struct callattempt *epollo; -#endif char *inchan_name; struct timeval start_time_tv = ast_tvnow(); int canceled_by_caller = 0; /* 1 when caller hangs up or press digit or press * */ @@ -4806,13 +4803,6 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte ast_channel_unlock(qe->chan); starttime = (long) time(NULL); -#ifdef HAVE_EPOLL - for (epollo = outgoing; epollo; epollo = epollo->q_next) { - if (epollo->chan) { - ast_poll_channel_add(in, epollo->chan); - } - } -#endif while ((*to = ast_remaining_ms(start_time_tv, orig)) && !peer) { int numlines, retry, pos = 1; @@ -5325,14 +5315,6 @@ skip_frame:; publish_dial_end_event(qe->chan, outgoing, NULL, "NOANSWER"); } -#ifdef HAVE_EPOLL - for (epollo = outgoing; epollo; epollo = epollo->q_next) { - if (epollo->chan) { - ast_poll_channel_del(in, epollo->chan); - } - } -#endif - return peer; } diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml index a06d515f3..f05f42869 100644 --- a/build_tools/cflags.xml +++ b/build_tools/cflags.xml @@ -19,10 +19,6 @@ <member name="STATIC_BUILD" displayname="Build static binaries"> <support_level>extended</support_level> </member> - <member name="LOADABLE_MODULES" displayname="Runtime module loading"> - <defaultenabled>yes</defaultenabled> - <support_level>core</support_level> - </member> <member name="DEBUG_FD_LEAKS" displayname="Enable File Descriptor Leak Detection"> <support_level>core</support_level> </member> diff --git a/build_tools/embed_modules.xml b/build_tools/embed_modules.xml deleted file mode 100644 index a7e4cfd5d..000000000 --- a/build_tools/embed_modules.xml +++ /dev/null @@ -1,46 +0,0 @@ - <category name="MENUSELECT_EMBED" displayname="Module Embedding" positive_output="yes" remove_on_change="main/asterisk"> - <member name="EMBED_ADDONS" displayname="Add-ons" remove_on_change="addons/*.o addons/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_APPS" displayname="Applications" remove_on_change="apps/*.o apps/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_BRIDGES" displayname="Bridging Technologies" remove_on_change="bridges/*.o bridges/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_CDR" displayname="Call Detail Recording" remove_on_change="cdr/*.o cdr/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_CHANNELS" displayname="Channels" remove_on_change="channels/*.o channels/*/*.o channels/*.oo channels/*/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_CODECS" displayname="Coders/Decoders" remove_on_change="codecs/*.o codecs/*/*.o codecs/*/*/*.o codecs/*/*.a codecs/*/*/*.a codecs/*.oo codecs/*/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_FORMATS" displayname="File Formats" remove_on_change="formats/*.o formats/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_FUNCS" displayname="Dialplan Functions" remove_on_change="funcs/*.o funcs/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_PBX" displayname="PBX Functionality" remove_on_change="pbx/*.o pbx/*/*.o pbx/*.oo pbx/*/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_RES" displayname="Resource Modules" remove_on_change="res/*.o res/*/*.o res/*.oo res/*/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - <member name="EMBED_TEST" displayname="Test Modules" remove_on_change="tests/*.o tests/*.oo"> - <depend>gnu_ld</depend> - <support_level>extended</support_level> - </member> - </category> diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c index cbd9e0558..33cc1b8ae 100644 --- a/cdr/cdr_pgsql.c +++ b/cdr/cdr_pgsql.c @@ -202,6 +202,7 @@ static int pgsql_log(struct ast_cdr *cdr) struct ast_tm tm; char *pgerror; PGresult *result; + int res = -1; ast_mutex_lock(&pgsql_lock); @@ -231,13 +232,14 @@ static int pgsql_log(struct ast_cdr *cdr) if (connected) { struct columns *cur; struct ast_str *sql = ast_str_create(maxsize), *sql2 = ast_str_create(maxsize2); - char buf[257], escapebuf[513], *value; + char buf[257]; + char *escapebuf = NULL, *value; char *separator = ""; + size_t bufsize = 513; - if (!sql || !sql2) { - ast_free(sql); - ast_free(sql2); - return -1; + escapebuf = ast_malloc(bufsize); + if (!escapebuf || !sql || !sql2) { + goto ast_log_cleanup; } ast_str_set(&sql, 0, "INSERT INTO %s (", table); @@ -358,10 +360,28 @@ static int pgsql_log(struct ast_cdr *cdr) } /* XXX Might want to handle dates, times, and other misc fields here XXX */ } else { - if (value) + if (value) { + size_t required_size = strlen(value) * 2 + 1; + + /* If our argument size exceeds our buffer, grow it, + * as PQescapeStringConn() expects the buffer to be + * adequitely sized and does *NOT* do size checking. + */ + if (required_size > bufsize) { + char *tmpbuf = ast_realloc(escapebuf, required_size); + + if (!tmpbuf) { + AST_RWLIST_UNLOCK(&psql_columns); + goto ast_log_cleanup; + } + + escapebuf = tmpbuf; + bufsize = required_size; + } PQescapeStringConn(conn, escapebuf, value, strlen(value), NULL); - else + } else { escapebuf[0] = '\0'; + } LENGTHEN_BUF2(strlen(escapebuf) + 3); ast_str_append(&sql2, 0, "%s'%s'", separator, escapebuf); } @@ -395,10 +415,7 @@ static int pgsql_log(struct ast_cdr *cdr) PQfinish(conn); conn = NULL; connected = 0; - ast_mutex_unlock(&pgsql_lock); - ast_free(sql); - ast_free(sql2); - return -1; + goto ast_log_cleanup; } } result = PQexec(conn, ast_str_buffer(sql)); @@ -419,23 +436,17 @@ static int pgsql_log(struct ast_cdr *cdr) pgerror = PQresultErrorMessage(result); ast_log(LOG_ERROR, "HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD!\n"); ast_log(LOG_ERROR, "Reason: %s\n", pgerror); - } else { + } else { /* Second try worked out ok */ totalrecords++; records++; - ast_mutex_unlock(&pgsql_lock); - PQclear(result); - return 0; + res = 0; } } - ast_mutex_unlock(&pgsql_lock); - PQclear(result); - ast_free(sql); - ast_free(sql2); - return -1; } else { totalrecords++; records++; + res = 0; } PQclear(result); @@ -447,11 +458,14 @@ static int pgsql_log(struct ast_cdr *cdr) maxsize2 = ast_str_strlen(sql2); } +ast_log_cleanup: + ast_free(escapebuf); ast_free(sql); ast_free(sql2); } + ast_mutex_unlock(&pgsql_lock); - return 0; + return res; } /* This function should be called without holding the pgsql_columns lock */ diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c index 8d9d5dfce..5fe66784b 100644 --- a/cel/cel_pgsql.c +++ b/cel/cel_pgsql.c @@ -179,11 +179,14 @@ static void pgsql_log(struct ast_event *event) if (connected) { struct columns *cur; struct ast_str *sql = ast_str_create(maxsize), *sql2 = ast_str_create(maxsize2); - char buf[257], escapebuf[513]; + char buf[257]; + char *escapebuf = NULL; const char *value; int first = 1; + size_t bufsize = 513; - if (!sql || !sql2) { + escapebuf = ast_malloc(bufsize); + if (!escapebuf || !sql || !sql2) { goto ast_log_cleanup; } @@ -307,6 +310,23 @@ static void pgsql_log(struct ast_event *event) /* XXX Might want to handle dates, times, and other misc fields here XXX */ } else { if (value) { + size_t required_size = strlen(value) * 2 + 1; + + /* If our argument size exceeds our buffer, grow it, + * as PQescapeStringConn() expects the buffer to be + * adequitely sized and does *NOT* do size checking. + */ + if (required_size > bufsize) { + char *tmpbuf = ast_realloc(escapebuf, required_size); + + if (!tmpbuf) { + AST_RWLIST_UNLOCK(&psql_columns); + goto ast_log_cleanup; + } + + escapebuf = tmpbuf; + bufsize = required_size; + } PQescapeStringConn(conn, escapebuf, value, strlen(value), NULL); } else { escapebuf[0] = '\0'; @@ -361,8 +381,6 @@ static void pgsql_log(struct ast_event *event) ast_log(LOG_ERROR, "Reason: %s\n", pgerror); } } - PQclear(result); - goto ast_log_cleanup; } PQclear(result); @@ -377,6 +395,7 @@ static void pgsql_log(struct ast_event *event) ast_log_cleanup: ast_free(sql); ast_free(sql2); + ast_free(escapebuf); } ast_mutex_unlock(&pgsql_lock); diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc index 595ac8fee..87342b1d0 100644 --- a/channels/chan_vpb.cc +++ b/channels/chan_vpb.cc @@ -373,7 +373,9 @@ static struct ast_channel_tech vpb_tech = { hangup: vpb_hangup, answer: vpb_answer, read: vpb_read, + read_stream: NULL, write: vpb_write, + write_stream: NULL, send_text: NULL, send_image: NULL, send_html: NULL, @@ -404,7 +406,9 @@ static struct ast_channel_tech vpb_tech_indicate = { hangup: vpb_hangup, answer: vpb_answer, read: vpb_read, + read_stream: NULL, write: vpb_write, + write_stream: NULL, send_text: NULL, send_image: NULL, send_html: NULL, diff --git a/codecs/Makefile b/codecs/Makefile index 684ccc679..64f77ebaa 100644 --- a/codecs/Makefile +++ b/codecs/Makefile @@ -38,7 +38,7 @@ include $(ASTTOPDIR)/Makefile.moddir_rules ifneq ($(GSM_INTERNAL),no) GSM_INCLUDE := -I$(SUB_GSM)/inc -$(if $(filter codec_gsm,$(EMBEDDED_MODS)),modules.link,codec_gsm.so): $(SUB_GSM)/lib/libgsm.a +codec_gsm.so: $(SUB_GSM)/lib/libgsm.a endif # Don't run the implicit rules for this target. @@ -57,7 +57,7 @@ clean:: .PHONY: $(SUB_DIRS) -$(if $(filter codec_lpc10,$(EMBEDDED_MODS)),modules.link,codec_lpc10.so): $(LIBLPC10) +codec_lpc10.so: $(LIBLPC10) # Don't run the implicit rules for this target. $(LIBLPC10): $(SUB_LPC10) ; @@ -67,7 +67,7 @@ $(SUB_LPC10): ifneq ($(ILBC_INTERNAL),no) -$(if $(filter codec_ilbc,$(EMBEDDED_MODS)),modules.link,codec_ilbc.so): $(LIBILBC) +codec_ilbc.so: $(LIBILBC) else ILBC_INCLUDE += -DILBC_WEBRTC endif diff --git a/configs/samples/musiconhold.conf.sample b/configs/samples/musiconhold.conf.sample index 3df29bf69..b2980fc1d 100644 --- a/configs/samples/musiconhold.conf.sample +++ b/configs/samples/musiconhold.conf.sample @@ -85,7 +85,11 @@ directory=moh ;[ulawstream] ;mode=custom ;application=/usr/bin/streamplayer 192.168.100.52 888 -;format=ulaw +;format=ulaw ; The 'format' option specifies the audio format that the +; ; 'application' will provide to Asterisk. In this example, +; ; streamplayer will output ulaw samples so we need to set the +; ; format to ulaw so that Asterisk knows how to interpret the +; ; incoming audio. ; mpg123 on Solaris does not always exit properly; madplay may be a better ; choice diff --git a/configs/samples/pjsip_wizard.conf.sample b/configs/samples/pjsip_wizard.conf.sample index 0f46083af..8c8572e4d 100644 --- a/configs/samples/pjsip_wizard.conf.sample +++ b/configs/samples/pjsip_wizard.conf.sample @@ -79,6 +79,13 @@ ; sends_auth must also be specified. ; (default: "no") +;sends_line_with_registrations= ; Setting this to true will cause the wizard to + ; skip the creation of an identify object to match + ; incoming requests to the endpoint and instead add the + ; line and endpoint parameters to the outbound + ; registration object. + ; (default: "no") + ;accepts_registrations= ; Will create an aor with dynamic contacts which will ; accept registrations. ; accepts_auth must also be specified. @@ -96,6 +103,11 @@ ; SRV records are not currently supported. ; (default: "") +;outbound_proxy= ; Setting this is a shortcut for setting + ; endpoint/outbound_proxy + ; aor/outbound_proxy + ; registration/outbound_proxy + ;transport= ; The transport to use for the endpoint and registrations ; (default: the pjsip default) @@ -704,8 +704,6 @@ AST_NO_STRICT_OVERFLOW AST_FORTIFY_SOURCE AST_TRAMPOLINES AST_DECLARATION_AFTER_STATEMENT -GC_LDFLAGS -GC_CFLAGS AST_UNDEFINED_SANITIZER AST_LEAK_SANITIZER AST_THREAD_SANITIZER @@ -4892,28 +4890,6 @@ if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then fi fi -# -# The following code for detecting lib64 was taken from Fedora's -# /usr/share/config.site with a modification to check that the -# /usr/lib64 directory actually exists. This prevents libdir from -# being set to /usr/lib64 on 64-bit systems that still use /usr/lib. -# -if test "$prefix" = /usr ||\ - { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; } -then - for i in x86_64 ppc64 s390x aarch64; do - if test $host_cpu = $i; then - if test "$libdir" = '${exec_prefix}/lib' &&\ - { test -d "${exec_prefix}/lib64" || test -d "${ac_default_prefix}/lib64" ; } ; then - libdir='${exec_prefix}/lib64' - { $as_echo "$as_me:${as_lineno-$LINENO}: Setting libdir=${libdir} " >&5 -$as_echo "$as_me: Setting libdir=${libdir} " >&6;} - fi - break - fi - done -fi - BUILD_PLATFORM=${build} BUILD_CPU=${build_cpu} BUILD_VENDOR=${build_vendor} @@ -18920,62 +18896,6 @@ CFLAGS="${saved_sanitize_CFLAGS}" LDFLAGS="${saved_sanitize_LDFLAGS}" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -ffunction-sections support" >&5 -$as_echo_n "checking for -ffunction-sections support... " >&6; } -saved_CFLAGS="${CFLAGS}" -CFLAGS="${CFLAGS} -ffunction-sections" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -int x = 1; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - saved_LDFLAGS="${LDFLAGS}" - LDFLAGS="${LDFLAGS} -Wl,--gc-sections" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --gc-sections support" >&5 -$as_echo_n "checking for --gc-sections support... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -int x = 1; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - GC_CFLAGS="-ffunction-sections" - GC_LDFLAGS="-Wl,--gc-sections" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="${saved_LDFLAGS}" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -CFLAGS="${saved_CFLAGS}" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wdeclaration-after-statement support" >&5 $as_echo_n "checking for -Wdeclaration-after-statement support... " >&6; } if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then diff --git a/configure.ac b/configure.ac index 890f32d47..b0f04887a 100644 --- a/configure.ac +++ b/configure.ac @@ -135,27 +135,6 @@ if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then fi fi -# -# The following code for detecting lib64 was taken from Fedora's -# /usr/share/config.site with a modification to check that the -# /usr/lib64 directory actually exists. This prevents libdir from -# being set to /usr/lib64 on 64-bit systems that still use /usr/lib. -# -if test "$prefix" = /usr ||\ - { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; } -then - for i in x86_64 ppc64 s390x aarch64; do - if test $host_cpu = $i; then - if test "$libdir" = '${exec_prefix}/lib' &&\ - { test -d "${exec_prefix}/lib64" || test -d "${ac_default_prefix}/lib64" ; } ; then - libdir='${exec_prefix}/lib64' - AC_MSG_NOTICE([ Setting libdir=${libdir} ]) - fi - break - fi - done -fi - BUILD_PLATFORM=${build} BUILD_CPU=${build_cpu} BUILD_VENDOR=${build_vendor} @@ -1197,29 +1176,6 @@ CFLAGS="${saved_sanitize_CFLAGS}" LDFLAGS="${saved_sanitize_LDFLAGS}" AC_SUBST(AST_UNDEFINED_SANITIZER) -AC_MSG_CHECKING(for -ffunction-sections support) -saved_CFLAGS="${CFLAGS}" -CFLAGS="${CFLAGS} -ffunction-sections" -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [int x = 1;])], - AC_MSG_RESULT(yes) - [saved_LDFLAGS="${LDFLAGS}"] - [LDFLAGS="${LDFLAGS} -Wl,--gc-sections"] - AC_MSG_CHECKING(for --gc-sections support) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([], [int x = 1;])], - AC_MSG_RESULT(yes) - [GC_CFLAGS="-ffunction-sections"] - [[GC_LDFLAGS="-Wl,--gc-sections"]], - AC_MSG_RESULT(no) - ) - [LDFLAGS="${saved_LDFLAGS}"], - AC_MSG_RESULT(no) -) -CFLAGS="${saved_CFLAGS}" -AC_SUBST(GC_CFLAGS) -AC_SUBST(GC_LDFLAGS) - AC_MSG_CHECKING(for -Wdeclaration-after-statement support) if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) diff --git a/contrib/ast-db-manage/cdr/versions/210693f3123d_create_cdr_table.py b/contrib/ast-db-manage/cdr/versions/210693f3123d_create_cdr_table.py index 3ea9ed153..3ea9ed153 100755..100644 --- a/contrib/ast-db-manage/cdr/versions/210693f3123d_create_cdr_table.py +++ b/contrib/ast-db-manage/cdr/versions/210693f3123d_create_cdr_table.py diff --git a/contrib/ast-db-manage/config/versions/10aedae86a32_add_outgoing_enum_va.py b/contrib/ast-db-manage/config/versions/10aedae86a32_add_outgoing_enum_va.py index b4ea71cbd..b4ea71cbd 100755..100644 --- a/contrib/ast-db-manage/config/versions/10aedae86a32_add_outgoing_enum_va.py +++ b/contrib/ast-db-manage/config/versions/10aedae86a32_add_outgoing_enum_va.py diff --git a/contrib/ast-db-manage/config/versions/1758e8bbf6b_increase_useragent_column_size.py b/contrib/ast-db-manage/config/versions/1758e8bbf6b_increase_useragent_column_size.py index 215726fa0..215726fa0 100755..100644 --- a/contrib/ast-db-manage/config/versions/1758e8bbf6b_increase_useragent_column_size.py +++ b/contrib/ast-db-manage/config/versions/1758e8bbf6b_increase_useragent_column_size.py diff --git a/contrib/ast-db-manage/config/versions/21e526ad3040_add_pjsip_debug_option.py b/contrib/ast-db-manage/config/versions/21e526ad3040_add_pjsip_debug_option.py index 2adca628b..2adca628b 100755..100644 --- a/contrib/ast-db-manage/config/versions/21e526ad3040_add_pjsip_debug_option.py +++ b/contrib/ast-db-manage/config/versions/21e526ad3040_add_pjsip_debug_option.py diff --git a/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py b/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py index dc0c01c24..dc0c01c24 100755..100644 --- a/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py +++ b/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py diff --git a/contrib/ast-db-manage/config/versions/28887f25a46f_create_queue_tables.py b/contrib/ast-db-manage/config/versions/28887f25a46f_create_queue_tables.py index 59ddac7cd..59ddac7cd 100755..100644 --- a/contrib/ast-db-manage/config/versions/28887f25a46f_create_queue_tables.py +++ b/contrib/ast-db-manage/config/versions/28887f25a46f_create_queue_tables.py diff --git a/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py b/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py index d39ddb41a..d39ddb41a 100755..100644 --- a/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py +++ b/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py diff --git a/contrib/ast-db-manage/config/versions/43956d550a44_add_tables_for_pjsip.py b/contrib/ast-db-manage/config/versions/43956d550a44_add_tables_for_pjsip.py index 140fe5b93..140fe5b93 100755..100644 --- a/contrib/ast-db-manage/config/versions/43956d550a44_add_tables_for_pjsip.py +++ b/contrib/ast-db-manage/config/versions/43956d550a44_add_tables_for_pjsip.py diff --git a/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py b/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py index 17906ae19..17906ae19 100755..100644 --- a/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py +++ b/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py diff --git a/contrib/ast-db-manage/config/versions/4da0c5f79a9c_create_tables.py b/contrib/ast-db-manage/config/versions/4da0c5f79a9c_create_tables.py index 01c40acbc..01c40acbc 100755..100644 --- a/contrib/ast-db-manage/config/versions/4da0c5f79a9c_create_tables.py +++ b/contrib/ast-db-manage/config/versions/4da0c5f79a9c_create_tables.py diff --git a/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py b/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py index 72f5ee169..72f5ee169 100755..100644 --- a/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py +++ b/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py diff --git a/contrib/ast-db-manage/config/versions/581a4264e537_adding_extensions.py b/contrib/ast-db-manage/config/versions/581a4264e537_adding_extensions.py index 415f5bc25..415f5bc25 100755..100644 --- a/contrib/ast-db-manage/config/versions/581a4264e537_adding_extensions.py +++ b/contrib/ast-db-manage/config/versions/581a4264e537_adding_extensions.py diff --git a/contrib/ast-db-manage/env.py b/contrib/ast-db-manage/env.py index a903451b4..a903451b4 100755..100644 --- a/contrib/ast-db-manage/env.py +++ b/contrib/ast-db-manage/env.py diff --git a/contrib/ast-db-manage/voicemail/versions/39428242f7f5_increase_recording_column_size.py b/contrib/ast-db-manage/voicemail/versions/39428242f7f5_increase_recording_column_size.py index f06cbf10e..f06cbf10e 100755..100644 --- a/contrib/ast-db-manage/voicemail/versions/39428242f7f5_increase_recording_column_size.py +++ b/contrib/ast-db-manage/voicemail/versions/39428242f7f5_increase_recording_column_size.py diff --git a/contrib/ast-db-manage/voicemail/versions/a2e9769475e_create_tables.py b/contrib/ast-db-manage/voicemail/versions/a2e9769475e_create_tables.py index 3dc4d47c4..3dc4d47c4 100755..100644 --- a/contrib/ast-db-manage/voicemail/versions/a2e9769475e_create_tables.py +++ b/contrib/ast-db-manage/voicemail/versions/a2e9769475e_create_tables.py diff --git a/include/asterisk.h b/include/asterisk.h index 862fa1fe5..dc530dfd4 100644 --- a/include/asterisk.h +++ b/include/asterisk.h @@ -196,6 +196,7 @@ struct ast_module; struct ast_variable; struct ast_str; struct ast_sched_context; +struct ast_json; /* Some handy macros for turning a preprocessor token into (effectively) a quoted string */ #define __stringify_1(x) #x diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h index 28ae73e87..484e1e35c 100644 --- a/include/asterisk/astobj2.h +++ b/include/asterisk/astobj2.h @@ -854,11 +854,9 @@ struct ao2_global_obj { * \return Nothing */ #define ao2_t_global_obj_release(holder, tag) \ - __ao2_global_obj_release(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) + __ao2_global_obj_replace_unref(&holder, NULL, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_release(holder) \ - __ao2_global_obj_release(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) - -void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name); + __ao2_global_obj_replace_unref(&holder, NULL, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) /*! * \brief Replace an ao2 object in the global holder. diff --git a/include/asterisk/cel.h b/include/asterisk/cel.h index 350b4bf9f..c77a3538c 100644 --- a/include/asterisk/cel.h +++ b/include/asterisk/cel.h @@ -87,29 +87,6 @@ enum ast_cel_event_type { */ unsigned int ast_cel_check_enabled(void); -/*! - * \brief Allocate a CEL record - * - * \since 1.8 - * - * \note The CEL record must be destroyed with ast_cel_destroy(). - * - * \retval non-NULL an allocated ast_cel structure - * \retval NULL error - */ -struct ast_cel *ast_cel_alloc(void); - -/*! - * \brief Destroy a CEL record. - * - * \param cel the record to destroy - * - * \since 1.8 - * - * \return nothing. - */ -void ast_cel_destroy(struct ast_cel *cel); - /*! * \brief Get the name of a CEL event type * diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 9a3a967e2..32c9c7f67 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -178,12 +178,12 @@ extern "C" { #include "asterisk/ccss.h" #include "asterisk/framehook.h" #include "asterisk/stasis.h" -#include "asterisk/json.h" #include "asterisk/endpoints.h" #define DATASTORE_INHERIT_FOREVER INT_MAX -#define AST_MAX_FDS 11 +#define AST_MAX_FDS 11 /*!< original maximum number of file descriptors */ +#define AST_EXTENDED_FDS 12 /*!< the start of extended file descriptor positions */ /* * We have AST_MAX_FDS file descriptors in a channel. * Some of them have a fixed use: @@ -2402,12 +2402,6 @@ void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_par /*! Set the file descriptor on the channel */ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd); -/*! Add a channel to an optimized waitfor */ -void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1); - -/*! Delete a channel from an optimized waitfor */ -void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1); - /*! Start a tone going */ int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol); /*! Stop a tone from playing */ @@ -4300,11 +4294,30 @@ void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value) int ast_channel_fd(const struct ast_channel *chan, int which); int ast_channel_fd_isset(const struct ast_channel *chan, int which); -/* epoll data internal accessors */ -#ifdef HAVE_EPOLL -struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which); -void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value); -#endif +/*! + * \since 15 + * \brief Retrieve the number of file decriptor positions present on the channel + * + * \param chan The channel to get the count of + * + * \pre chan is locked + * + * \return The number of file descriptor positions + */ +int ast_channel_fd_count(const struct ast_channel *chan); + +/*! + * \since 15 + * \brief Add a file descriptor to the channel without a fixed position + * + * \param chan The channel to add the file descriptor to + * \param value The file descriptor + * + * \pre chan is locked + * + * \return The position of the file descriptor + */ +int ast_channel_fd_add(struct ast_channel *chan, int value); pthread_t ast_channel_blocker(const struct ast_channel *chan); void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value); diff --git a/include/asterisk/module.h b/include/asterisk/module.h index a80c7f843..e614a726f 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -303,8 +303,6 @@ struct ast_module_info { enum ast_module_load_result (*load)(void); /*!< register stuff etc. Optional. */ int (*reload)(void); /*!< config etc. Optional. */ int (*unload)(void); /*!< unload. called with the module locked */ - int (*backup_globals)(void); /*!< for embedded modules, backup global data */ - void (*restore_globals)(void); /*!< for embedded modules, restore global data */ const char *name; /*!< name of the module for loader reference and CLI commands */ const char *description; /*!< user friendly description of the module. */ @@ -379,8 +377,6 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons load_func, \ reload_func, \ unload_func, \ - NULL, \ - NULL, \ AST_MODULE, \ desc, \ keystr, \ @@ -440,70 +436,9 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons static const __attribute__((unused)) struct ast_module_info *ast_module_info; #endif -#if !defined(EMBEDDED_MODULE) -#define __MODULE_INFO_SECTION -#define __MODULE_INFO_GLOBALS -#else -/* - * For embedded modules we need additional information to backup and - * restore the global variables in the module itself, so we can unload - * reload the module. - * EMBEDDED_MODULE is defined as the module name, so the calls to make_var() - * below will actually define different symbols for each module. - */ -#define __MODULE_INFO_SECTION __attribute__((section(".embed_module"))) -#define __MODULE_INFO_GLOBALS .backup_globals = __backup_globals, .restore_globals = __restore_globals, - -#define make_var_sub(mod, type) __ ## mod ## _ ## type -#define make_var(mod, type) make_var_sub(mod, type) - -extern void make_var(EMBEDDED_MODULE, bss_start); -extern void make_var(EMBEDDED_MODULE, bss_end); -extern void make_var(EMBEDDED_MODULE, data_start); -extern void make_var(EMBEDDED_MODULE, data_end); - -static void * __attribute__((section(".embed_module"))) __global_backup; - -static int __backup_globals(void) -{ - size_t data_size = & make_var(EMBEDDED_MODULE, data_end) - & make_var(EMBEDDED_MODULE, data_start); - - if (__global_backup) - return 0; - - if (!data_size) - return 0; - - if (!(__global_backup = ast_malloc(data_size))) - return -1; - - memcpy(__global_backup, & make_var(EMBEDDED_MODULE, data_start), data_size); - - return 0; -} - -static void __restore_globals(void) -{ - size_t data_size = & make_var(EMBEDDED_MODULE, data_end) - & make_var(EMBEDDED_MODULE, data_start); - size_t bss_size = & make_var(EMBEDDED_MODULE, bss_end) - & make_var(EMBEDDED_MODULE, bss_start); - - if (bss_size) - memset(& make_var(EMBEDDED_MODULE, bss_start), 0, bss_size); - - if (!data_size || !__global_backup) - return; - - memcpy(& make_var(EMBEDDED_MODULE, data_start), __global_backup, data_size); -} -#undef make_var -#undef make_var_sub -#endif /* EMBEDDED_MODULE */ - #define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) \ static struct ast_module_info \ - __MODULE_INFO_SECTION \ __mod_info = { \ - __MODULE_INFO_GLOBALS \ .name = AST_MODULE, \ .flags = flags_to_set, \ .description = desc, \ diff --git a/include/asterisk/stasis_app.h b/include/asterisk/stasis_app.h index e131833a9..ca5c25111 100644 --- a/include/asterisk/stasis_app.h +++ b/include/asterisk/stasis_app.h @@ -51,7 +51,6 @@ */ #include "asterisk/channel.h" -#include "asterisk/json.h" /*! @{ */ diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h index deb79b0d0..4843617db 100644 --- a/include/asterisk/stasis_channels.h +++ b/include/asterisk/stasis_channels.h @@ -22,7 +22,6 @@ #include "asterisk/stringfields.h" #include "asterisk/stasis.h" -#include "asterisk/json.h" #include "asterisk/channel.h" /*! \addtogroup StasisTopicsAndMessages diff --git a/include/asterisk/stasis_endpoints.h b/include/asterisk/stasis_endpoints.h index 539f270cf..2fbe5f4b7 100644 --- a/include/asterisk/stasis_endpoints.h +++ b/include/asterisk/stasis_endpoints.h @@ -28,7 +28,6 @@ */ #include "asterisk/endpoints.h" -#include "asterisk/json.h" #include "asterisk/stasis.h" #include "asterisk/stasis_cache_pattern.h" #include "asterisk/stringfields.h" diff --git a/include/asterisk/stasis_system.h b/include/asterisk/stasis_system.h index 274c02e49..55959063c 100644 --- a/include/asterisk/stasis_system.h +++ b/include/asterisk/stasis_system.h @@ -19,7 +19,6 @@ #ifndef _ASTERISK_STASIS_SYSTEM_H #define _ASTERISK_STASIS_SYSTEM_H -#include "asterisk/json.h" #include "asterisk/stasis.h" /*! diff --git a/main/Makefile b/main/Makefile index cf38f5f46..4fb6a0131 100644 --- a/main/Makefile +++ b/main/Makefile @@ -11,7 +11,7 @@ # the GNU General Public License # --include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts.embed_rules $(ASTTOPDIR)/makeopts +-include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts all: asterisk @@ -48,9 +48,7 @@ AST_LIBS+=$(RT_LIB) AST_LIBS+=$(SYSTEMD_LIB) ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-musl kfreebsd-gnu),) - ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) AST_LIBS+=-ldl - endif ifneq (x$(CAP_LIB),x) AST_LIBS+=$(CAP_LIB) endif @@ -69,11 +67,7 @@ ifneq ($(findstring darwin,$(OSARCH)),) ASTLINK+=/usr/lib/bundle1.o else # These are used for all but Darwin - ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) - ASTLINK+=-Wl,--export-dynamic - else - ASTLINK+=${GC_LDFLAGS} - endif + ASTLINK+=-Wl,--export-dynamic ifneq ($(findstring BSD,$(OSARCH)),) LDFLAGS+=-L/usr/local/lib endif @@ -172,9 +166,6 @@ endif stdtime/localtime.o: _ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral -AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS)) -AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep))) -AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep))) OBJS:=$(sort $(OBJS)) ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) @@ -325,10 +316,10 @@ endif tcptls.o: _ASTCFLAGS+=$(OPENSSL_INCLUDE) -$(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(ASTPJ_LIB) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) +$(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(ASTPJ_LIB) $(LIBEDIT_OBJ) @$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS) - $(ECHO_PREFIX) echo " [LD] $(OBJS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) -> $@" - $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(ASTPJ_LDLIBS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB) + $(ECHO_PREFIX) echo " [LD] $(OBJS) $(LIBEDIT_OBJ) -> $@" + $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(ASTPJ_LDLIBS) $(LIBEDIT_OBJ) buildinfo.o $(AST_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB) ifeq ($(GNU_LD),1) $(MAIN_TGT): asterisk.exports @@ -360,7 +351,7 @@ binuninstall: rm -f "$(DESTDIR)$(ASTSBINDIR)/$(MAIN_TGT)" rm -f "$(DESTDIR)$(ASTSBINDIR)/rasterisk" rm -f "$(DESTDIR)$(ASTLIBDIR)/libasterisk"* || : - rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR))/libasterisk"* || : + test -n "$(_oldlibdir)" -a -d "$(_oldlibdir)" && rm -f "$(_oldlibdir)/libasterisk"* || : clean:: rm -f asterisk libasteriskssl.o diff --git a/main/astobj2.c b/main/astobj2.c index 1529e91b0..d534900dd 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -729,30 +729,6 @@ unsigned int ao2_options_get(void *obj) return orig_obj->priv_data.options; } - -void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name) -{ - if (!holder) { - /* For sanity */ - ast_log(LOG_ERROR, "Must be called with a global object!\n"); - ast_assert(0); - return; - } - if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) { - /* Could not get the write lock. */ - ast_assert(0); - return; - } - - /* Release the held ao2 object. */ - if (holder->obj) { - __ao2_ref(holder->obj, -1, tag, file, line, func); - holder->obj = NULL; - } - - __ast_rwlock_unlock(file, line, func, &holder->lock, name); -} - void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name) { void *obj_old; diff --git a/main/channel.c b/main/channel.c index 15c7fa406..31f363938 100644 --- a/main/channel.c +++ b/main/channel.c @@ -78,21 +78,12 @@ /*** DOCUMENTATION ***/ -#ifdef HAVE_EPOLL -#include <sys/epoll.h> -#endif - #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) #if defined(HAVE_PRI) #include "libpri.h" #endif /* defined(HAVE_PRI) */ #endif /* defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) */ -struct ast_epoll_data { - struct ast_channel *chan; - int which; -}; - /* uncomment if you have problems with 'monitoring' synchronized files */ #if 0 #define MONITOR_CONSTANT_DELAY @@ -850,10 +841,6 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char ast_channel_internal_alertpipe_clear(tmp); ast_channel_internal_fd_clear_all(tmp); -#ifdef HAVE_EPOLL - ast_channel_epfd_set(tmp, epoll_create(25)); -#endif - if (!(schedctx = ast_sched_context_create())) { ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n"); /* See earlier channel creation abort comment above. */ @@ -1058,9 +1045,6 @@ struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const ast_channel_timingfd_set(tmp, -1); ast_channel_internal_alertpipe_clear(tmp); ast_channel_internal_fd_clear_all(tmp); -#ifdef HAVE_EPOLL - ast_channel_epfd_set(tmp, -1); -#endif ast_channel_hold_state_set(tmp, AST_CONTROL_UNHOLD); @@ -2223,9 +2207,6 @@ void ast_party_redirecting_free(struct ast_party_redirecting *doomed) static void ast_channel_destructor(void *obj) { struct ast_channel *chan = obj; -#ifdef HAVE_EPOLL - int i; -#endif struct ast_var_t *vardata; struct ast_frame *f; struct varshead *headp; @@ -2323,14 +2304,6 @@ static void ast_channel_destructor(void *obj) ast_timer_close(ast_channel_timer(chan)); ast_channel_timer_set(chan, NULL); } -#ifdef HAVE_EPOLL - for (i = 0; i < AST_MAX_FDS; i++) { - if (ast_channel_internal_epfd_data(chan, i)) { - ast_free(ast_channel_internal_epfd_data(chan, i)); - } - } - close(ast_channel_epfd(chan)); -#endif while ((f = AST_LIST_REMOVE_HEAD(ast_channel_readq(chan), frame_list))) ast_frfree(f); @@ -2481,82 +2454,10 @@ struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const /*! Set the file descriptor on the channel */ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd) { -#ifdef HAVE_EPOLL - struct epoll_event ev; - struct ast_epoll_data *aed = NULL; - - if (ast_channel_fd_isset(chan, which)) { - epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_DEL, ast_channel_fd(chan, which), &ev); - aed = ast_channel_internal_epfd_data(chan, which); - } - - /* If this new fd is valid, add it to the epoll */ - if (fd > -1) { - if (!aed && (!(aed = ast_calloc(1, sizeof(*aed))))) - return; - - ast_channel_internal_epfd_data_set(chan, which, aed); - aed->chan = chan; - aed->which = which; - - ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; - ev.data.ptr = aed; - epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_ADD, fd, &ev); - } else if (aed) { - /* We don't have to keep around this epoll data structure now */ - ast_free(aed); - ast_channel_epfd_data_set(chan, which, NULL); - } -#endif ast_channel_internal_fd_set(chan, which, fd); return; } -/*! Add a channel to an optimized waitfor */ -void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1) -{ -#ifdef HAVE_EPOLL - struct epoll_event ev; - int i = 0; - - if (ast_channel_epfd(chan0) == -1) - return; - - /* Iterate through the file descriptors on chan1, adding them to chan0 */ - for (i = 0; i < AST_MAX_FDS; i++) { - if (!ast_channel_fd_isset(chan1, i)) { - continue; - } - ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; - ev.data.ptr = ast_channel_internal_epfd_data(chan1, i); - epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_ADD, ast_channel_fd(chan1, i), &ev); - } - -#endif - return; -} - -/*! Delete a channel from an optimized waitfor */ -void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1) -{ -#ifdef HAVE_EPOLL - struct epoll_event ev; - int i = 0; - - if (ast_channel_epfd(chan0) == -1) - return; - - for (i = 0; i < AST_MAX_FDS; i++) { - if (!ast_channel_fd_isset(chan1, i)) { - continue; - } - epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_DEL, ast_channel_fd(chan1, i), &ev); - } - -#endif - return; -} - void ast_channel_clear_softhangup(struct ast_channel *chan, int flag) { ast_channel_lock(chan); @@ -3061,20 +2962,15 @@ int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception) } /*! \brief Wait for x amount of time on a file descriptor to have input. */ -#ifdef HAVE_EPOLL -static struct ast_channel *ast_waitfor_nandfds_classic(struct ast_channel **c, int n, int *fds, int nfds, - int *exception, int *outfd, int *ms) -#else struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms) -#endif { struct timeval start = { 0 , 0 }; struct pollfd *pfds = NULL; int res; long rms; int x, y, max; - int sz; + int sz = nfds; struct timeval now = { 0, 0 }; struct timeval whentohangup = { 0, 0 }, diff; struct ast_channel *winner = NULL; @@ -3090,14 +2986,6 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, *exception = 0; } - if ((sz = n * AST_MAX_FDS + nfds)) { - pfds = ast_alloca(sizeof(*pfds) * sz); - fdmap = ast_alloca(sizeof(*fdmap) * sz); - } else { - /* nothing to allocate and no FDs to check */ - return NULL; - } - for (x = 0; x < n; x++) { ast_channel_lock(c[x]); if (!ast_tvzero(*ast_channel_whentohangup(c[x]))) { @@ -3114,8 +3002,17 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0) whentohangup = diff; } + sz += ast_channel_fd_count(c[x]); ast_channel_unlock(c[x]); } + + if (!sz) { + return NULL; + } + + pfds = ast_alloca(sizeof(*pfds) * sz); + fdmap = ast_alloca(sizeof(*fdmap) * sz); + /* Wait full interval */ rms = *ms; /* INT_MAX, not LONG_MAX, because it matters on 64-bit */ @@ -3135,12 +3032,12 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, */ max = 0; for (x = 0; x < n; x++) { - for (y = 0; y < AST_MAX_FDS; y++) { + ast_channel_lock(c[x]); + for (y = 0; y < ast_channel_fd_count(c[x]); y++) { fdmap[max].fdno = y; /* fd y is linked to this pfds */ fdmap[max].chan = x; /* channel x is linked to this pfds */ max += ast_add_fd(&pfds[max], ast_channel_fd(c[x], y)); } - ast_channel_lock(c[x]); CHECK_BLOCKING(c[x]); ast_channel_unlock(c[x]); } @@ -3234,205 +3131,6 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, return winner; } -#ifdef HAVE_EPOLL -static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan, int *ms) -{ - struct timeval start = { 0 , 0 }; - int res = 0; - struct epoll_event ev[1]; - long diff, rms = *ms; - struct ast_channel *winner = NULL; - struct ast_epoll_data *aed = NULL; - - ast_channel_lock(chan); - /* Figure out their timeout */ - if (!ast_tvzero(*ast_channel_whentohangup(chan))) { - if ((diff = ast_tvdiff_ms(*ast_channel_whentohangup(chan), ast_tvnow())) < 0) { - /* They should already be hungup! */ - ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_TIMEOUT); - ast_channel_unlock(chan); - return NULL; - } - /* If this value is smaller then the current one... make it priority */ - if (rms > diff) { - rms = diff; - } - } - - ast_channel_unlock(chan); - - /* Time to make this channel block... */ - CHECK_BLOCKING(chan); - - if (*ms > 0) { - start = ast_tvnow(); - } - - /* We don't have to add any file descriptors... they are already added, we just have to wait! */ - res = epoll_wait(ast_channel_epfd(chan), ev, 1, rms); - - /* Stop blocking */ - ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); - - /* Simulate a timeout if we were interrupted */ - if (res < 0) { - if (errno != EINTR) { - *ms = -1; - } - return NULL; - } - - /* If this channel has a timeout see if it expired */ - if (!ast_tvzero(*ast_channel_whentohangup(chan))) { - if (ast_tvdiff_ms(ast_tvnow(), *ast_channel_whentohangup(chan)) >= 0) { - ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_TIMEOUT); - winner = chan; - } - } - - /* No fd ready, reset timeout and be done for now */ - if (!res) { - *ms = 0; - return winner; - } - - /* See what events are pending */ - aed = ev[0].data.ptr; - ast_channel_fdno_set(chan, aed->which); - if (ev[0].events & EPOLLPRI) { - ast_set_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); - } else { - ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); - } - - if (*ms > 0) { - *ms -= ast_tvdiff_ms(ast_tvnow(), start); - if (*ms < 0) { - *ms = 0; - } - } - - return chan; -} - -static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, int n, int *ms) -{ - struct timeval start = { 0 , 0 }; - int res = 0, i; - struct epoll_event ev[25] = { { 0, } }; - struct timeval now = { 0, 0 }; - long whentohangup = 0, diff = 0, rms = *ms; - struct ast_channel *winner = NULL; - - for (i = 0; i < n; i++) { - ast_channel_lock(c[i]); - if (!ast_tvzero(*ast_channel_whentohangup(c[i]))) { - if (whentohangup == 0) { - now = ast_tvnow(); - } - if ((diff = ast_tvdiff_ms(*ast_channel_whentohangup(c[i]), now)) < 0) { - ast_channel_softhangup_internal_flag_add(c[i], AST_SOFTHANGUP_TIMEOUT); - ast_channel_unlock(c[i]); - return c[i]; - } - if (!whentohangup || whentohangup > diff) { - whentohangup = diff; - } - } - ast_channel_unlock(c[i]); - CHECK_BLOCKING(c[i]); - } - - rms = *ms; - if (whentohangup) { - rms = whentohangup; - if (*ms >= 0 && *ms < rms) { - rms = *ms; - } - } - - if (*ms > 0) { - start = ast_tvnow(); - } - - res = epoll_wait(ast_channel_epfd(c[0]), ev, 25, rms); - - for (i = 0; i < n; i++) { - ast_clear_flag(ast_channel_flags(c[i]), AST_FLAG_BLOCKING); - } - - if (res < 0) { - if (errno != EINTR) { - *ms = -1; - } - return NULL; - } - - if (whentohangup) { - now = ast_tvnow(); - for (i = 0; i < n; i++) { - if (!ast_tvzero(*ast_channel_whentohangup(c[i])) && ast_tvdiff_ms(now, *ast_channel_whentohangup(c[i])) >= 0) { - ast_channel_softhangup_internal_flag_add(c[i], AST_SOFTHANGUP_TIMEOUT); - if (!winner) { - winner = c[i]; - } - } - } - } - - if (!res) { - *ms = 0; - return winner; - } - - for (i = 0; i < res; i++) { - struct ast_epoll_data *aed = ev[i].data.ptr; - - if (!ev[i].events || !aed) { - continue; - } - - winner = aed->chan; - if (ev[i].events & EPOLLPRI) { - ast_set_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION); - } else { - ast_clear_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION); - } - ast_channel_fdno_set(winner, aed->which); - } - - if (*ms > 0) { - *ms -= ast_tvdiff_ms(ast_tvnow(), start); - if (*ms < 0) { - *ms = 0; - } - } - - return winner; -} - -struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, - int *exception, int *outfd, int *ms) -{ - /* Clear all provided values in one place. */ - if (outfd) { - *outfd = -99999; - } - if (exception) { - *exception = 0; - } - - /* If no epoll file descriptor is available resort to classic nandfds */ - if (!n || nfds || ast_channel_epfd(c[0]) == -1) { - return ast_waitfor_nandfds_classic(c, n, fds, nfds, exception, outfd, ms); - } else if (!nfds && n == 1) { - return ast_waitfor_nandfds_simple(c[0], ms); - } else { - return ast_waitfor_nandfds_complex(c, n, ms); - } -} -#endif - struct ast_channel *ast_waitfor_n(struct ast_channel **c, int n, int *ms) { return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms); @@ -6852,6 +6550,7 @@ static void channel_do_masquerade(struct ast_channel *original, struct ast_chann int origstate; unsigned int orig_disablestatecache; unsigned int clone_disablestatecache; + int generator_fd; int visible_indication; int clone_hold_state; int moh_is_playing; @@ -7042,8 +6741,13 @@ static void channel_do_masquerade(struct ast_channel *original, struct ast_chann /* Keep the same parkinglot. */ ast_channel_parkinglot_set(original, ast_channel_parkinglot(clonechan)); - /* Copy the FD's other than the generator fd */ - for (x = 0; x < AST_MAX_FDS; x++) { + /* Clear all existing file descriptors but retain the generator */ + generator_fd = ast_channel_fd(original, AST_GENERATOR_FD); + ast_channel_internal_fd_clear_all(original); + ast_channel_set_fd(original, AST_GENERATOR_FD, generator_fd); + + /* Copy all file descriptors present on clonechan to original, skipping generator */ + for (x = 0; x < ast_channel_fd_count(clonechan); x++) { if (x != AST_GENERATOR_FD) ast_channel_set_fd(original, x, ast_channel_fd(clonechan, x)); } diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index d7ae8f9c1..b3c0a4805 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -48,6 +48,7 @@ #include "asterisk/stringfields.h" #include "asterisk/stream.h" #include "asterisk/test.h" +#include "asterisk/vector.h" /*! * \brief Channel UniqueId structure @@ -96,9 +97,6 @@ struct ast_channel { * in the CHANNEL dialplan function */ struct ast_channel_monitor *monitor; /*!< Channel monitoring */ ast_callid callid; /*!< Bound call identifier pointer */ -#ifdef HAVE_EPOLL - struct ast_epoll_data *epfd_data[AST_MAX_FDS]; -#endif struct ao2_container *dialed_causes; /*!< Contains tech-specific and Asterisk cause data from dialed channels */ AST_DECLARE_STRING_FIELDS( @@ -167,7 +165,7 @@ struct ast_channel { unsigned long insmpl; /*!< Track the read/written samples for monitor use */ unsigned long outsmpl; /*!< Track the read/written samples for monitor use */ - int fds[AST_MAX_FDS]; /*!< File descriptors for channel -- Drivers will poll on + AST_VECTOR(, int) fds; /*!< File descriptors for channel -- Drivers will poll on * these file descriptors, so at least one must be non -1. * See \arg \ref AstFileDesc */ int softhangup; /*!< Whether or not we have been hung up... Do not set this value @@ -197,9 +195,6 @@ struct ast_channel { struct ast_format *rawreadformat; /*!< Raw read format (before translation) */ struct ast_format *rawwriteformat; /*!< Raw write format (after translation) */ unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */ -#ifdef HAVE_EPOLL - int epfd; -#endif int visible_indication; /*!< Indication currently playing on the channel */ int hold_state; /*!< Current Hold/Unhold state */ @@ -597,17 +592,6 @@ void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value) chan->amaflags = value; ast_channel_publish_snapshot(chan); } - -#ifdef HAVE_EPOLL -int ast_channel_epfd(const struct ast_channel *chan) -{ - return chan->epfd; -} -void ast_channel_epfd_set(struct ast_channel *chan, int value) -{ - chan->epfd = value; -} -#endif int ast_channel_fdno(const struct ast_channel *chan) { return chan->fdno; @@ -1432,38 +1416,55 @@ void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_c /* file descriptor array accessors */ void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value) { - chan->fds[which] = value; + int pos; + + /* This ensures that if the vector has to grow with unused positions they will be + * initialized to -1. + */ + for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) { + AST_VECTOR_REPLACE(&chan->fds, pos, -1); + } + + AST_VECTOR_REPLACE(&chan->fds, which, value); } void ast_channel_internal_fd_clear(struct ast_channel *chan, int which) { - ast_channel_internal_fd_set(chan, which, -1); + if (which >= AST_VECTOR_SIZE(&chan->fds)) { + return; + } + + AST_VECTOR_REPLACE(&chan->fds, which, -1); } void ast_channel_internal_fd_clear_all(struct ast_channel *chan) { - int i; - for (i = 0; i < AST_MAX_FDS; i++) { - ast_channel_internal_fd_clear(chan, i); - } + AST_VECTOR_RESET(&chan->fds, AST_VECTOR_ELEM_CLEANUP_NOOP); } int ast_channel_fd(const struct ast_channel *chan, int which) { - return chan->fds[which]; + return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which); } int ast_channel_fd_isset(const struct ast_channel *chan, int which) { return ast_channel_fd(chan, which) > -1; } -#ifdef HAVE_EPOLL -struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which) +int ast_channel_fd_count(const struct ast_channel *chan) { - return chan->epfd_data[which]; + return AST_VECTOR_SIZE(&chan->fds); } -void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value) + +int ast_channel_fd_add(struct ast_channel *chan, int value) { - chan->epfd_data[which] = value; + int pos = AST_EXTENDED_FDS; + + while (ast_channel_fd_isset(chan, pos)) { + pos += 1; + } + + AST_VECTOR_REPLACE(&chan->fds, pos, value); + + return pos; } -#endif pthread_t ast_channel_blocker(const struct ast_channel *chan) { @@ -1617,6 +1618,8 @@ struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj), tmp->linkedid = tmp->uniqueid; } + AST_VECTOR_INIT(&tmp->fds, AST_MAX_FDS); + return tmp; } @@ -1693,6 +1696,8 @@ void ast_channel_internal_cleanup(struct ast_channel *chan) chan->topics = NULL; ast_channel_internal_set_stream_topology(chan, NULL); + + AST_VECTOR_FREE(&chan->fds); } void ast_channel_internal_finalize(struct ast_channel *chan) diff --git a/main/dial.c b/main/dial.c index cc2366ed7..d0492dcfd 100644 --- a/main/dial.c +++ b/main/dial.c @@ -479,9 +479,6 @@ static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_chann ast_hangup(channel->owner); channel->owner = NULL; } else { - if (chan) { - ast_poll_channel_add(chan, channel->owner); - } ast_channel_publish_dial(async ? NULL : chan, channel->owner, channel->device, NULL); res = 1; ast_verb(3, "Called %s\n", numsubst); @@ -868,8 +865,6 @@ static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_chann set_state(dial, AST_DIAL_RESULT_HANGUP); break; } - if (chan) - ast_poll_channel_del(chan, channel->owner); ast_channel_publish_dial(chan, who, channel->device, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(who))); ast_hangup(who); channel->owner = NULL; @@ -890,8 +885,6 @@ static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_chann AST_LIST_TRAVERSE(&dial->channels, channel, list) { if (!channel->owner || channel->owner == who) continue; - if (chan) - ast_poll_channel_del(chan, channel->owner); ast_channel_publish_dial(chan, channel->owner, channel->device, "CANCEL"); ast_hangup(channel->owner); channel->cause = AST_CAUSE_ANSWERED_ELSEWHERE; @@ -915,8 +908,6 @@ static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_chann AST_LIST_TRAVERSE(&dial->channels, channel, list) { if (!channel->owner) continue; - if (chan) - ast_poll_channel_del(chan, channel->owner); ast_channel_publish_dial(chan, channel->owner, channel->device, "CANCEL"); ast_hangup(channel->owner); channel->cause = AST_CAUSE_NORMAL_CLEARING; diff --git a/main/loader.c b/main/loader.c index dacfce1f6..380fe1c92 100644 --- a/main/loader.c +++ b/main/loader.c @@ -109,10 +109,6 @@ static const unsigned char expected_key[] = static char buildopt_sum[33] = AST_BUILDOPT_SUM; -static unsigned int embedding = 1; /* we always start out by registering embedded modules, - since they are here before we dlopen() any - */ - /*! * \brief Internal flag to indicate all modules have been initially loaded. */ @@ -146,14 +142,6 @@ const char *ast_module_name(const struct ast_module *mod) return mod->info->name; } -/* - * module_list is cleared by its constructor possibly after - * we start accumulating embedded modules, so we need to - * use another list (without the lock) to accumulate them. - * Then we update the main list when embedding is done. - */ -static struct module_list embedded_module_list; - struct loadupdate { int (*updater)(void); AST_LIST_ENTRY(loadupdate) entry; @@ -182,15 +170,7 @@ static struct ast_module *resource_being_loaded; void ast_module_register(const struct ast_module_info *info) { - struct ast_module *mod; - - if (embedding) { - if (!(mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1))) - return; - strcpy(mod->resource, info->name); - } else { - mod = resource_being_loaded; - } + struct ast_module *mod = resource_being_loaded; ast_debug(5, "Registering module %s\n", info->name); @@ -206,18 +186,14 @@ void ast_module_register(const struct ast_module_info *info) might be unsafe to use the list lock at that point... so let's avoid it altogether */ - if (embedding) { - AST_DLLIST_INSERT_TAIL(&embedded_module_list, mod, entry); - } else { - AST_DLLIST_LOCK(&module_list); - /* it is paramount that the new entry be placed at the tail of - the list, otherwise the code that uses dlopen() to load - dynamic modules won't be able to find out if the module it - just opened was registered or failed to load - */ - AST_DLLIST_INSERT_TAIL(&module_list, mod, entry); - AST_DLLIST_UNLOCK(&module_list); - } + AST_DLLIST_LOCK(&module_list); + /* it is paramount that the new entry be placed at the tail of + the list, otherwise the code that uses dlopen() to load + dynamic modules won't be able to find out if the module it + just opened was registered or failed to load + */ + AST_DLLIST_INSERT_TAIL(&module_list, mod, entry); + AST_DLLIST_UNLOCK(&module_list); /* give the module a copy of its own handle, for later use in registrations and the like */ *((struct ast_module **) &(info->self)) = mod; @@ -431,8 +407,6 @@ static struct ast_module *find_resource(const char *resource, int do_lock) return cur; } -#ifdef LOADABLE_MODULES - /*! * \brief dlclose(), with failure logging. */ @@ -605,8 +579,6 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned return AST_DLLIST_LAST(&module_list); } -#endif - int modules_shutdown(void) { struct ast_module *mod; @@ -721,18 +693,11 @@ int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode f AST_DLLIST_UNLOCK(&module_list); - if (!error && !mod->lib && mod->info && mod->info->restore_globals) - mod->info->restore_globals(); - -#ifdef LOADABLE_MODULES if (!error) { unload_dynamic_module(mod); ast_test_suite_event_notify("MODULE_UNLOAD", "Message: %s", resource_name); - } -#endif - - if (!error) ast_update_use_count(); + } return res; } @@ -1072,7 +1037,6 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi if (global_symbols_only && !ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS)) return AST_MODULE_LOAD_SKIP; } else { -#ifdef LOADABLE_MODULES mod = load_dynamic_module(resource_name, global_symbols_only, suppress_logging, resource_heap); if (mod == MODULE_LOCAL_ONLY) { return AST_MODULE_LOAD_SKIP; @@ -1083,22 +1047,11 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi } return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; } -#else - ast_log(LOG_WARNING, "Module support is not available. Module '%s' could not be loaded.\n", resource_name); - return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; -#endif } if (inspect_module(mod)) { ast_log(LOG_WARNING, "Module '%s' could not be loaded.\n", resource_name); -#ifdef LOADABLE_MODULES unload_dynamic_module(mod); -#endif - return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; - } - - if (!mod->lib && mod->info->backup_globals && mod->info->backup_globals()) { - ast_log(LOG_WARNING, "Module '%s' was unable to backup its global data.\n", resource_name); return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; } @@ -1316,7 +1269,6 @@ done: int load_modules(unsigned int preload_only) { struct ast_config *cfg; - struct ast_module *mod; struct load_order_entry *order; struct ast_variable *v; unsigned int load_count; @@ -1324,14 +1276,8 @@ int load_modules(unsigned int preload_only) int res = 0; struct ast_flags config_flags = { 0 }; int modulecount = 0; - -#ifdef LOADABLE_MODULES struct dirent *dirent; DIR *dir; -#endif - - /* all embedded modules have registered themselves by now */ - embedding = 0; ast_verb(1, "Asterisk Dynamic Loader Starting:\n"); @@ -1339,12 +1285,6 @@ int load_modules(unsigned int preload_only) AST_DLLIST_LOCK(&module_list); - if (embedded_module_list.first) { - module_list.first = embedded_module_list.first; - module_list.last = embedded_module_list.last; - embedded_module_list.first = NULL; - } - cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); @@ -1366,19 +1306,6 @@ int load_modules(unsigned int preload_only) /* check if 'autoload' is on */ if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { - /* if so, first add all the embedded modules that are not already running to the load order */ - AST_DLLIST_TRAVERSE(&module_list, mod, entry) { - /* if it's not embedded, skip it */ - if (mod->lib) - continue; - - if (mod->flags.running) - continue; - - add_to_load_order(mod->resource, &load_order, 0); - } - -#ifdef LOADABLE_MODULES /* if we are allowed to load dynamic modules, scan the directory for for all available modules and add them as well */ if ((dir = opendir(ast_config_AST_MODULE_DIR))) { @@ -1407,7 +1334,6 @@ int load_modules(unsigned int preload_only) ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", ast_config_AST_MODULE_DIR); } -#endif } /* now scan the config for any modules we are prohibited from loading and diff --git a/makeopts.in b/makeopts.in index 5bc5258da..03ef7470c 100644 --- a/makeopts.in +++ b/makeopts.in @@ -62,9 +62,6 @@ HOST_OS=@HOST_OS@ OSARCH=@OSARCH@ OSREV=@PBX_OSREV@ -GC_CFLAGS=@GC_CFLAGS@ -GC_LDFLAGS=@GC_LDFLAGS@ - PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ PTHREAD_LIBS=@PTHREAD_LIBS@ diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 5ee1ac30b..992737b15 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -1112,16 +1112,13 @@ static int moh_scan_files(struct mohclass *class) { DIR *files_DIR; struct dirent *files_dirent; char dir_path[PATH_MAX]; - char path[PATH_MAX]; char filepath[PATH_MAX]; char *ext; struct stat statbuf; int i; if (class->dir[0] != '/') { - ast_copy_string(dir_path, ast_config_AST_DATA_DIR, sizeof(dir_path)); - strncat(dir_path, "/", sizeof(dir_path) - 1); - strncat(dir_path, class->dir, sizeof(dir_path) - 1); + snprintf(dir_path, sizeof(dir_path), "%s/%s", ast_config_AST_DATA_DIR, class->dir); } else { ast_copy_string(dir_path, class->dir, sizeof(dir_path)); } @@ -1137,16 +1134,6 @@ static int moh_scan_files(struct mohclass *class) { } class->total_files = 0; - if (!getcwd(path, sizeof(path))) { - ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno)); - closedir(files_DIR); - return -1; - } - if (chdir(dir_path) < 0) { - ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); - closedir(files_DIR); - return -1; - } while ((files_dirent = readdir(files_DIR))) { /* The file name must be at least long enough to have the file type extension */ if ((strlen(files_dirent->d_name) < 4)) @@ -1183,10 +1170,6 @@ static int moh_scan_files(struct mohclass *class) { } closedir(files_DIR); - if (chdir(path) < 0) { - ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); - return -1; - } if (ast_test_flag(class, MOH_SORTALPHA)) qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare); return class->total_files; diff --git a/res/res_pjsip_config_wizard.c b/res/res_pjsip_config_wizard.c index 83e282821..1526dc2e2 100644 --- a/res/res_pjsip_config_wizard.c +++ b/res/res_pjsip_config_wizard.c @@ -139,6 +139,12 @@ entry in the list. If send_registrations is also set, a registration will also be created for each.</para></description> </configOption> + <configOption name="outbound_proxy"> + <synopsis>Shortcut for specifying proxy on individual objects.</synopsis> + <description><para>Shortcut for specifying endpoint/outbound_proxy, + aor/outbound_proxy, and registration/outbound_proxy individually. + </para></description> + </configOption> <configOption name="sends_auth" default="no"> <synopsis>Send outbound authentication to remote hosts.</synopsis> <description><para>At least outbound_auth/username is required.</para></description> @@ -153,6 +159,13 @@ be created for each host in the remote _hosts string. If authentication is required, sends_auth and an outbound_auth/username must also be supplied.</para></description> </configOption> + <configOption name="sends_line_with_registrations" default="no"> + <synopsis>Sets "line" and "endpoint parameters on registrations.</synopsis> + <description><para>Setting this to true will cause the wizard to skip the + creation of an identify object to match incoming requests to the endpoint and + instead add the line and endpoint parameters to the outbound registration object. + </para></description> + </configOption> <configOption name="accepts_registrations" default="no"> <synopsis>Accept inbound registration from remote hosts.</synopsis> <description><para>An AOR with dynamic contacts will be created. If @@ -595,11 +608,16 @@ static int handle_aor(const struct ast_sorcery *sorcery, struct object_type_wiza struct ast_sorcery_object *obj = NULL; const char *id = ast_category_get_name(wiz); const char *contact_pattern; + const char *outbound_proxy = ast_variable_find_last_in_list(wizvars, "outbound_proxy"); int host_count = AST_VECTOR_SIZE(remote_hosts_vector); RAII_VAR(struct ast_variable *, vars, get_object_variables(wizvars, "aor/"), ast_variables_destroy); variable_list_append(&vars, "@pjsip_wizard", id); + if (!ast_strlen_zero(outbound_proxy)) { + variable_list_append_return(&vars, "outbound_proxy", outbound_proxy); + } + /* If the user explicitly specified an aor/contact, don't use remote hosts. */ if (!ast_variable_find_last_in_list(vars, "contact")) { if (!(contact_pattern = ast_variable_find_last_in_list(wizvars, "contact_pattern"))) { @@ -647,6 +665,7 @@ static int handle_endpoint(const struct ast_sorcery *sorcery, struct object_type struct ast_variable *wizvars = ast_category_first(wiz); struct ast_sorcery_object *obj = NULL; const char *id = ast_category_get_name(wiz); + const char *outbound_proxy = ast_variable_find_last_in_list(wizvars, "outbound_proxy"); const char *transport = ast_variable_find_last_in_list(wizvars, "transport"); const char *hint_context = hint_context = ast_variable_find_last_in_list(wizvars, "hint_context"); const char *hint_exten = ast_variable_find_last_in_list(wizvars, "hint_exten"); @@ -657,6 +676,10 @@ static int handle_endpoint(const struct ast_sorcery *sorcery, struct object_type variable_list_append_return(&vars, "@pjsip_wizard", id); variable_list_append_return(&vars, "aors", id); + if (!ast_strlen_zero(outbound_proxy)) { + variable_list_append_return(&vars, "outbound_proxy", outbound_proxy); + } + if (ast_strlen_zero(hint_context)) { hint_context = ast_variable_find_last_in_list(vars, "context"); } @@ -719,8 +742,9 @@ static int handle_identify(const struct ast_sorcery *sorcery, struct object_type snprintf(new_id, sizeof(new_id), "%s-identify", id); - /* If accepting registrations, we don't need an identify. */ - if (is_variable_true(wizvars, "accepts_registrations")) { + /* If accepting registrations or we're sending line, we don't need an identify. */ + if (is_variable_true(wizvars, "accepts_registrations") + || is_variable_true(wizvars, "sends_line_with_registrations")) { /* If one exists, delete it. */ obj = otw->wizard->retrieve_id(sorcery, otw->wizard_data, "identify", new_id); if (obj) { @@ -836,6 +860,7 @@ static int handle_registrations(const struct ast_sorcery *sorcery, struct object const char *id = ast_category_get_name(wiz); const char *server_uri_pattern; const char *client_uri_pattern; + const char *outbound_proxy = ast_variable_find_last_in_list(wizvars, "outbound_proxy"); const char *transport = ast_variable_find_last_in_list(wizvars, "transport"); const char *username; char new_id[strlen(id) + MAX_ID_SUFFIX]; @@ -855,6 +880,10 @@ static int handle_registrations(const struct ast_sorcery *sorcery, struct object return -1; } + if (!ast_strlen_zero(outbound_proxy)) { + variable_list_append_return(&vars, "outbound_proxy", outbound_proxy); + } + otw->wizard->retrieve_multiple(sorcery, otw->wizard_data, "registration", existing, search); ast_variables_destroy(search); @@ -925,6 +954,11 @@ static int handle_registrations(const struct ast_sorcery *sorcery, struct object variable_list_append_return(®istration_vars, "transport", transport); } + if (is_variable_true(wizvars, "sends_line_with_registrations")) { + variable_list_append_return(®istration_vars, "line", "yes"); + variable_list_append_return(®istration_vars, "endpoint", id); + } + snprintf(new_id, sizeof(new_id), "%s-reg-%d", id, host_counter); obj = create_object(sorcery, new_id, "registration", registration_vars); diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index b66c1aeb8..21de4409c 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -781,7 +781,7 @@ static void apply_dtls_attrib(struct ast_sip_session_media *session_media, struct ast_rtp_engine_dtls *dtls = ast_rtp_instance_get_dtls(session_media->rtp); pj_str_t *value; - if (!attr->value.ptr) { + if (!attr->value.ptr || !dtls) { return; } diff --git a/res/res_srtp.c b/res/res_srtp.c index a611e6165..c47a8d55e 100644 --- a/res/res_srtp.c +++ b/res/res_srtp.c @@ -782,8 +782,8 @@ static int res_sdp_crypto_parse_offer(struct ast_rtp_instance *rtp, struct ast_s return -1; } - /* RFC4568 9.1 - tag is 1-9 digits, greater than zero */ - if (sscanf(tag, "%30d", &tag_from_sdp) != 1 || tag_from_sdp <= 0 || tag_from_sdp > 999999999) { + /* RFC4568 9.1 - tag is 1-9 digits */ + if (sscanf(tag, "%30d", &tag_from_sdp) != 1 || tag_from_sdp < 0 || tag_from_sdp > 999999999) { ast_log(LOG_WARNING, "Unacceptable a=crypto tag: %s\n", tag); return -1; } diff --git a/res/res_xmpp.c b/res/res_xmpp.c index f4a5d8e05..cc9d56f32 100644 --- a/res/res_xmpp.c +++ b/res/res_xmpp.c @@ -559,7 +559,6 @@ static void xmpp_client_destructor(void *obj) ast_xmpp_client_disconnect(client); ast_endpoint_shutdown(client->endpoint); - ao2_cleanup(client->endpoint); client->endpoint = NULL; if (client->filter) { @@ -3580,6 +3579,7 @@ int ast_xmpp_client_disconnect(struct ast_xmpp_client *client) { if ((client->thread != AST_PTHREADT_NULL) && !pthread_equal(pthread_self(), client->thread)) { xmpp_client_change_state(client, XMPP_STATE_DISCONNECTING); + pthread_cancel(client->thread); pthread_join(client->thread, NULL); client->thread = AST_PTHREADT_NULL; } @@ -3759,11 +3759,26 @@ static int xmpp_client_receive(struct ast_xmpp_client *client, unsigned int time return IKS_OK; } +static void sleep_with_backoff(unsigned int *sleep_time) +{ + /* We're OK with our thread dying here */ + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + + sleep(*sleep_time); + *sleep_time = MIN(60, *sleep_time * 2); + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); +} + /*! \brief XMPP client connection thread */ static void *xmpp_client_thread(void *data) { struct ast_xmpp_client *client = data; int res = IKS_NET_RWERR; + unsigned int sleep_time = 1; + + /* We only allow cancellation while sleeping */ + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); do { if (client->state == XMPP_STATE_DISCONNECTING) { @@ -3774,7 +3789,7 @@ static void *xmpp_client_thread(void *data) if (res == IKS_NET_RWERR || client->timeout == 0) { ast_debug(3, "[%s] Connecting\n", client->name); if ((res = xmpp_client_reconnect(client)) != IKS_OK) { - sleep(4); + sleep_with_backoff(&sleep_time); res = IKS_NET_RWERR; } continue; @@ -3813,6 +3828,8 @@ static void *xmpp_client_thread(void *data) } } else if (res == IKS_NET_RWERR) { ast_log(LOG_WARNING, "[%s] Socket read error\n", client->name); + ast_xmpp_client_disconnect(client); + sleep_with_backoff(&sleep_time); } else if (res == IKS_NET_NOSOCK) { ast_log(LOG_WARNING, "[%s] No socket\n", client->name); } else if (res == IKS_NET_NOCONN) { @@ -3825,6 +3842,8 @@ static void *xmpp_client_thread(void *data) ast_log(LOG_WARNING, "[%s] Dropped?\n", client->name); } else if (res == IKS_NET_UNKNOWN) { ast_debug(5, "[%s] Unknown\n", client->name); + } else if (res == IKS_OK) { + sleep_time = 1; } } while (1); diff --git a/tests/test_channel.c b/tests/test_channel.c new file mode 100644 index 000000000..854aff782 --- /dev/null +++ b/tests/test_channel.c @@ -0,0 +1,119 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2017, Digium, Inc. + * + * Joshua Colp <jcolp@digium.com> + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! + * \file + * \brief Channel unit tests + * + * \author Joshua Colp <jcolp@digium.com> + * + */ + +/*** MODULEINFO + <depend>TEST_FRAMEWORK</depend> + <support_level>core</support_level> + ***/ + +#include "asterisk.h" + +#include "asterisk/module.h" +#include "asterisk/test.h" +#include "asterisk/channel.h" + +AST_TEST_DEFINE(set_fd_grow) +{ + struct ast_channel *mock_channel; + enum ast_test_result_state res = AST_TEST_PASS; + int pos; + + switch (cmd) { + case TEST_INIT: + info->name = "set_fd_grow"; + info->category = "/main/channel/"; + info->summary = "channel setting file descriptor with growth test"; + info->description = + "Test that setting a file descriptor on a high position of a channel results in -1 set on any new positions"; + return AST_TEST_NOT_RUN; + case TEST_EXECUTE: + break; + } + + mock_channel = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, "TestChannel"); + ast_test_validate_cleanup(test, mock_channel, res, done); + + ast_channel_set_fd(mock_channel, AST_EXTENDED_FDS + 10, 1); + ast_test_validate_cleanup(test, ast_channel_fd_count(mock_channel) == AST_EXTENDED_FDS + 11, res, done); + + for (pos = AST_EXTENDED_FDS; (pos < AST_EXTENDED_FDS + 10); pos++) { + ast_test_validate_cleanup(test, ast_channel_fd(mock_channel, pos) == -1, res, done); + } + +done: + ast_hangup(mock_channel); + + return res; +} + +AST_TEST_DEFINE(add_fd) +{ + struct ast_channel *mock_channel; + enum ast_test_result_state res = AST_TEST_PASS; + int pos; + + switch (cmd) { + case TEST_INIT: + info->name = "add_fd"; + info->category = "/main/channel/"; + info->summary = "channel adding file descriptor test"; + info->description = + "Test that adding a file descriptor to a channel places it in the expected position"; + return AST_TEST_NOT_RUN; + case TEST_EXECUTE: + break; + } + + mock_channel = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, "TestChannel"); + ast_test_validate_cleanup(test, mock_channel, res, done); + + pos = ast_channel_fd_add(mock_channel, 1); + ast_test_validate_cleanup(test, pos == AST_EXTENDED_FDS, res, done); + + ast_channel_set_fd(mock_channel, pos, -1); + ast_test_validate_cleanup(test, ast_channel_fd(mock_channel, pos) == -1, res, done); + +done: + ast_hangup(mock_channel); + + return res; +} + +static int unload_module(void) +{ + AST_TEST_UNREGISTER(set_fd_grow); + AST_TEST_UNREGISTER(add_fd); + return 0; +} + +static int load_module(void) +{ + AST_TEST_REGISTER(set_fd_grow); + AST_TEST_REGISTER(add_fd); + return AST_MODULE_LOAD_SUCCESS; +} + +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel Unit Tests"); diff --git a/third-party/Makefile b/third-party/Makefile index f3016f153..59b7c0649 100644 --- a/third-party/Makefile +++ b/third-party/Makefile @@ -6,7 +6,7 @@ TP_SUBDIRS := pjproject # to prevent accidentally running the package's default install target. TP_INSTALL_SUBDIRS := pjproject -.PHONY: all dist-clean distclean install clean moduleinfo makeopts uninstall __embed_libs __embed_ldscript __embed_ldflags $(TP_SUBDIRS) +.PHONY: all dist-clean distclean install clean moduleinfo makeopts uninstall $(TP_SUBDIRS) override MAKECMDGOALS?=all |