6 months agocore: Improve MALLOC_DEBUG for frames.
Corey Farrell [Fri, 8 Nov 2019 15:20:13 +0000 (10:20 -0500)]
core: Improve MALLOC_DEBUG for frames.

* Pass caller information to frame allocation functions.
* Disable caching as it interfers with MALLOC_DEBUG reporting.
* Stop using ast_calloc_cache.

Change-Id: Id343cd80a3db941d2daefde2a060750fea8cd260

6 months agoBuild: Fix compile issues with seldom used modules
George Joseph [Tue, 29 Oct 2019 13:23:54 +0000 (07:23 -0600)]
Build:  Fix compile issues with seldom used modules

The following modules needed tweaks for API changes.



Change-Id: Ib40e513ae55b5114be035cdc929abb6a8ce2d06d

6 months agores_pjsip_outbound_registration: Extend documentation for "max_retries".
Joshua Colp [Fri, 25 Oct 2019 11:46:41 +0000 (11:46 +0000)]
res_pjsip_outbound_registration: Extend documentation for "max_retries".

If the "max_retries" option is set to 0 then upon failure no
further attemps are made, so explicitly document the behavior.


Change-Id: I1e30daae9dd6c49ce18744164214d3def505acbf

6 months agoMerge "res_ari_events: Add module reference when a WebSocket is open."
Joshua Colp [Tue, 29 Oct 2019 15:25:06 +0000 (10:25 -0500)]
Merge "res_ari_events: Add module reference when a WebSocket is open."

7 months agores_calendar: Resolve memory leak on calendar destruction
Sean Bright [Thu, 24 Oct 2019 14:15:14 +0000 (10:15 -0400)]
res_calendar: Resolve memory leak on calendar destruction

Calling ne_uri_parse allocates memory that needs to be freed with a
corresponding call to ne_uri_free.

ASTERISK-28572 #close

Change-Id: I8a6834da27000a6807d89cb7a157b2a88fcb5e61

7 months agores_ari_events: Add module reference when a WebSocket is open.
Joshua Colp [Thu, 24 Oct 2019 10:21:31 +0000 (07:21 -0300)]
res_ari_events: Add module reference when a WebSocket is open.

This change ensures that the module isn't unloaded when a
WebSocket is open. Previously it was possible to unload the
module manually or during shutdown which could cause a crash
when any active WebSockets were terminated.


Change-Id: I85c71ab112f99875b586419a34c08c8b34c14c5c

7 months agoMerge "ExternalMedia: Change return object from ExternalMedia to Channel"
George Joseph [Mon, 21 Oct 2019 18:53:38 +0000 (13:53 -0500)]
Merge "ExternalMedia:  Change return object from ExternalMedia to Channel"

7 months agoMerge "utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN"
Kevin Harwell [Mon, 21 Oct 2019 18:51:49 +0000 (13:51 -0500)]
Merge "utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN"

7 months agoMerge "app_voicemail.c: Support multiple file formats for forwarded messages."
Joshua Colp [Mon, 21 Oct 2019 15:32:17 +0000 (10:32 -0500)]
Merge "app_voicemail.c: Support multiple file formats for forwarded messages."

7 months agoMerge "Crash during "pjsip show channelstats" execution"
Friendly Automation [Mon, 21 Oct 2019 13:01:48 +0000 (08:01 -0500)]
Merge "Crash during "pjsip show channelstats" execution"

7 months agoutils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN
Sean Bright [Fri, 18 Oct 2019 18:47:20 +0000 (14:47 -0400)]
utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN

ASTERISK-28590 #close

Change-Id: I51abce00c04d0a06550bda5205580705185b9c1c

7 months agoMerge " Speling correetions."
Joshua Colp [Fri, 18 Oct 2019 17:54:37 +0000 (12:54 -0500)]
Merge " Speling correetions."

7 months agoExternalMedia: Change return object from ExternalMedia to Channel
George Joseph [Fri, 18 Oct 2019 11:36:12 +0000 (05:36 -0600)]
ExternalMedia:  Change return object from ExternalMedia to Channel

When we created the External Media addition to ARI we created an
ExternalMedia object to be returned from the channels/externalMedia
REST endpoint.  This object contained the channel object that was
created plus local_address and local_port attributes (which are
also in the Channel variables).  At the time, we thought that
creating an ExternalMedia object would give us more flexibility
in the future but as we created the sample speech to text
application, we discovered that it doesn't work so well with ARI
client libraries that a) don't have the ExternalMedia object
defined and/or b) can't promote the embedded channel structure
to a first-class Channel object.

This change causes the channels/externalMedia REST endpoint to
return a Channel object (like channels/create and channels/originate)
instead of the ExternalMedia object.

Change-Id: If280094debd35102cf21e0a31a5e0846fec14af9

7 months agoCrash during "pjsip show channelstats" execution
Salah Ahmed [Fri, 18 Oct 2019 09:22:22 +0000 (11:22 +0200)]
Crash during "pjsip show channelstats" execution

During execution "pjsip show channelstats" cli command by an
external module asterisk crashed. It seems this is a separate
thread running to fetch and print rtp stats. The crash happened on
the ao2_lock method, just before it going to read the rtp stats on
a rtp instance. According to gdb backtrace log, it seems the
session media was already cleaned up at that moment.


Change-Id: I3e05980dd4694577be6d39be2c21a5736bae3c6f

