Commit Graph

5458 Commits

Author SHA1 Message Date
zuul 6f49ca5927 Merge "Audit ast_json_pack() calls for needed UTF-8 checks." 2016-10-14 17:17:14 -05:00
zuul 9581407fd2 Merge "json: Check party id name, number, subaddresses for UTF-8." 2016-10-14 16:32:18 -05:00
zuul 5b70ae04d4 Merge "json: Add UTF-8 check call." 2016-10-14 14:40:34 -05:00
Richard Mudgett 9c49b96374 Audit ast_json_pack() calls for needed UTF-8 checks.
Added needed UTF-8 checks before constructing json objects in various
files for strings obtained outside the system.  In this case string values
from a channel driver's peer and not from the user setting channel
variables.

* aoc.c: Fixed type mismatch in s_to_json() for time and granularity json
object construction.

ASTERISK-26466
Reported by: Richard Mudgett

Change-Id: Iac2d867fa598daba5c5dbc619b5464625a7f2096
2016-10-13 18:13:00 -05:00
Richard Mudgett 774d5f7ef7 json: Check party id name, number, subaddresses for UTF-8.
* Updated unit test as ast_json_name_number() is now NULL tolerant.

ASTERISK-26466 #close
Reported by: Richard Mudgett

Change-Id: I7d4e14194f8f81f24a1dc34d1b8602c0950265a6
2016-10-13 18:12:59 -05:00
Richard Mudgett 1c4c6c082d json: Add UTF-8 check call.
Since the json library does not make the check function public we
recreate/copy the function in our interface module.

ASTERISK-26466
Reported by: Richard Mudgett

Change-Id: I36d3d750b6f5f1a110bc69ea92b435ecdeeb2a99
2016-10-13 18:12:59 -05:00
Richard Mudgett 6fe5202c2c aoc.c: Whitespace cleanup
* In s_to_json() removed unnecessary ast_json_ref() to ast_json_null()
when creating the type json object.  The ref is a noop.

Change-Id: I2be8b836876fc2e34a27c161f8b1c53b58a3889a
2016-10-13 15:59:54 -05:00
zuul 8b58db0962 Merge "Binaural synthesis (confbridge): interleaved two-channel audio." 2016-10-12 11:36:06 -05:00
zuul f866201598 Merge "audiohooks: Remove redundant codec translations when using audiohooks" 2016-10-11 17:45:56 -05:00
Corey Farrell fafdde322c logger: Prevent output of verbose messages initiated from rasterisk.
Remote asterisk consoles should only display verbose log messages
created by the daemon.  The first patch for ASTERISK-26410 caused
a couple verbose messages to be printed when the rasterisk process
ended.

ASTERISK-26410

Change-Id: Ie2a1bb3753ad2724c0349ec1a336f52f7117b52a
2016-10-10 16:54:51 -05:00
Michael Walton 7af7490e42 audiohooks: Remove redundant codec translations when using audiohooks
The main frame read and write handlers in main/channel.c don't use the
optimum placement in the processing flow for calling audiohooks
callbacks, as far as codec translation is concerned. This change places
the audiohooks callback code:
 * After the channel read translation if the frame is not linear before
the translation, thereby increasing the chance that the frame is linear
as required by audiohooks
 * Before the channel write translation if the frame is linear at this
point
This prevents the audiohooks code from instantiating additional
translation paths to/from linear where a linear frame format is already
available, saving valuable CPU cycles

ASTERISK-26419

Change-Id: I6edd5771f0740e758e7eb42558b953f046c01f8f
2016-10-10 11:41:42 -05:00
Joshua Colp 73f75c246b Revert "Packet-Loss Concealment (PLC) for supporting codecs."
This change introduced some fax test failures
that have not yet been addressed. So this is
not forgotten I'm submitting a change which
reverts it.

This reverts:
d56fc3b36b.

ASTERISK-25629

Change-Id: Ibc2f23c38643f5a2c89cf8915ae2d805b81bc3d5
2016-10-09 23:55:28 +00:00
frahaase c455823657 Binaural synthesis (confbridge): interleaved two-channel audio.
Asterisk only supports mono audio at the moment.
This patch adds interleaved two-channel audio to Asterisk's channels.

ASTERISK-26292

Change-Id: I7a547cea0fd3c6d1e502709d9e7e39605035757a
2016-10-03 03:12:50 -05:00
Corey Farrell 2a03575c30 astobj2: Add backtrace to log_bad_ao2.
* Compile __ast_assert_failed unconditionally.
* Use __ast_assert_failed to log messages from log_bad_ao2
* Remove calls to ast_assert(0) that happen after log_bad_ao2 was run.

