Skip to content
Snippets Groups Projects
  1. Feb 23, 2022
    • Naveen Albert's avatar
      cli: Add core dump info to core show settings. · 4358c776
      Naveen Albert authored
      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
      4358c776
  2. Jan 19, 2022
    • Michał Górny's avatar
      main: Enable rdtsc support on NetBSD · d68d90c5
      Michał Górny authored
      Enable the Linux rdtsc implementation on NetBSD as well.  The assembly
      works correctly there.
      
      ASTERISK-29851
      
      Change-Id: I460ad9b4d971913420ecb84186f5ba5ab03f6f37
      d68d90c5
  3. Nov 15, 2021
    • Josh Soref's avatar
      main: Spelling fixes · 4019a93e
      Josh Soref authored
      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
      4019a93e
  4. May 25, 2021
  5. Mar 22, 2021
    • Mark Murawski's avatar
      logger: Console sessions will now respect logger.conf dateformat= option · a0009c80
      Mark Murawski authored
      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
      a0009c80
  6. Mar 04, 2021
  7. Jan 06, 2021
    • Sean Bright's avatar
      asterisk: Export additional manager functions · 68d3d3af
      Sean Bright authored
      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
      68d3d3af
  8. Jul 28, 2020
    • Sean Bright's avatar
      utf8.c: Add UTF-8 validation and utility functions · d9ae902f
      Sean Bright authored
      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
      d9ae902f
  9. Jun 02, 2020
    • George Joseph's avatar
      Scope Tracing: A new facility for tracing scope enter/exit · ca3c22c5
      George Joseph authored
      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
      ca3c22c5
  10. May 08, 2020
    • Pirmin Walthert's avatar
      app.c: make sure that no non-async-signal-safe syscalls are used after · 6b2d9451
      Pirmin Walthert authored
      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
      6b2d9451
  11. Feb 03, 2020
    • George Joseph's avatar
      message.c: Add option to suppress the Message channel AMI and ARI events · b76ab5e5
      George Joseph authored
      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
      b76ab5e5
  12. Nov 18, 2019
    • Kevin Harwell's avatar
      various files - fix some alerts raised by lgtm code analysis · bdd785d3
      Kevin Harwell authored
      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
      bdd785d3
  13. Apr 23, 2019
    • Kevin Harwell's avatar
      mwi core: Move core MWI functionality into its own files · ff0d0ac2
      Kevin Harwell authored
      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
      ff0d0ac2
  14. Mar 08, 2019
  15. Dec 12, 2018
    • Joshua C. Colp's avatar
      stasis: Add statistics gathering in developer mode. · fe070936
      Joshua C. Colp authored
      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
      fe070936
  16. Nov 15, 2018
  17. Nov 11, 2018
  18. Aug 01, 2018
    • Corey Farrell's avatar
      Build System: Improve ccache matching for different menuselect options. · a10a3aff
      Corey Farrell authored
      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
      a10a3aff
  19. Jul 23, 2018
  20. Jul 20, 2018
  21. Jul 16, 2018
    • Corey Farrell's avatar
      loader: Fix startup issues. · 49f83a74
      Corey Farrell authored
      * 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
      49f83a74
  22. Apr 20, 2018
  23. Mar 27, 2018
  24. Mar 26, 2018
    • Guido Falsi's avatar
      core: fix getopt(3) usage · 48190c7f
      Guido Falsi authored
      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
      48190c7f
  25. Mar 22, 2018
    • Corey Farrell's avatar
      core: Create main/options.c. · a6d58c51
      Corey Farrell authored
      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
      a6d58c51
  26. Mar 19, 2018
    • George Joseph's avatar
      channel.c: Allow generic plc then channel formats are equal · 5d097f82
      George Joseph authored
      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
      5d097f82
  27. Mar 17, 2018
    • Corey Farrell's avatar
      core: Minor cleanup of ast_el_read_char. · 5b404411
      Corey Farrell authored
      * 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
      5b404411
  28. Mar 14, 2018
    • Corey Farrell's avatar
      loader: Convert reload_classes to built-in modules. · 572a508e
      Corey Farrell authored
      * 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
      572a508e
  29. Mar 13, 2018
    • Corey Farrell's avatar
      core: Remove non-critical cleanup from startup aborts. · fee929c8
      Corey Farrell authored
      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
      fee929c8
  30. Feb 28, 2018
    • Richard Mudgett's avatar
      pjproject: Add cache_pools debugging option. · 1a36a452
      Richard Mudgett authored
      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
      1a36a452
  31. Feb 13, 2018
  32. Feb 12, 2018
    • Corey Farrell's avatar
      core: Remove embedded editline. · 9fddc8b4
      Corey Farrell authored
      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
      9fddc8b4
  33. Jan 27, 2018
  34. Jan 26, 2018
    • Corey Farrell's avatar
      core: Tweak startup order. · 39fcecad
      Corey Farrell authored
      Move initialization of units which do not require configuration to occur
      before preload modules.  This leaves only units which load config between
      module preload and regular load stages.
      
      Change-Id: I1d15384acad16a22c3498124421af474fa517478
      39fcecad
  35. Dec 20, 2017
  36. Dec 19, 2017
    • Corey Farrell's avatar
      CLI: Address multiple issues. · d51837a1
      Corey Farrell authored
      * listen uses the variable `s` for the result from ast_poll() then
        overwrites it with the result of accept().  Create a separate variable
        poll_result to avoid confusion since ast_poll does not return a file
        descriptor.
      * Resolve fd leak that would occur if setsockopt failed in listen.
      * Reserve an extra byte while processing completion results from remote
        daemon.  This fixes a bug where completion processing used strstr() on
        a string that was not '\0' terminated.  This was no risk to the Asterisk
        daemon, the bug was only reachable the remote console process.
      * Resolve leak in handle_showchan when the channel is not found.
      * Multiple leaks and a deadlock in pbx_config CLI completion.
      * Fix leaks in "manager show command".
      
      Change-Id: I8f633ceb1714867ae30ef4e421858f77c14485a9
      d51837a1
  37. Dec 13, 2017
    • Corey Farrell's avatar
      CLI: Remove special handling of 'core set verbose' from rasterisk. · 5f6a3c43
      Corey Farrell authored
      rasterisk does not need to handle setting verbose levels locally, it
      should just tell the daemon what it wants and print what it is given.
      Just max out the verbose level on the local client so all filtering
      happens on the daemon.
      
      ASTERISK-20281 #close
      
      Change-Id: Ia305f75f1fc424a9169bfa30ef70d626ace2c8a8
      5f6a3c43
  38. Dec 12, 2017
  39. Dec 08, 2017
    • Sean Bright's avatar
      utils: Add convenience function for setting fd flags · 2ffe52a1
      Sean Bright authored
      There are many places in the code base where we ignore the return value
      of fcntl() when getting/setting file descriptior flags. This patch
      introduces a convenience function that allows setting or clearing file
      descriptor flags and will also log an error on failure for later
      analysis.
      
      Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7
      2ffe52a1
  40. Dec 06, 2017
    • Corey Farrell's avatar
      sounds_index: Avoid repeatedly reindexing. · ab191e97
      Corey Farrell authored
      The sounds index is rebuilt each time a format is registered or
      unregistered.  This causes the index to be repeatedly rebuilt during
      startup and shutdown.
      
      This patch significantly reduces the work done by delaying sound index
      initialization until after modules are loaded.  This way a reindex only
      occurs if a format module is loaded after startup.  We also skip
      reindexing when format modules are unloaded during shutdown.
      
      Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a
      ab191e97
Loading