7 months agores_rtp_asterisk: Remove a log message that slipped in.
Joshua Colp [Thu, 17 Oct 2019 10:50:28 +0000 (07:50 -0300)]
res_rtp_asterisk: Remove a log message that slipped in.

This was only supposed to be for testing, so now it can be

Change-Id: I3dfc2e776e70b3196aeed5688372ea80c0214b59

7 months Speling correetions.
Sean Bright [Wed, 16 Oct 2019 21:06:52 +0000 (17:06 -0400)] Speling correetions.

ASTERISK-28586 #close

Change-Id: I43dc4e8bd9dc685b17695b215a5360314074734f

7 months agoMerge "test_res_rtp: Enable FIR and REMB nominal tests."
Friendly Automation [Wed, 16 Oct 2019 12:50:18 +0000 (07:50 -0500)]
Merge "test_res_rtp: Enable FIR and REMB nominal tests."

7 months agoapp_voicemail.c: Support multiple file formats for forwarded messages.
cmaj [Fri, 27 Sep 2019 00:24:12 +0000 (18:24 -0600)]
app_voicemail.c: Support multiple file formats for forwarded messages.

If you specify multiple formats in voicemail.conf, eg. "format = gsm|wav"
and are using realtime ODBC backend, only the first format gets stored
in the database. So when you forward a message later on, there is a bug
generating the email, related to the stored format (GSM) being different
than the desired email format (WAV) specified for the user. Sox can
handle this, but Asterisk needs to tell sox exactly what to do.


Change-Id: I7321e7f7e7c58adbf41dd4fd7191c887b9b2eafd

7 months agoMerge "res_pjsip_mwi: potential double unref, and potential unwanted double link"
George Joseph [Mon, 14 Oct 2019 17:01:28 +0000 (12:01 -0500)]
Merge "res_pjsip_mwi: potential double unref, and potential unwanted double link"

7 months agotest_res_rtp: Enable FIR and REMB nominal tests.
Joshua Colp [Mon, 14 Oct 2019 11:19:23 +0000 (11:19 +0000)]
test_res_rtp: Enable FIR and REMB nominal tests.

Now that both FIR and REMB are being sent in compound packets
these tests can be enabled.

This also extends the REMB nominal test to cover the REMB
contents itself.

Change-Id: Ibfee526ad780eefcce5dd787f53785382210024a

7 months agoMerge "pbx: deadlock when outgoing dialed channel hangs up too quickly"
Friendly Automation [Mon, 14 Oct 2019 12:16:25 +0000 (07:16 -0500)]
Merge "pbx: deadlock when outgoing dialed channel hangs up too quickly"

7 months agoMerge "cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12"
Friendly Automation [Mon, 14 Oct 2019 11:27:08 +0000 (06:27 -0500)]
Merge "cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12"

7 months agocdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12
Christoph Moench-Tegeder [Tue, 8 Oct 2019 18:40:30 +0000 (20:40 +0200)]
cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12

PostgreSQL 12 finally removed column adsrc from table pg_catalog.pg_attrdef
(column default values), which has been deprecated since version 8.0.
Since then, the official/correct/supported way to retrieve the column
default value from the catalog is function pg_catalog.pg_get_expr().

This change breaks compatibility with pre-8.0 PostgreSQL servers,
but has reached end-of-support more than a decade ago.
cdr_pgsql and res_config_pgsql still have support for pre-7.3
servers, but cleaning that up is perhaps a topic for a major release,
not this bugfix.


Change-Id: I834cb3addf1937e19e87ede140bdd16cea531ebe

7 months agoMerge "pjproject_bundled: Replace earlier reverts with official fixes."
George Joseph [Fri, 11 Oct 2019 14:50:51 +0000 (09:50 -0500)]
Merge "pjproject_bundled:  Replace earlier reverts with official fixes."

7 months agores_pjsip_mwi: potential double unref, and potential unwanted double link
Kevin Harwell [Thu, 10 Oct 2019 20:30:06 +0000 (15:30 -0500)]
res_pjsip_mwi: potential double unref, and potential unwanted double link

When creating an unsolicited MWI aggregate subscription it was possible for
the subscription object to be double unref'ed. This patch removes the explicit
unref as it is not needed since the RAII_VAR will handle it at function end.

Less concerning there was also a bug that could potentially allow the aggregate
subscription object to be added to the unsolicited container twice. This patch
ensures it is added only once.


Change-Id: I9ccfdb5ea788bc0c3618db183aae235e53c12763

7 months agotest_taskprocessor.c: Fix test failure on Ubuntu
csavinovich [Wed, 9 Oct 2019 21:00:31 +0000 (16:00 -0500)]
test_taskprocessor.c: Fix test failure on Ubuntu

Fixes a failure in /main/taskprocesor unit test, only occurring in Ubuntu.
Newer versions of GCC require variable initialization.

Change-Id: I2994d8aab9307a8c2c7330584f287a27144a580c

7 months agoMerge "Revert "app_voicemail: Cleanup stale lock files on module load""
Friendly Automation [Thu, 10 Oct 2019 14:59:53 +0000 (09:59 -0500)]
Merge "Revert "app_voicemail: Cleanup stale lock files on module load""

7 months agoMerge changes from topic "pjsip_shutdown"
George Joseph [Thu, 10 Oct 2019 14:13:15 +0000 (09:13 -0500)]
Merge changes from topic "pjsip_shutdown"