Change-Id: I48f1af44b2718ad74a421ff75cb6397b924a9751
2016-09-30 19:25:40 -04:00
Corey Farrell 8c5c95ad89 core: Remove ABI effects of LOW_MEMORY.
This allows asterisk to compiled with LOW_MEMORY to load modules built
without LOW_MEMORY.

ASTERISK-26398 #close

Change-Id: I24b78ac9493ab933b11087a8b6794f3c96d4872d
2016-09-29 03:22:28 -04:00
Corey Farrell 2d2a8944be logger: Output early verbose messages to console.
Verbose messages should be printed to the console if the sublevel is
less than option_verbose.  This fix ensures the welcome message with
copyright and license are printed at daemon and interactive rasterisk
startup.

ASTERISK-26410 #close

Change-Id: Ia44235e30ec328aba92ea2c8a837b094e65c9a03
2016-09-27 15:50:46 -05:00
George Joseph d425971009 chan_sip: Address runaway when realtime peers subscribe to mailboxes
Users upgrading from asterisk 13.5 to a later version and who use
realtime with peers that have mailboxes were experiencing runaway
situations that manifested as a continuous stream of taskprocessor
congestion errors, memory leaks and an unresponsive chan_sip.

A related issue was that setting rtcachefriends=no NEVER worked in
asterisk 13 (since the move to stasis).  In 13.5 and earlier, when a
peer tried to register, all of the stasis threads would block and
chan_sip would again become unresponsive.  After 13.5, the runaway
would happen.

There were a number of causes...
* mwi_event_cb was (indirectly) calling build_peer even though calls to
  mwi_event_cb are often caused by build_peer.
* In an effort to prevent chan_sip from being unloaded while messages
  were still in flight, destroy_mailboxes was calling
  stasis_unsubscribe_and_join but in some cases waited forever for the
  final message.
* add_peer_mailboxes wasn't properly marking the existing mailboxes
  on a peer as "keep" so build_peer would always delete them all.
* add_peer_mwi_subs was unsubscribing existing mailbox subscriptions
  then just creating them again.

All of this was causing a flood of subscribes and unsubscribes on
multiple threads all for the same peer and mailbox.

Fixes...
* add_peer_mailboxes now marks mailboxes correctly and build_peer only
  deletes the ones that really are no longer needed by the peer.
* add_peer_mwi_subs now only adds subscriptions marked as "new" instead
  of unsubscribing and resubscribing everything.  It also adds the peer
  object's address to the mailbox instead of its name to the subscription
  userdata so mwi_event_cb doesn't have to call build_peer.

With these changes, with rtcachefriends=yes (the most common setting),
there are no leaks, locks, loops or crashes at shutdown.

rtcachefriends=no still causes leaks but at least it doesn't lock, loop
or crash.  Since making rtcachefriends=no work wasnt in scope for this
issue, further work will have to be deferred to a separate patch.

Side fixes...
 * The ast_lock_track structure had a member named "thread" which gdb
   doesn't like since it conflicts with it's "thread" command.  That
   member was renamed to "thread_id".

ASTERISK-25468 #close

Change-Id: I07519ef7f092629e1e844f855abd279d6475cdd0
2016-09-23 07:53:31 -05:00
Joshua Colp 8d5219e6b8 Merge "core: Ensure presencestate subtype and message are NULL." 2016-09-22 08:45:38 -05:00
zuul 9ef0eb6487 Merge "logger: Simplify ast_callid handling code." 2016-09-21 15:15:14 -05:00
Joshua Colp 57b29f3b69 Merge "logger: Always enable verbose for console channel." 2016-09-21 14:35:27 -05:00
Joshua Colp a805d779e8 core: Ensure presencestate subtype and message are NULL.
When retrieving presence state information there is no
guarantee that the subtype and message passed in are
set to NULL. This change ensures they are.

ASTERISK-26397 #close

Change-Id: If38cd730e409e9a9b6eb9adef6591d15a9e61f86
2016-09-21 14:27:46 -05:00
zuul ccc0bfa69c Merge "logger: Fix default console settings." 2016-09-21 12:22:35 -05:00
zuul 4caee4a11b Merge "core: Fix LOW_MEMORY missing symbol ast_pbx_uuid_get." 2016-09-21 11:31:54 -05:00
zuul f84652bd81 Merge "asterisk.c: Non-root users also get the astcanary after core restart." 2016-09-21 07:10:09 -05:00
Corey Farrell 923edf2596 logger: Simplify ast_callid handling code.
Routines responsible for managing ast_callid's are overly complicated.
This is left-over code from when ast_callid was an AO2 object.  Now that
it is an integer the code can be reduced.

ast_callid handler code no longer prints it's own error message upon failure
to allocate threadstorage as ast_calloc would have already printed a
message.  Debug messages that were printed when TEST_FRAMEWORK was
enabled have been also been removed.

