Commit Graph

527 Commits

Author SHA1 Message Date
Naveen Albert d1fb397cfc general: Fix broken links.
This fixes a number of broken links throughout the
tree, mostly caused by wiki.asterisk.org being replaced
with docs.asterisk.org, which should eliminate the
need for sporadic fixes as in f28047db36.

Resolves: #430
2023-12-08 13:11:54 +00:00
George Joseph 95313d4727 asterisk.c: Use the euid's home directory to read/write cli history
The CLI .asterisk_history file is read from/written to the directory
specified by the HOME environment variable. If the root user starts
asterisk with the -U/-G options, or with runuser/rungroup set in
asterisk.conf, the asterisk process is started as root but then it
calls setuid/setgid to set the new user/group. This does NOT reset
the HOME environment variable to the new user's home directory
though so it's still left as "/root". In this case, the new user
will almost certainly NOT have access to read from or write to the
history file.

* Added function process_histfile() which calls
  getpwuid(geteuid()) and uses pw->dir as the home directory
  instead of the HOME environment variable.
* ast_el_read_default_histfile() and ast_el_write_default_histfile()
  have been modified to use the new process_histfile()
  function.

Resolves: #337
2023-09-22 13:34:21 +00:00
George Joseph 67fd66e2fe file.c: Add ability to search custom dir for sounds
To better co-exist with sounds files that may be managed by
packages, custom sound files may now be placed in
AST_DATA_DIR/sounds/custom instead of the standard
AST_DATA_DIR/sounds/<lang> directory.  If the new
"sounds_search_custom_dir" option in asterisk.conf is set
to "true", asterisk will search the custom directory for sounds
files before searching the standard directory.  For performance
reasons, the "sounds_search_custom_dir" defaults to "false".

Resolves: #315

UserNote: A new option "sounds_search_custom_dir" has been added to
asterisk.conf that allows asterisk to search
AST_DATA_DIR/sounds/custom for sounds files before searching the
standard AST_DATA_DIR/sounds/<lang> directory.
2023-09-20 19:15:07 +00:00
George Joseph fde0e19658 make_buildopts_h, et. al. Allow adding all cflags to buildopts.h
The previous behavior of make_buildopts_h was to not add the
non-ABI-breaking MENUSELECT_CFLAGS like DETECT_DEADLOCKS,
REF_DEBUG, etc. to the buildopts.h file because "it caused
ccache to invalidate files and extended compile times". They're
only defined by passing them on the gcc command line with '-D'
options.   In practice, including them in the include file rarely
causes any impact because the only time ccache cares is if you
actually change an option so the hit occurrs only once after
you change it.

OK so why would we want to include them?  Many IDEs follow the
include files to resolve defines and if the options aren't in an
include file, it can cause the IDE to mark blocks of "ifdeffed"
code as unused when they're really not.

So...

* Added a new menuselect compile option ADD_CFLAGS_TO_BUILDOPTS_H
  which tells make_buildopts_h to include the non-ABI-breaking
  flags in buildopts.h as well as the ABI-breaking ones. The default
  is disabled to preserve current behavior.  As before though,
  only the ABI-breaking flags appear in AST_BUILDOPTS and only
  those are used to calculate AST_BUILDOPT_SUM.
  A new AST_BUILDOPT_ALL define was created to capture all of the
  flags.

* make_version_c was streamlined to use buildopts.h and also to
  create asterisk_build_opts_all[] and ast_get_build_opts_all(void)

* "core show settings" now shows both AST_BUILDOPTS and
  AST_BUILDOPTS_ALL.

UserNote: The "Build Options" entry in the "core show settings"
CLI command has been renamed to "ABI related Build Options" and
a new entry named "All Build Options" has been added that shows
both breaking and non-breaking options.
2023-09-14 17:58:24 +00:00
Maximilian Fridrich 51a7b18038 core/ari/pjsip: Add refer mechanism
This change adds support for refers that are not session based. It
includes a refer implementation for the PJSIP technology which results
in out-of-dialog REFERs being sent to a PJSIP endpoint. These can be
triggered using the new ARI endpoint `/endpoints/refer`.

Resolves: #71