* changes:
  res_pjsip_mwi: use an ao2_global object for mwi containers
  res_pjsip/res_pjsip_mwi: use centralized serializer pools

7 months agoMerge "serializer: move/add asterisk serializer pool functionality"
George Joseph [Thu, 10 Oct 2019 14:12:53 +0000 (09:12 -0500)]
Merge "serializer: move/add asterisk serializer pool functionality"

7 months agoMerge "chan_pjsip: Prevent segfault when running PlayDTMF on hungup channel"
Friendly Automation [Thu, 10 Oct 2019 13:57:05 +0000 (08:57 -0500)]
Merge "chan_pjsip: Prevent segfault when running PlayDTMF on hungup channel"

7 months agopjproject_bundled: Replace earlier reverts with official fixes.
George Joseph [Wed, 9 Oct 2019 14:32:45 +0000 (08:32 -0600)]
pjproject_bundled:  Replace earlier reverts with official fixes.

Issues in pjproject 2.9 caused us to revert some of their changes
as a work around.  This introduced another issue where pjproject
wouldn't build with older gcc versions such as that found on
CentOS 6.  This commit replaces the reverts with the official
fixes for the original issues and allows pjproject to be built
on CentOS 6 again.

Reported-by: Niklas Larsson

Change-Id: I06f8507bea553d1a01b0b8874197d35b9d47ec4c

7 months agopbx: deadlock when outgoing dialed channel hangs up too quickly
Kevin Harwell [Wed, 9 Oct 2019 20:17:59 +0000 (15:17 -0500)]
pbx: deadlock when outgoing dialed channel hangs up too quickly

Here's the basic scenario that occurred when executing an AMI fast originate
while at the same time something else locks the channels container, and also
wants a lock on the dialed channel:

1. pbx_outgoing_attempt obtains a lock on a dialed channel
2. concurrently another thread obtains a lock on the channels container, and
   subsequently requests a lock on the dialed channel. It waits on #1. For
   instance, "core show channel <dialed channel"
3. the outgoing call does not fail, but ends before the pbx_outgoing_attempt
   function exits
4. pbx_outgoing_attempt function exits, the outgoing structure destructs, and
   attempts to hang up the dialed channel
5. hang up tries to obtain the channels container lock, but can't due to #2.
6. Asterisk is deadlocked.

The solution was to allow the pbx_outgoing_exec function to "steal" ownership
of the dialed channel, and handle hanging it up. The channel now is either hung
up prior to it being potentially locked by the initiating thread, or if locked
the hang up takes place in a different thread, thus alleviating the deadlock.

  iliketrains.diff submitted by Joshua Colp (license 5000)

Change-Id: I51b42b92dde8f2215b69bb509e28667ee3a3853a

7 months agoMerge "cdr_mysql: Don't clean up on unload unless we can unregister from CDRs"
Friendly Automation [Tue, 8 Oct 2019 12:27:30 +0000 (07:27 -0500)]
Merge "cdr_mysql: Don't clean up on unload unless we can unregister from CDRs"

7 months agoRevert "app_voicemail: Cleanup stale lock files on module load"
Sean Bright [Mon, 7 Oct 2019 19:02:39 +0000 (14:02 -0500)]
Revert "app_voicemail: Cleanup stale lock files on module load"

This reverts commit fd2e8d0da7ba539470ed73d463d8bc641f7843af.

Reason for revert: Problematic for users who store their voicemail
on network storage devices, or share voicemail storage between
multiple Asterisk instances.

ASTERISK-28567 #close

Change-Id: I3ff4ca983d8e753fe2971f3439bd154705693c41

7 months agochan_pjsip: Prevent segfault when running PlayDTMF on hungup channel
lvl [Tue, 1 Oct 2019 11:29:11 +0000 (13:29 +0200)]
chan_pjsip: Prevent segfault when running PlayDTMF on hungup channel

ASTERISK-28086 #close

Change-Id: Ib3baadc89b9f0477a6f25a63861433812368c5ea

7 months agores_pjsip_mwi: use an ao2_global object for mwi containers
Kevin Harwell [Wed, 2 Oct 2019 17:56:44 +0000 (12:56 -0500)]
res_pjsip_mwi: use an ao2_global object for mwi containers

On shutdown it's possible for the unsolicited mwi container to be freed before
other dependent threads are done using it. This patch ensures this can no
longer happen by wrapping the container in an ao2_global object. The solicited
container was also changed too.


Change-Id: I8f812286dc19a34916acacd71ce2ec26e1042047

7 months agoserializer: move/add asterisk serializer pool functionality
Kevin Harwell [Wed, 2 Oct 2019 17:55:38 +0000 (12:55 -0500)]
serializer: move/add asterisk serializer pool functionality

Serializer pools have previously existed in Asterisk. However, for the most
part the code has been duplicated across modules. This patch abstracts the
code into an 'ast_serializer_pool' object. As well the code is now centralized
in serializer.c/h.

In addition serializer pools can now optionally be monitored by a shutdown
group. This will prevent the pool from being destroyed until all serializers
have completed.

Change-Id: Ib1e906144b90ffd4d5ed9826f0b719ca9c6d2971