Change-Id: I65a768a78dc6cf3cfa071e97f33ce3dce280258e
2016-09-20 18:25:16 -05:00
Corey Farrell 5cb905a227 core: Fix LOW_MEMORY missing symbol ast_pbx_uuid_get.
Move the function outside the conditional block that excludes
LOW_MEMORY.

ASTERISK-26273 #close

Change-Id: Ic290fa128222c410c3531107e30efacabc8493b4
2016-09-20 15:23:25 -05:00
Corey Farrell 00f1d05d34 logger: Always enable verbose for console channel.
Previous versions of Asterisk did not require verbose to be specified in
logger.conf for the console channel, if it was requested by command line
or asterisk.conf it just worked.  This change causes Asterisk to always
enable verbose in the console channel level mask.  Verbose is displayed
on consoles if requested by command line, option_verbose or 'core set
verbose'.

This also delays initialization of the logger until after threadstorage
is initialized.  Initializing too early can cause messages to be printed
multiple times to the console (stdout).

ASTERISK-26391 #close

Change-Id: I52187d67c2fcb3efd5561bf04b3e5e23e5ee8a04
2016-09-20 13:03:40 -04:00
Corey Farrell 74f562a8e2 logger: Fix default console settings.
When logger.conf is missing or invalid we should be printing notices,
warnings and errors to the console.  The logmask was incorrectly
calculated.

Change-Id: Ibaa9465a8682854bc1a5e9ba07079bea1bfb6bb3
2016-09-20 13:03:19 -04:00
zuul ea8105cf5e Merge "sd_notify (systemd status notifications) support" 2016-09-20 11:19:02 -05:00
zuul 0caf846aff Merge "rtp: Only accept the first payload for a format in SDP." 2016-09-20 09:34:58 -05:00
zuul d36da3a26b Merge "Fix showing of swap details when sysinfo() is available" 2016-09-19 16:05:02 -05:00
Walter Doekes 0bc9912739 asterisk.c: Non-root users also get the astcanary after core restart.
Without this change, a 'core restart' would kill the astcanary forever
if you're not running as root. Both with and without this patch, the
scheduling priority was still SCHED_RR after restart.

Additionally, the astcanary is now spawned if you start with high
priority and Asterisk doesn't get a chance to lower it. For example
through: `chrt -r 10 sudo -u asterisk asterisk -c`

Also reap killed astcanary processes on core restart.

ASTERISK-26352 #close

Change-Id: Iacb49f26491a0717084ad46ed96b0bea5f627a55
2016-09-19 22:33:42 +02:00
Walter Doekes bffaf46690 asterisk.c: When astcanary dies on linux, reset priority on all threads.
Previously only the canary checking thread itself had its priority set
to SCHED_OTHER. Now all threads are traversed and adjusted.

ASTERISK-19867 #close
Reported by: Xavier Hienne

Change-Id: Ie0dd02a3ec42f66a78303e9c1aac28f7ed9aae39
2016-09-19 16:40:40 +02:00
Joshua Colp 0376af9519 rtp: Only accept the first payload for a format in SDP.
When receiving an SDP offer with multiple payloads for
the same format we would generate an answer with the first
payload, but during the payload crossover operation
(to set the payloads for receiving) we would remove all
payloads but the last. This would result in incoming
traffic being matched against the wrong format and outgoing
traffic being sent using the wrong payload.

This change makes it so that once a format has a payload
number put into the mapping all subsequent ones are ignored.
This ensures there is only ever one payload in the mapping
and that it is the payload placed into the answer SDP.

ASTERISK-26365 #close

Change-Id: I1e8150860a3518cab36d00b1fab50f9352b64e60
2016-09-15 14:27:26 -05:00
Tzafrir Cohen 07b95f7c65 sd_notify (systemd status notifications) support
sd_notify() is used to notify systemd of changes to the status of the
process. This allows the systemd daemon to know when the process
finished loading (and thus only start another program after Asterisk has
finished loading).

To use this, use a systemd unit with 'Type=notify' for Asterisk.

This commit also adds the function ast_sd_notify(), a wrapper around
sd_notify that does nothing if not built with systemd support.

Also adds support for libsystemd detection in the configure script.

Change-Id: Ied6a59dafd5ef331c5c7ae8f3ccd2dfc94be7811
2016-09-15 10:31:31 +03:00
Timo Teräs bc81765bb4 Fix showing of swap details when sysinfo() is available
If sysinfo() is available, but not sysctl() or swapctl() the
printing code for swap buffer sizes is incorrectly omitted.
The above condition happens with musl c-library.