UserNote: There is a new ARI endpoint `/endpoints/refer` for referring
an endpoint to some URI or endpoint.
2023-08-09 15:10:46 +00:00
InterLinked1 ad6ff4cbf2
asterisk.c: Fix option warning for remote console. (#103)
Commit 09e989f972
categorized the T option as not being compatible
with remote consoles, but they do affect verbose
messages with remote console. This fixes this.

Resolves: #102
2023-05-22 12:59:56 -06:00
Naveen Albert cd0d60a64b cli: Prevent assertions on startup from bad ao2 refs.
If "core show channels" is run before startup has completed, it
is possible for bad ao2 refs to occur because the system is not
yet fully initialized. This will lead to an assertion failing.

To prevent this, initialization of CLI builtins is moved to be
later along in the main load sequence. Core CLI commands are
loaded at the same time, but channel-related commands are loaded
later on.

ASTERISK-29846 #close

Change-Id: If6b3cde802876bd738c1b4cf2683bea6ddc615b6
2022-09-09 20:41:35 -05:00
Naveen Albert bcc18ca9f5 general: Fix various typos.
ASTERISK-30089 #close

Change-Id: I1f5db911fd05a3a211c522c13e990fa1d0e62275
2022-07-12 07:46:03 -05:00
Naveen Albert b841845453 cli: Fix CLI blocking forever on terminating backslash
A corner case exists in CLI parsing where if
a CLI user in a remote console ends with
a backslash and then invokes command completion
(using TAB or ?), then the console will freeze
forever until a SIGQUIT signal is sent to the
process, due to getting blocked forever
reading the command completion. CTRL+C
and other key combinations have no impact on
the CLI session.

This occurs because, in such cases, the CLI
process is waiting for AST_CLI_COMPLETE_EOF
to appear in the buffer from the main process,
but instead the main process is confused by
the funny syntax and thus prints out the CLI help.
As a result, the CLI process is stuck on the
read call, waiting for the completion that
will never come.

This prevents blocking forever by checking
if the data from the main process starts with
"Usage:". If it does, that means that CLI help
was sent instead of the tab complete vector,
and thus the CLI should bail out and not wait
any longer.

ASTERISK-29822 #close

Change-Id: I9810ac59304fec162da701653c9c834f0ec8f670
2022-07-01 10:14:37 -05:00
Naveen Albert 2604a8352b asterisk.c: Fix incompatibility warnings for remote console.
A previous review fixing ASTERISK_22246 and ASTERISK_26582
got a couple of the options mixed up as to whether or not
they are compatible with the remote console. This fixes
those to the best of my knowledge.

ASTERISK-30097 #close

Change-Id: Id54166991aa79f04fb02699cc499bedda854253b
2022-06-16 12:37:13 -05:00
Naveen Albert 4585a9c3b8 asterisk.c: Warn of incompatibilities with remote console.
Some command line options to Asterisk only apply when Asterisk
is started and cannot be used with remote console mode. If a
user tries to use any of these, they are currently simply
silently ignored.

This prints out a warning if incompatible options are used,
informing users that an option used cannot be used with remote
console mode. Additionally, some clarifications are added to
the help text and man page.

ASTERISK-22246
ASTERISK-26582

Change-Id: I980a5380ef2c19e8ea348596396d5382893c4337
2022-04-27 12:38:20 -05:00
Naveen Albert 4722c8b70a cli: Add core dump info to core show settings.
Adds two pieces of information to the core show settings command
which are useful in the context of getting backtraces.

The first is to display whether or not Asterisk would generate
a core dump if it were to crash.

The second is to show the current running directory of Asterisk.

ASTERISK-29866 #close

Change-Id: Ic42c0a9ecc233381aad274d86c62808d1ebb4d83
2022-02-23 13:47:27 -06:00
Michał Górny dda02b8979 main: Enable rdtsc support on NetBSD
Enable the Linux rdtsc implementation on NetBSD as well.  The assembly
works correctly there.

ASTERISK-29851

Change-Id: I460ad9b4d971913420ecb84186f5ba5ab03f6f37
2022-01-19 11:27:16 -06:00
Josh Soref f382775241 main: Spelling fixes
Correct typos of the following word families:

analysis
nuisance
converting
although
transaction
desctitle
acquire
update
evaluate
thousand
this
dissolved
management
integrity
reconstructed
decrement
further on
irrelevant
currently
constancy
anyway
unconstrained
featuregroups
right
larger
evaluated
encumbered
languages
digits
authoritative
framing
blindxfer
tolerate
traverser
exclamation
perform
permissions
rearrangement
performing
processing
declension
happily
duplicate
compound
hundred
returns
elicit
allocate
actually
paths
inheritance
atxferdropcall
earlier
synchronization
multiplier
acknowledge
across
against
thousands
joyous
manipulators
guaranteed
emulating
soundfile

ASTERISK-29714

Change-Id: I926ba4b11e9f6dd3fdd93170ab1f9b997910be70
2021-11-15 17:33:27 -06:00
Joshua C. Colp 987f5eb0ad asterisk: We've moved to Libera Chat!
Change-Id: I48c1933dd79b50ddc0a6793acec4754b4e95c575
2021-05-25 09:20:59 -05:00
Mark Murawski b4347c4861 logger: Console sessions will now respect logger.conf dateformat= option
The 'core' console (ie: asterisk -c) does read logger.conf and does
use the dateformat= option.

Whereas 'remote' consoles (ie: asterisk -r -T) does not read logger.conf
and uses a hard coded dateformat option for printing received verbose messages:
  main/logger.c: static char dateformat[256] = "%b %e %T"

This change will load logger.conf for each remote console session and
use the dateformat= option to set the per-line timestamp for verbose messages

Change-Id: I3ea10990dbd920e9f7ce8ff771bc65aa7f4ea8c1
ASTERISK-25358: #close
Reported-by: Igor Liferenko
2021-03-22 11:17:23 -05:00
Joshua C. Colp f8d1758792 asterisk: Update copyright.
ASTERISK-29326

Change-Id: Ia95dbfb66e2d11ac4d1228444283bb2e4d77396a
2021-03-04 13:48:27 -06:00
Sean Bright 1b74555fcf asterisk: Export additional manager functions
Rename check_manager_enabled() and check_webmanager_enabled() to begin
with ast_ so that the symbols are automatically exported by the
linker.

ASTERISK~29184

Change-Id: I85762b9a5d14500c15f6bad6507138c8858644c9
2021-01-06 09:11:43 -06:00
Sean Bright 7d96b3e437 utf8.c: Add UTF-8 validation and utility functions
There are various places in Asterisk - specifically in regards to
database integration - where having some kind of UTF-8 validation would
be beneficial. This patch adds:

* Functions to validate that a given string contains only valid UTF-8
  sequences.

* A function to copy a string (similar to ast_copy_string) stopping when
  an invalid UTF-8 sequence is encountered.

* A UTF-8 validator that allows for progressive validation.

All of this is based on the excellent UTF-8 decoder by Björn Höhrmann.
More information is available here:

    https://bjoern.hoehrmann.de/utf-8/decoder/dfa/

The API was written in such a way that should allow us to replace the
implementation later should we determine that we need something more
comprehensive.

Change-Id: I3555d787a79e7c780a7800cd26e0b5056368abf9
2020-07-28 09:45:29 -05:00
George Joseph ca3c22c5f1 Scope Tracing: A new facility for tracing scope enter/exit
What's wrong with ast_debug?

  ast_debug is fine for general purpose debug output but it's not
  really geared for scope tracing since it doesn't present its
  output in a way that makes capturing and analyzing flow through
  Asterisk easy.

How is scope tracing better?

  Scope tracing uses the same "cleanup" attribute that RAII_VAR
  uses to print messages to a separate "trace" log level.  Even
  better, the messages are indented and unindented based on a
  thread-local call depth counter.  When output to a separate log
  file, the output is uncluttered and easy to follow.

  Here's an example of the output. The leading timestamps and
  thread ids are removed and the output cut off at 68 columns for
  commit message restrictions but you get the idea.

--> res_pjsip_session.c:3680 handle_incoming PJSIP/1173-00000001
	--> res_pjsip_session.c:3661 handle_incoming_response PJSIP/1173
		--> res_pjsip_session.c:3669 handle_incoming_response PJSIP/
			--> chan_pjsip.c:3265 chan_pjsip_incoming_response_after
				--> chan_pjsip.c:3194 chan_pjsip_incoming_response P
					    chan_pjsip.c:3245 chan_pjsip_incoming_respon
				<-- chan_pjsip.c:3194 chan_pjsip_incoming_response P
			<-- chan_pjsip.c:3265 chan_pjsip_incoming_response_after
		<-- res_pjsip_session.c:3669 handle_incoming_response PJSIP/
	<-- res_pjsip_session.c:3661 handle_incoming_response PJSIP/1173
<-- res_pjsip_session.c:3680 handle_incoming PJSIP/1173-00000001

  The messages with the "-->" or "<--" were produced by including
  the following at the top of each function:

  SCOPE_TRACE(1, "%s\n", ast_sip_session_get_name(session));

  Scope isn't limited to functions any more than RAII_VAR is.  You
  can also see entry and exit from "if", "for", "while", etc blocks.

  There is also an ast_trace() macro that doesn't track entry or
  exit but simply outputs a message to the trace log using the
  current indent level.  The deepest message in the sample
  (chan_pjsip.c:3245) was used to indicate which "case" in a
  "select" was executed.

How do you use it?

  More documentation is available in logger.h but here's an overview:

  * Configure with --enable-dev-mode.  Like debug, scope tracing
    is #ifdef'd out if devmode isn't enabled.

  * Add a SCOPE_TRACE() call to the top of your function.

  * Set a logger channel in logger.conf to output the "trace" level.

  * Use the CLI (or cli.conf) to set a trace level similar to setting
    debug level... CLI> core set trace 2 res_pjsip.so

Summary Of Changes:

  * Added LOG_TRACE logger level.  Actually it occupies the slot
    formerly occupied by the now defunct "event" level.

  * Added core asterisk option "trace" similar to debug.  Includes
	ability to specify global trace level in asterisk.conf and CLI
	commands to turn on/off and set levels.  Levels can be set
	globally (probably not a good idea), or by module/source file.

  * Updated sample asterisk.conf and logger.conf.  Tracing is
    disabled by default in both.

  * Added __ast_trace() to logger.c which keeps track of the indent
    level using TLS. It's #ifdef'd out if devmode isn't enabled.

  * Added ast_trace() and SCOPE_TRACE() macros to logger.h.
    These are all #ifdef'd out if devmode isn't enabled.

Why not use gcc's -finstrument-functions capability?

  gcc's facility doesn't allow access to local data and doesn't
  operate on non-function scopes.

Known Issues:

  The only know issue is that we currently don't know the line
  number where the scope exited.  It's reported as the same place
  the scope was entered.  There's probably a way to get around it
  but it might involve looking at the stack and doing an 'addr2line'
  to get the line number.  Kind of like ast_backtrace() does.
  Not sure if it's worth it.

Change-Id: Ic5ebb859883f9c10a08c5630802de33500cad027
2020-06-02 11:35:07 -05:00
Pirmin Walthert 6b2d945174 app.c: make sure that no non-async-signal-safe syscalls are used after
fork before exec

Posix does only allow async-signal-safe syscalls after fork before exec.
As asterisk ignores this, functions like TrySystem or System sometimes
end up in a deadlocked child process. The patch prevents the use of
non-async-signal-safe syscalls.

ASTERISK-28776

Change-Id: Idc76365c0592ee3f3b3bd72a4f48f7a098978e8e
2020-05-08 13:44:08 -05:00
George Joseph b76ab5e5c9 message.c: Add option to suppress the Message channel AMI and ARI events
In order to reduce the amount of AMI and ARI events generated,
the global "Message/ast_msg_queue" channel can be set to suppress
it's normal channel housekeeping events such as "Newexten",
"VarSet", etc. This can greatly reduce load on the manager
and ARI applications when the Digium Phone Module for Asterisk
is in use.  To enable, set "hide_messaging_ami_events" in
asterisk.conf to "yes"  In Asterisk versions <18, the default
is "no" preserving existing behavior.  Beginning with
Asterisk 18, the option will default to "yes".

NOTE:  This change does not affect UserEvents or the ARI
TextMessageReceived events.

* Added the "hide_messaging_ami_events" option to asterisk.conf.

* Changed message.c to set the AST_CHAN_TP_INTERNAL property on
  the "Message/ast_msg_queue" channel if the option is set in
  asterisk.conf.  This suppresses the reporting of the events.

Change-Id: Ia2e3516d43f4e0df994fc6598565d6bba2d7018b
2020-02-03 13:58:48 -06:00
Kevin Harwell bdd785d31c various files - fix some alerts raised by lgtm code analysis
This patch fixes several issues reported by the lgtm code analysis tool:

https://lgtm.com/projects/g/asterisk/asterisk

Not all reported issues were addressed in this patch. This patch mostly fixes
confirmed reported errors, potential problematic code points, and a few other
"low hanging" warnings or recommendations found in core supported modules.
These include, but are not limited to the following:

* innapropriate stack allocation in loops
* buffer overflows
* variable declaration "hiding" another variable declaration
* comparisons results that are always the same
* ambiguously signed bit-field members
* missing header guards

Change-Id: Id4a881686605d26c94ab5409bc70fcc21efacc25
2019-11-18 08:30:45 -06:00
Kevin Harwell ff0d0ac23a mwi core: Move core MWI functionality into its own files
There is enough MWI functionality to warrant it having its own 'c' and header
files. This patch moves all current core MWI data structures, and functions
into the following files:

main/mwi.h
main/mwi.c

Note, code was simply moved, and not modified. However, this patch is also in
preparation for core MWI changes, and additions to come.

Change-Id: I9dde8bfae1e7ec254fa63166e090f77e4d3097e0
2019-04-23 17:40:15 -05:00
Corey Farrell 9b7b8cb155 jansson: json_pack with new format to verify required runtime version.
Add a json_pack at startup that will fail if runtime links against a
library older than jansson-2.11.

Change-Id: I101aebafe0f9407650206f7c552dad3d69377b5a
2019-03-08 12:47:50 -06:00
Joshua C. Colp fe07093660 stasis: Add statistics gathering in developer mode.
This change adds statistics gathering to Stasis topics,
subscriptions, and message types. These can be viewed using
CLI commands and provide insight into how Stasis is used
and how long certain operations take to execute.

These are only available when Asterisk is compiled in
developer mode and do not have any impact under normal
operation.

ASTERISK-28117

Change-Id: I94411b53767f89ee01714daaecf0c2f1666e863f
2018-12-12 12:14:53 -05:00
Corey Farrell c3d7b19cdd core: Fix handling of restart from remote console.
We cannot use need_el_end and SIGURG when restarting.  Instead we need
to run el_end within the SIGHUP restartnow handler.

ASTERISK-28158

Change-Id: Ia852276363c81bdcf1aa29eb4558c5c2fa1218a0
2018-11-15 06:34:19 -05:00
Corey Farrell 194e40122a core: Ensure that el_end is always run when needed.
* Ignore console=yes configuration option in remote console processes.
* Use new flag to tell consolethread to run el_end and exit when needed.

ASTERISK-28158

Change-Id: I9e23b31d4211417ddc88c6bbfd83ea4c9f3e5438
2018-11-11 09:23:15 -05:00
Corey Farrell a10a3aff6a Build System: Improve ccache matching for different menuselect options.
Changing any Menuselect option in the `Compiler Flags` section causes a
full rebuild of the Asterisk source tree.  Every enabled option causes
a #define to be added to buildopts.h, thus breaking ccache caching for
every source file that includes "asterisk.h".  In most cases each option
only applies to one or two files.  Now we only define those options for
the specific sources which use them, this causes much better cache
matching when working with multiple builds.  For example testing code
with an without MALLOC_DEBUG will now use just over half the ccache
size, only main/astmm.o will have two builds cached instead of every
file.

Reorder main/Makefile so _ASTCFLAGS set on specific object files are all
together, sorted by filename.  Stop adding -DMALLOC_DEBUG to CFLAGS of
bundled pjproject, this define is no longer used by any header so only
serves to break cache.

The only code change is a slight adjustment to how main/astmm.c is
initialized.  Initialization functions always exist so main/asterisk.c
can call them unconditionally.  Additionally rename the astmm
initialization functions so they are not exported.

Change-Id: Ie2085237a964f6e1e6fff55ed046e2afff83c027
2018-08-01 12:01:15 -04:00
Richard Mudgett 0f8657aae9 asterisk.c: Make displayed copyright always consistent
Change-Id: I4f5499486e8ec90d7c7ffeebc659ceda1db6d5b5
2018-07-23 12:51:32 -05:00
Richard Mudgett 09c4be9433 asterisk.c: Update displayed copyright year for v16 release.
Change-Id: I60622731d928ee9506b1d28934095f0dc3e5306e
2018-07-20 15:53:18 -05:00
Corey Farrell 49f83a7490 loader: Fix startup issues.
* Merge the preload and load stages, use load ordering to try preload's
  first.  This fixes an issue where `preload=res_config_curl` would fail
  unless res_curl and func_curl were also preloaded.  Now it is only
  required that those modules be loaded during startup: autoload or
  regular load is good enough.
* The configuration option `require` and `preload-require` were only
  effective if the modules failed to load.  These options will now abort
  Asterisk startup if required modules fail to reach the 'Running'
  state.
* Missing or invalid 'module.conf' did not prevent startup.  Asterisk
  doesn't do anything without modules so this a fatal error.

Change-Id: Ie4176699133f0e3a823b43f90c3348677e43a5f3
2018-07-16 18:21:52 -04:00
Alexander Traud efe40ff671 BuildSystem: Add DragonFly BSD.
ASTERISK-27820

Change-Id: I310896143e94d65da1c2be3bb448204a8b86d557
2018-04-20 12:50:03 +02:00
George Joseph df7277ac5d Merge "main: Update copyright notice with year 2018" 2018-04-02 10:14:15 -05:00
Jenkins2 0718964e32 Merge "core: Create main/options.c." 2018-04-02 08:31:08 -05:00
Florian Floimair 455cee99ae main: Update copyright notice with year 2018
Change-Id: I2d80bc5edf940fab914cba3d8a0fa0b5eb2a3148
2018-03-27 15:27:09 +02:00
Guido Falsi 48190c7f93 core: fix getopt(3) usage
Setting optind = 0 is forced to 1 in glibc implementation, but
causes option parsing to be flawed in other implementations, for
example on FreeBSD.

ASTERISK-27773 #close

Change-Id: Ia548e69f8302e9754dbbedb6bc451c0700c66f61
2018-03-26 06:50:54 -06:00
Corey Farrell a6d58c518a core: Create main/options.c.
This creates a separate source to 'own' symbols related to options.h and
paths.h.  This significantly reduces the number of exports created by
main/asterisk.o.  This change is required to eventually be able to
link unmodified Asterisk sources to utilities and/or stand-alone tests.

ASTERISK~26245

Change-Id: I5cf184f4757f9363b80c9e678bdc35c477122380
2018-03-22 00:33:12 -04:00
Jenkins2 f863f1f91b Merge "channel.c: Allow generic plc then channel formats are equal" 2018-03-20 11:16:52 -05:00
Jenkins2 c1344d3f77 Merge "core: Minor cleanup of ast_el_read_char." 2018-03-20 08:47:15 -05:00
George Joseph 5d097f8236 channel.c: Allow generic plc then channel formats are equal
If the two formats on a channel are equal, we don't transcode and since
the generic plc needs slin to work, it doesn't get invoked.

* A new configuration option "genericplc_on_equal_codecs" was added
  to the "plc" section of codecs.conf to allow generic packet loss
  concealment even if no transcoding was originally needed.
  Transcoding via SLIN is forced in this case.

ASTERISK-27743

Change-Id: I0577026a179dea34232e63123254b4e0508378f4
2018-03-19 15:36:09 -06:00
Corey Farrell 5b40441197 core: Minor cleanup of ast_el_read_char.
* Define CHAR_T_LIBEDIT and CHAR_TO_LIBEDIT based on
  HAVE_LIBEDIT_IS_UNICODE.  This avoids needing to repeatedly use
  conditional blocks, eliminates having multiple function prototypes.
* Remove parenthesis from return values.
* Add missing code block brackets {}.
* Reduce use of 'else' conditional statements where possible.

Change-Id: I4315328ebea2f62641faf6881de2ac20a9f9d08e
2018-03-17 18:32:40 -04:00
Corey Farrell 572a508ef2 loader: Convert reload_classes to built-in modules.
* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl

These modules are now loaded at appropriate time by the module loader.
Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so
the module loader will abort startup on failure of these modules.

Some of these modules are still initialized or shutdown from outside the
module loader.  logger.c is initialized very early and shutdown very
late, manager.c is initialized by the module loader but is shutdown by
the Asterisk core (too much uses it without holding references).

Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
2018-03-14 05:20:12 -04:00
Corey Farrell fee929c8ac core: Remove non-critical cleanup from startup aborts.
When built-in components of Asterisk fail to start they cause the
Asterisk startup to abort.  In these cases only the most critical
cleanup should be performed - closing databases and terminating
proceses.  These cleanups are registered using ast_register_atexit, all
other cleanups should not be run during startup abort.

The main reason for this change is that these cleanup procedures are
untestable from the partially initialized states, if they fail it could
prevent us from ever running the critical cleanup with ast_run_atexits.

Create separate initialization for dns_core.c to be run unconditionally
during startup instead of being initialized by the first dns resolver to
be registered. This ensures that 'sched' is initialized before it can be
potentially used.

Replace ast_register_atexit with ast_register_cleanup in media_cache.c.
There is no reason for this cleanup to happen unconditionally.

Change-Id: Iecc2df98008b21509925ff16740bd5fa29527db3
2018-03-13 13:46:08 -04:00
Richard Mudgett 1a36a452bd pjproject: Add cache_pools debugging option.
The pool cache gets in the way of finding use after free errors of memory
pool contents.  Tools like valgrind and MALLOC_DEBUG don't know when a
pool is released because it gets put into the cache instead of being
freed.

* Added the "cache_pools" option to pjproject.conf.  Disabling the option
helps track down pool content mismanagement when using valgrind or
MALLOC_DEBUG.  The cache gets in the way of determining if the pool
contents are used after free and who freed it.

To disable the pool caching simply disable the cache_pools option in
pjproject.conf and restart Asterisk.

Sample pjproject.conf setting:
[startup]
cache_pools=no

* Made current users of the caching pool factory initialization and
destruction calls call common routines to create and destroy cached pools.

ASTERISK-27704

Change-Id: I64d5befbaeed2532f93aa027a51eb52347d2b828
2018-02-28 11:41:30 -06:00
Jenkins2 d6147aa6a3 Merge "main/asterisk.c: Remove silly usage of RAII_VAR." 2018-02-14 12:55:18 -06:00
Corey Farrell 9e45d3f893 main/asterisk.c: Remove silly usage of RAII_VAR.
Change-Id: I7e2996397fbd3c3a6a69dd805c38448ddfc34ae9
2018-02-12 22:15:34 -06:00
Corey Farrell 9fddc8b4dc core: Remove embedded editline.
This removes the embedded copy of editline from the Asterisk source
tree, making a system copy of libedit mandatory in Asterisk 16+.

ASTERISK-27634 #close

Change-Id: Iedb64ad92acb78419f3caefedaa2bb7cd2a1a33f
2018-02-12 04:44:26 -05:00
Jenkins2 21bcd85bba Merge "core: Fix unused variable error in handle_show_sysinfo." 2018-01-29 11:45:27 -06:00
Alexander Traud d9e42f27b9 core: Fix unused variable error in handle_show_sysinfo.
The previous fix broke the case
HAVE_SYSINFO = no
HAVE_SYSCTL = yes
HAVE_SWAPCTL = no
which occurs on FreeBSD 11.1 for example.

ASTERISK-26563

Change-Id: If77c39bc75f0b83a6c8a24ecb2fa69be8846160a
2018-01-27 16:44:21 +01:00