7 months agores_pjsip/res_pjsip_mwi: use centralized serializer pools
Kevin Harwell [Wed, 2 Oct 2019 17:56:14 +0000 (12:56 -0500)]
res_pjsip/res_pjsip_mwi: use centralized serializer pools

Both res_pjsip and res_pjsip_mwi made use of serializer pools. However, they
both implemented their own serializer pool functionality that was pretty much
identical in each of the source files. This patch removes the duplicated code,
and uses the new 'ast_serializer_pool' object instead.

Additionally res_pjsip_mwi enables a shutdown group on the pool since if the
timing was right the module could be unloaded while taskprocessor threads still
needed to execute, thus causing a crash.

Change-Id: I959b0805ad024585bbb6276593118be34fbf6e1d

7 months agoMerge "channel/chan_pjsip: add dialplan function for music on hold"
Friendly Automation [Mon, 7 Oct 2019 13:02:42 +0000 (08:02 -0500)]
Merge "channel/chan_pjsip: add dialplan function for music on hold"

7 months agocdr_mysql: Don't clean up on unload unless we can unregister from CDRs
Sean Bright [Fri, 4 Oct 2019 20:31:22 +0000 (16:31 -0400)]
cdr_mysql: Don't clean up on unload unless we can unregister from CDRs

ASTERISK-28566 #close

Change-Id: I6daa4e5128e9406d04d3aed670c3bae98d38d40c

7 months agoMerge "stasis_state: Create internal stasis_state_proxy object."
Friendly Automation [Fri, 4 Oct 2019 11:56:30 +0000 (06:56 -0500)]
Merge "stasis_state: Create internal stasis_state_proxy object."

7 months agostasis: Pass bumped topic_all reference to proxy_dtor.
Joshua Colp [Tue, 1 Oct 2019 14:01:17 +0000 (14:01 +0000)]
stasis: Pass bumped topic_all reference to proxy_dtor.

This avoids use of the global variable and ensures topic_all remains
active until all topics are freed.

  ASTERISK-28553.patch by coreyfarrell (license 5909)

Change-Id: I9a8cd8977f3c3a6aa00783f8336d2cfb9c2820f1

7 months agoMerge "res_pjsip_pubsub: add endpoint to some warning"
George Joseph [Tue, 1 Oct 2019 11:33:18 +0000 (06:33 -0500)]
Merge "res_pjsip_pubsub: add endpoint to some warning"

7 months agochannel/chan_pjsip: add dialplan function for music on hold
Torrey Searle [Thu, 19 Sep 2019 08:56:26 +0000 (10:56 +0200)]
channel/chan_pjsip: add dialplan function for music on hold

Add a new dialplan function PJSIP_MOH_PASSTHROUGH that allows
the on-hold behavior to be controlled on a per-call basis

ASTERISK-28542 #close

Change-Id: Iebe905b2ad6dbaa87ab330267147180b05a3c3a8

7 months agores_pjsip_pubsub: add endpoint to some warning
Alexei Gradinari [Tue, 24 Sep 2019 19:18:14 +0000 (15:18 -0400)]
res_pjsip_pubsub: add endpoint to some warning

There are some warning messages which are not informative without endpoint:
"No registered subscribe handler for event presence.winfo"
"No registered publish handler for event presence"

This patch adds an endpoint name to these messages.

Change-Id: Ia2811ec226d8a12659b4f9d4d224b48289650827

7 months agores_pjsip_transport_websocket: Don't put brackets around local_name if IPv6
Sean Bright [Fri, 27 Sep 2019 14:54:53 +0000 (10:54 -0400)]
res_pjsip_transport_websocket: Don't put brackets around local_name if IPv6

ASTERISK-28544 #close

Change-Id: I8e62c444d107674c298f472e3545661de8a80dce

7 months agoMerge "basic-pbx: Bring forward queue configuration from 13"
George Joseph [Fri, 27 Sep 2019 13:59:36 +0000 (08:59 -0500)]
Merge "basic-pbx: Bring forward queue configuration from 13"

7 months agoMerge "res_musiconhold: Add new 'playlist' mode"
George Joseph [Fri, 27 Sep 2019 13:57:41 +0000 (08:57 -0500)]
Merge "res_musiconhold: Add new 'playlist' mode"

7 months agoMerge "taskprocessor.c: Added "like" support to 'core show taskprocessors'"
George Joseph [Fri, 27 Sep 2019 13:56:51 +0000 (08:56 -0500)]
Merge "taskprocessor.c: Added "like" support to 'core show taskprocessors'"

7 months agoMerge "pbx: Prevent Realtime switch crash on invalid priority"
Friendly Automation [Fri, 27 Sep 2019 13:29:54 +0000 (08:29 -0500)]
Merge "pbx: Prevent Realtime switch crash on invalid priority"

7 months agobasic-pbx: Bring forward queue configuration from 13
Jonathan Rose [Fri, 27 Mar 2015 22:34:48 +0000 (22:34 +0000)]
basic-pbx: Bring forward queue configuration from 13

Original commit: cfbf5fbe918bc34f3d600760fc0b6f13a3a9a0ed

Change-Id: I34a841d73c429ca8d944481f8dccb756ee231c9c

7 months agoMerge "res_pjsip_registrar: Validate Contact URI before adding to responses"
Friendly Automation [Thu, 26 Sep 2019 09:50:26 +0000 (04:50 -0500)]
Merge "res_pjsip_registrar: Validate Contact URI before adding to responses"