Fix #if rule to consider defined(HAVE_SYSINFO). And also
remove the redundant || defined(HAVE_SYSCTL) which was
incorrectly there to start with. Now swap information is
displayed only if an actual libc function to get it is
available.

This also fixes warnings previously seen with musl libc:

   [CC] asterisk.c -> asterisk.o
asterisk.c: In function 'handle_show_sysinfo':
asterisk.c:773:6: warning: variable 'totalswap' set but not used
 [-Wunused-but-set-variable]
  int totalswap = 0;
      ^~~~~~~~~
asterisk.c:770:11: warning: variable 'freeswap' set but not used
 [-Wunused-but-set-variable]
  uint64_t freeswap = 0;
           ^~~~~~~~

Change-Id: I1fb21dad8f27e416c60f138c6f2bff03fb626eca
2016-09-15 08:43:58 +03:00
Joshua Colp 89764f7ae9 rtp: Preserve timestamps on video frames.
Currently when receiving video over RTP we store only
a calculated samples on the frame. When starting the video
it can take some time for this calculation to actually yield
a value as it requires constant changing timestamps. As well
if a video frame passes over multiple RTP packets this calculation
will fail as the timestamp is the same as the previous RTP
packet and the number of samples calculated will be 0.

This change preserves the timestamp on the frame and allows
it to pass through the core. When sending the video this timestamp
is used instead of a new one being calculated.

ASTERISK-26367 #close

Change-Id: Iba8179fb5c14c9443aee4baf670d2185da3ecfbd
2016-09-14 12:58:10 -05:00
zuul b5e4445b29 Merge "sorcery: Create function ast_sorcery_lockable_alloc." 2016-09-06 12:14:03 -05:00
zuul 825d6e036c Merge "named_locks: Use ao2_weakproxy to deal with cleanup from container." 2016-09-06 11:20:57 -05:00
Joshua Colp fe806ba08b Merge "format_cap.c: Fix CLI "core show channeltype Surrogate" crash." 2016-09-06 10:06:10 -05:00
zuul d57242a16b Merge "astobj2: Support using a separate object for locking." 2016-09-06 09:37:32 -05:00
Joshua Colp e34f299a96 Merge "codecs: Add Codec 2 mode 2400." 2016-09-04 14:11:34 -05:00
Richard Mudgett c3b965a2c0 format_cap.c: Fix CLI "core show channeltype Surrogate" crash.
* Make ast_format_cap_get_names() NULL tolerant.

ASTERISK-26331 #close
Reported by: CGI.NET

Change-Id: Id67e93936dc8ec2a33a9d33655843d43b59285a3
2016-09-02 12:56:21 -05:00
Corey Farrell e875e1c12a sorcery: Create function ast_sorcery_lockable_alloc.
Create an alternative to ast_sorcery_generic_alloc which uses astobj2
shared locking. Use this new method for the 'struct ast_sip_aor' allocator.

Change-Id: I3f62f2ada64b622571950278fbb6ad57395b5d6f
2016-09-02 09:26:25 -04:00
Corey Farrell 131baf70d6 named_locks: Use ao2_weakproxy to deal with cleanup from container.
This allows standard ao2 functions to be used to release references to
an ast_named_lock.  This change can cause less frequent locking of the
global named_locks container.  The container is no longer locked when a
named_lock reference is being release except when this causes the
named_lock to be destroyed.

Change-Id: I644e39c6d83a153d71b3fae77ec05599d725e7e6
2016-09-02 09:13:45 -04:00
Corey Farrell 0c5b6e9ff5 astobj2: Support using a separate object for locking.
Create ao2_alloc_with_lockobj function to support shared locking.

Change-Id: Iba687eb9843922be7e481e23a32c0700ecf88a80
2016-09-02 09:13:33 -04:00
Etienne Lessard 5e0758575c pbx.c: Prevent infinite recursion in manager_show_dialplan_helper.
Previously, if context A was including context B and context B was including
context A, i.e. if there was a circular dependency between contexts, then
calling manager_show_dialplan_helper could lead to an infinite recursion,
resulting in a crash.

This commit applies the same solution as the one implemented in the
show_dialplan_helper function. The manager_show_dialplan_helper and
show_dialplan_helper functions contain lots of code in common, but the former
was missing the "infinite recursion avoidance" code.

ASTERISK-26226 #close

Change-Id: I1aea85133c21787226f4f8442253a93000aa0897
2016-08-29 08:07:38 -04:00
zuul 4d06f4621a Merge "channel: No hung-up on failing security requirements." 2016-08-26 19:40:15 -05:00
zuul 795532b2d5 Merge "ast_framehook_attach() must be called with the channel locked." 2016-08-26 13:27:16 -05:00
zuul c82cef8441 Merge "Fix checks for allocation debugging." 2016-08-26 12:55:22 -05:00