7 months agopbx: Prevent Realtime switch crash on invalid priority
Sean Bright [Wed, 25 Sep 2019 16:01:33 +0000 (12:01 -0400)]
pbx: Prevent Realtime switch crash on invalid priority

pbx_extension_helper takes two 'context' arguments. One (con) is a
pointer directly to a 'struct ast_context' and the other (context) is
the name of the context. In all cases, one of these arguments is NULL
and the other is non-NULL.

Functions that are ultimately called by pbx_extension_helper expect that
'context' will be non-NULL, so we set it unconditionally on entry into
this function.

ASTERISK-28534 #close

Change-Id: Ifbbc5e71440afd80efd441f7a9d72e8b10b6f47d

7 months agotaskprocessor.c: Added "like" support to 'core show taskprocessors'
Ben Ford [Tue, 24 Sep 2019 20:44:14 +0000 (15:44 -0500)]
taskprocessor.c: Added "like" support to 'core show taskprocessors'

Added "like" support for 'core show taskprocessors'. Now you
can specify a specific set of taskprocessors (or just one) by
adding the keyword "like" to the above command, followed by
your search criteria.

Change-Id: I021e740201e9ba487204b5451e46feb0e3222464

7 months agoMerge "core: Fix ABI mismatch of ao2_global_obj."
George Joseph [Wed, 25 Sep 2019 13:16:39 +0000 (08:16 -0500)]
Merge "core: Fix ABI mismatch of ao2_global_obj."

7 months agoMerge "taskprocessor.c: Add CLI commands to reset taskprocessor stats."
George Joseph [Wed, 25 Sep 2019 12:04:47 +0000 (07:04 -0500)]
Merge "taskprocessor.c: Add CLI commands to reset taskprocessor stats."

7 months agoMerge "res_pjsip_pubsub: change warning to debug"
George Joseph [Wed, 25 Sep 2019 12:03:46 +0000 (07:03 -0500)]
Merge "res_pjsip_pubsub: change warning to debug"

7 months agores_musiconhold: Add new 'playlist' mode
Sean Bright [Wed, 18 Sep 2019 11:56:05 +0000 (07:56 -0400)]
res_musiconhold: Add new 'playlist' mode

Allow the list of files to be played to be provided explicitly in the
music class's configuration. The primary driver for this change is to
allow URLs to be used for MoH.

Change-Id: I9f43b80b43880980b18b2bee26ec09429d0b92fa

7 months agores_pjsip_registrar: Validate Contact URI before adding to responses
Sean Bright [Tue, 24 Sep 2019 22:43:13 +0000 (18:43 -0400)]
res_pjsip_registrar: Validate Contact URI before adding to responses

If a permanent contact URI associated with an AOR is invalid, we add a
Contact header to REGISTER responses with a NULL URI, causing a crash.

ASTERISK-28463 #close

Change-Id: Id2b643e58b975bc560aab1c111e6669d54db9102

7 months agoMerge "core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option."
George Joseph [Wed, 25 Sep 2019 11:04:18 +0000 (06:04 -0500)]
Merge "core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option."

8 months agoMerge "pjproject_bundled: Revert pjproject 2.9 commits causing leaks"
George Joseph [Tue, 24 Sep 2019 20:38:23 +0000 (15:38 -0500)]
Merge "pjproject_bundled:  Revert pjproject 2.9 commits causing leaks"

8 months agostasis_state: Create internal stasis_state_proxy object.
Corey Farrell [Fri, 20 Sep 2019 14:08:02 +0000 (10:08 -0400)]
stasis_state: Create internal stasis_state_proxy object.

This improves the way which stasis_state reference counting works.
Since manager->states holds onto the proxy object instead of the real
object this allows stasis_state objects to be freed when appropriate
without use of a special state_remove function.  Additionally each
distinct eid associated with the state holds a reference to the state to
prevent early release and potentially allow easier debug of leaks.

Change-Id: I400e0db4b9afa3d5cb4ac7dad60907897e73f9a9

8 months agores_pjsip_pubsub: change warning to debug
Kevin Harwell [Tue, 24 Sep 2019 16:21:12 +0000 (11:21 -0500)]
res_pjsip_pubsub: change warning to debug

The following message:

"Subscription request from endpoint <blah> rejected. Expiration of 0 is invalid"

Would sometimes spam the log with warnings if Asterisk restarted and a bunch
of clients sent unsubscribes. This patch changes it from a warning to a debug

Change-Id: I841ec42f65559f3135e037df0e55f89b6447a467

8 months agotaskprocessor.c: Add CLI commands to reset taskprocessor stats.
Ben Ford [Tue, 24 Sep 2019 14:40:35 +0000 (09:40 -0500)]
taskprocessor.c: Add CLI commands to reset taskprocessor stats.

Added two new CLI commands to reset stats for taskprocessors. You can
reset stats for a single, specific taskprocessor ('core reset
taskprocessor <taskprocessor>'), or you can reset all taskprocessors
('core reset taskprocessors'). These commands will reset the counter for
the number of tasks processed as well as the max queue size.

Change-Id: Iaf17fc4ae29396ab0c6ac92408fc7bdc2f12362d

8 months agoMerge "res_sorcery_memory_cache: stale item update leak"
Kevin Harwell [Tue, 24 Sep 2019 15:27:44 +0000 (10:27 -0500)]
Merge "res_sorcery_memory_cache: stale item update leak"

8 months agoMerge "astmm.c: Display backtrace with memory show allocations"
George Joseph [Tue, 24 Sep 2019 13:27:26 +0000 (08:27 -0500)]
Merge "astmm.c:  Display backtrace with memory show allocations"

8 months agopjproject_bundled: Revert pjproject 2.9 commits causing leaks
George Joseph [Thu, 19 Sep 2019 14:50:07 +0000 (08:50 -0600)]
pjproject_bundled:  Revert pjproject 2.9 commits causing leaks

We've found a connection re-use regression in pjproject 2.9
introduced by commit
"Close #1019: Support for multiple listeners."

Normally, multiple SSL requests should reuse the same connection
if one already exists to the remote server.  When a transport
error occurs, the next request should establish a new connection
and any following requests should use that same one.  With this
patch, when a transport error occurs, every new request creates
a new connection so you can wind up with thousands of open tcp
sockets, possibly exhausting file handles, and increasing memory

Reverting pjproject commit 6002 (and related 6021) restores the
expected behavior.

We also found a memory leak in SSL processing that was introduced by
"Fixed #2204: Add OpenSSL remote certificate chain info"

Apparently the remote certificate chain is continually recreated
causing the leak.

Reverting pjproject commit 6014 (and related 6022) restores the
expected behavior.

Both of these issues have been acknowledged by Teluu.


Change-Id: I8ae7233c3ac4ec29a3b991f738e655dabcaba9f1

8 months agoMerge "app_voicemail: Fix module unload leak."
Kevin Harwell [Mon, 23 Sep 2019 20:28:25 +0000 (15:28 -0500)]
Merge "app_voicemail: Fix module unload leak."

8 months agoMerge "stasis: can incorrectly report skewed objects."
Friendly Automation [Mon, 23 Sep 2019 19:07:27 +0000 (14:07 -0500)]
Merge "stasis: can incorrectly report skewed objects."

8 months agocore: Add AO2_ALLOC_OPT_NO_REF_DEBUG option.
Corey Farrell [Sun, 22 Sep 2019 21:59:54 +0000 (17:59 -0400)]
core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option.

Previous to this patch passing a NULL tag to ao2_alloc or ao2_ref based
functions would result in the reference not being logged under
REF_DEBUG.  This could sometimes cause inaccurate logging if NULL was
accidentally passed to a reference action.  Now reference logging is
only disabled by option passed to the allocation method.

Change-Id: I3c17d867d901d53f9fcd512bef4d52e342637b54

8 months agores_sorcery_memory_cache: stale item update leak
Kevin Harwell [Mon, 23 Sep 2019 16:01:36 +0000 (11:01 -0500)]
res_sorcery_memory_cache: stale item update leak

When a stale item was being updated the object was being retrieved, but its
reference was not being decremented after the update. This patch makes it so
the object is now appropriately de-referenced.


Change-Id: I9d8173d3a0416a242f4eba92fa0853279c500ec7

8 months agoastmm.c: Display backtrace with memory show allocations
George Joseph [Mon, 23 Sep 2019 12:09:29 +0000 (06:09 -0600)]
astmm.c:  Display backtrace with memory show allocations

You can currently capture backtraces of memory allocations but they
only get displayed when you stop asterisk and the atexit hooks
are enabled.  Now, if memory backtrace is on and you issue a
"memory show allocations" CLI command for a specific file, then
a backtrace will show for each allocation that occurred after
you turned "memory backtrace on".  The backtrace display is shown
only when a specific file's allocations are displayed to prevent
a massive CLI dump of every file's allocations.

Change-Id: Ic657afc1fc6ec7205e16eb36a97a611d235a2b4f

8 months agocore: Fix ABI mismatch of ao2_global_obj.
Corey Farrell [Mon, 23 Sep 2019 02:04:44 +0000 (22:04 -0400)]
core: Fix ABI mismatch of ao2_global_obj.

astobj2.c declares DEBUG_THREADS_LOOSE_ABI to avoid overhead of debug
threads tracking information in the internal structures of astobj2.
Unfortunately this means that ao2_global_obj contains the statically
allocated debug threads tracking fields which are used by initialization
and cleanup but main/astobj2.c believed those fields and associated
space did not exist.

Change-Id: Icef41ad97d88a8c1d1515e034ec8133cab3b1527

8 months agostasis: can incorrectly report skewed objects.
Corey Farrell [Fri, 20 Sep 2019 13:29:01 +0000 (09:29 -0400)]
stasis: can incorrectly report skewed objects.

It is possible for topic->name to be NULL, this causes the allocation
reference to not be logged.  Use the name variable instead which has
been verified to be a non-empty.

Change-Id: I3d0031d03c8356e4808f00cdf2d5428712575883

8 months agostasis: Fix leaks
Corey Farrell [Thu, 19 Sep 2019 22:32:56 +0000 (18:32 -0400)]
stasis: Fix leaks

* Release reference returned by cache_remove
* state_alloc unconditionally bumped state_topic even when it was
  locally allocated.

Change-Id: I51101bf7d07b8dc8ce8fc46b6cb31fbbd213fbc7

8 months agoapp_voicemail: Fix module unload leak.
Corey Farrell [Thu, 19 Sep 2019 15:53:19 +0000 (11:53 -0400)]
app_voicemail: Fix module unload leak.

Change-Id: Ib9a06565b9a178822d3bbb67eccf51432e12d84a

8 months agoMerge "func_jitterbuffer: Add audio/video sync support."
Joshua Colp [Thu, 19 Sep 2019 13:23:15 +0000 (08:23 -0500)]
Merge "func_jitterbuffer: Add audio/video sync support."

8 months agoMerge "core: Add H.265/HEVC passthrough support"
Friendly Automation [Wed, 18 Sep 2019 21:50:23 +0000 (16:50 -0500)]
Merge "core: Add H.265/HEVC passthrough support"

8 months agofunc_jitterbuffer: Add audio/video sync support.
Joshua Colp [Fri, 6 Sep 2019 13:18:55 +0000 (13:18 +0000)]
func_jitterbuffer: Add audio/video sync support.

This change adds support to the JITTERBUFFER dialplan function
for audio and video synchronization. When enabled the RTCP SR
report is used to produce an NTP timestamp for both the audio and
video streams. Using this information the video frames are queued
until their NTP timestamp is equal to or behind the NTP timestamp
of the audio. The audio jitterbuffer acts as the leader deciding
when to shrink/grow the jitterbuffer when adaptive is in use. For
both adaptive and fixed the video buffer follows the size of the
audio jitterbuffer.


Change-Id: I3fd75160426465e6d46bb2e198c07b9d314a4492

8 months agoMerge "chan_pjsip: Relock correct channel during "fax" redirect."
Friendly Automation [Wed, 18 Sep 2019 12:44:27 +0000 (07:44 -0500)]
Merge "chan_pjsip: Relock correct channel during "fax" redirect."

8 months agoMerge "chan_dahdi: Fix build with clang/llvm"
George Joseph [Tue, 17 Sep 2019 14:30:36 +0000 (09:30 -0500)]
Merge "chan_dahdi: Fix build with clang/llvm"

8 months agocore: Add H.265/HEVC passthrough support
Florian Floimair [Thu, 22 Aug 2019 12:44:07 +0000 (14:44 +0200)]
core: Add H.265/HEVC passthrough support

This change adds H.265/HEVC as a known codec and creates a cached
"h265" media format for use.

Note that RFC 7798 section 7.2 also describes additional SDP
parameters. Handling of these is not yet supported.


Change-Id: I26d262cc4110b4f7e99348a3ddc53bad0d2cd1f2

8 months agochan_dahdi: Fix build with clang/llvm
Guido Falsi [Sat, 14 Sep 2019 15:05:23 +0000 (17:05 +0200)]
chan_dahdi: Fix build with clang/llvm

On FreeBSD using the clang/llvm compiler build fails to build due
to the switch statement argument being a non integer type expression.
Switch to an if/else if/else construct to sidestep the issue.

ASTERISK-28536 #close

Change-Id: Idf4a82cc1e94580a2d017fe9e351c226f23e20c8

8 months agochan_pjsip: Relock correct channel during "fax" redirect.
Joshua Colp [Sun, 15 Sep 2019 19:35:45 +0000 (19:35 +0000)]
chan_pjsip: Relock correct channel during "fax" redirect.

When fax detection occurs on an outbound PJSIP channel the
redirect operation will result in a masquerade occurring and
the underlying channel on the session changing. The code
incorrectly relocked the new channel instead of the old
channel when returning. This resulted in the new channel
being locked indefinitely. The code now always acts on the
expected channel.


Change-Id: I2b2e60d07e74383ae7e90d752c036c4b02d6b3a3

8 months agores_rtp_asterisk.c: Send RTCP as compound packets.
Ben Ford [Tue, 3 Sep 2019 17:20:20 +0000 (12:20 -0500)]
res_rtp_asterisk.c: Send RTCP as compound packets.

According to RFC3550, ALL RTCP packets must be sent in a compond packet
of at least two individual packets, including SR/RR and SDES. REMB,
FIR, and NACK were not following this format, and as a result, would
fail the packet check in ast_rtcp_interpret. This was found from writing
unit tests for RTCP. The browser would accept the way we were
constructing these RTCP packets, but when sending directly from one
Asterisk instance to another, the above mentioned problem would occur.

Change-Id: Ieb140e9c22568a251a564cd953dd22cd33244605

8 months agochannels: Allow updating variable value
Sean Bright [Wed, 11 Sep 2019 20:58:29 +0000 (16:58 -0400)]
channels: Allow updating variable value

When modifying an already defined variable in some channel drivers they
add a new variable with the same name to the list, but that value is
never used, only the first one found.

Introduce ast_variable_list_replace() and use it where appropriate.

ASTERISK-23756 #close
  setvar-multiplie.patch submitted by Michael Goryainov

Change-Id: Ie1897a96c82b8945e752733612ee963686f32839

8 months agoMerge "res_rtp: Add unit tests for RTCP stats."
Friendly Automation [Thu, 12 Sep 2019 20:22:38 +0000 (15:22 -0500)]
Merge "res_rtp: Add unit tests for RTCP stats."

8 months agoMerge "ChanIsAvail() generates a CDR when unanswered=yes in cdr.conf."
Joshua Colp [Wed, 11 Sep 2019 14:27:09 +0000 (09:27 -0500)]
Merge "ChanIsAvail() generates a CDR when unanswered=yes in cdr.conf."

8 months agoMerge "res_musiconhold: Added unregister realtime moh class"
Friendly Automation [Wed, 11 Sep 2019 14:00:47 +0000 (09:00 -0500)]
Merge "res_musiconhold: Added unregister realtime moh class"

8 months agoMerge "chan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up"
Friendly Automation [Wed, 11 Sep 2019 12:13:30 +0000 (07:13 -0500)]
Merge "chan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up"

8 months agoMerge "chan_sip: Update links referenced in deprecation notice"
Joshua Colp [Wed, 11 Sep 2019 12:12:48 +0000 (07:12 -0500)]
Merge "chan_sip:  Update links referenced in deprecation notice"

8 months agoMerge "codec_resample: Ensure OUTSIDE_SPEEX is defined when necessary"
Joshua Colp [Wed, 11 Sep 2019 11:19:26 +0000 (06:19 -0500)]
Merge "codec_resample: Ensure OUTSIDE_SPEEX is defined when necessary"

8 months agores_musiconhold: Added unregister realtime moh class
sungtae kim [Tue, 27 Aug 2019 22:44:33 +0000 (00:44 +0200)]
res_musiconhold: Added unregister realtime moh class

This fix allows a realtime moh class to be unregistered from the command
line. This is useful when the contents of a directory referenced by a
realtime moh class have changed.
The realtime moh class is then reloaded on the next request and uses the
new directory contents.


Change-Id: Ibc4c6834592257c4bb90601ee299682d15befbce

8 months agores_rtp: Add unit tests for RTCP stats.
Ben Ford [Wed, 28 Aug 2019 19:25:57 +0000 (14:25 -0500)]
res_rtp: Add unit tests for RTCP stats.

Added unit tests for RTCP video stats. These tests include NACK, REMB,
FIR/FUR/PLI, SR/RR/SDES, and packet loss statistics. The REMB and FIR
tests are currently disabled due to a bug. We expect to receive a
compound packet, but the code sends this out as a single packet, which
the browser accepts, but makes Asterisk upset.

While writing these tests, I noticed an issue with NACK as well. Where
it is handling a received NACK request, it was reading in only the first
8 bits of following packets that were also lost. This has been changed
to the correct value of 16 bits.

Also made a minor fix to the data buffer unit test.

Change-Id: I56107c7411003a247589bbb6086d25c54719901b

8 months agoChanIsAvail() generates a CDR when unanswered=yes in cdr.conf.
Frederic LE FOLL [Thu, 5 Sep 2019 16:09:28 +0000 (18:09 +0200)]
ChanIsAvail() generates a CDR when unanswered=yes in cdr.conf.

ChanIsAvail() creates a temporary channel with ast_request() to test
resource availability. It should not generate a CDR when it hangs up
this temporary channel.

This patch disables CDR generation for the temporary channel with


Change-Id: I7b0555c6909c7d322e452dde97c9ea5b111552d1

8 months agochan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up
Frederic LE FOLL [Thu, 5 Sep 2019 15:52:13 +0000 (17:52 +0200)]
chan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up

When the remote ISDN party ends an ISDN call on a PRI link
(DISCONNECT), CHANNEL(hangupsource) information is not available.

chan_dahdi already contains an ast_set_hangupsource() in
__dahdi_exception() function but it seems that ISDN message processing
does not use this part of code.

Two other channel modules associate ast_queue_hangup() and
ast_set_hangupsource() functions calls:
- chan_pjsip in chan_pjsip_session_end() function,
- chan_sip in sip_queue_hangup_cause() function.
chan_iax2 separates them, in iax2_queue_hangup()/iax2_destroy() and

Thus, I propose to add ast_set_hangupsource() beside
ast_queue_hangup() in sig_pri_queue_hangup(), like chan_pjsip and
chan_sip already do.


Change-Id: I0f588a4bcf15ccd0648fd69830d1b801c3f21b7c

8 months agoARI: External Media
George Joseph [Mon, 5 Aug 2019 11:59:59 +0000 (05:59 -0600)]
ARI: External Media

The Channel resource has a new sub-resource "externalMedia".
This allows an application to create a channel for the sole purpose
of exchanging media with an external server.  Once created, this
channel could be placed into a bridge with existing channels to
allow the external server to inject audio into the bridge or
receive audio from the bridge.
for more information.

Change-Id: I9618899198880b4c650354581b50c0401b58bc46

8 months agoMerge "chan_unistim: Fix clang warning: variable sized type not at end of a struct"
George Joseph [Tue, 10 Sep 2019 13:41:57 +0000 (08:41 -0500)]
Merge "chan_unistim: Fix clang warning: variable sized type not at end of a struct"

8 months agoMerge "test_utils.c: Skip test adsi_loaded_test if module not loaded."
Friendly Automation [Tue, 10 Sep 2019 13:28:21 +0000 (08:28 -0500)]
Merge "test_utils.c: Skip test adsi_loaded_test if module not loaded."

8 months agochan_sip: Update links referenced in deprecation notice
George Joseph [Tue, 10 Sep 2019 12:32:49 +0000 (06:32 -0600)]
chan_sip:  Update links referenced in deprecation notice

The links in the deprecation notice were the shortened
variety but it makes better sense to show the unshortened
links as they're more descriptive.

rather than

Change-Id: If2da5d5243e2d4a6f193b15691d23e7e5a7c57a9