Commit Graph

5444 Commits

Author SHA1 Message Date
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
zuul e3e08e1131 Merge "Fix naming mismatch of allocator functions." 2016-08-26 12:55:19 -05:00
Alexander Traud 858fa5eb2c channel: No hung-up on failing security requirements.
In your Diaplan, if you specify
 same => n,Set(CHANNEL(secure_bridge_media)=1)
 same => n,Set(CHANNEL(secure_bridge_signaling)=1)
only the SIP channel driver chan_sip supports this. All other channels drivers
like res_pjsip fail. In case of failure, the original sRTP source code released
the whole channel, even if not hung-up, yet. This change does not release the
channel but instead hangs-up the channel.

ASTERISK-26306

Change-Id: I0489f0cb660fab6673b0db8af027d116e70a66db
2016-08-26 16:37:46 +02:00
Richard Mudgett 5744f434f0 ast_framehook_attach() must be called with the channel locked.
The framehook container could become corrupted if the channel lock is not
held before calling.

Change-Id: I1a6b957a1f7b899eb29a186915f8cccab886a438
2016-08-25 17:11:50 -05:00
Alexander Traud 2e79f52d71 codecs: Add Codec 2 mode 2400.
ASTERISK-26217 #close

Change-Id: I1e45d8084683fab5f2b272bf35f4a149cea8b8d6
2016-08-24 10:41:58 +02:00
Corey Farrell 55ccdf93c3 Fix checks for allocation debugging.
MALLOC_DEBUG should not be used to check if debugging is actually
enabled, __AST_DEBUG_MALLOC should be used instead.  MALLOC_DEBUG only
indicates that debugging is requested, __AST_DEBUG_MALLOC indicates it
is active.

Change-Id: I3ce9cdb6ec91b74ee1302941328462231be1ea53
2016-08-19 20:16:36 -04:00
Corey Farrell 8061d9f66f Fix naming mismatch of allocator functions.
Allocator functions that take file/line/func parameters are prefixed
with single-underscore when MALLOC_DEBUG is not defined,
double-underscore when it is defined.  This change updates all
allocators that accept file/line/func to have the same prototype in
either ABI mode.  The parameter order of __ast_vasprintf and
__ast_asprintf in utils.h have been changed to match that of astmm.h.

End-use allocator macro's have been removed from astmm.h and moved to an
unconditional part of utils.h.

Change-Id: I823bb6ce2b5675b3a4735948f10a3b420e9a023a
2016-08-19 20:16:36 -04:00
Torrey Searle c1b6a79686 res_ari: Add http prefix to generated docs
updated the uri handler to include the url prefix of the http server
this enables res_ari to add it to the uris when generating docs

Change-Id: I279335a2625261a8492206c37219698f42591c2e
(cherry picked from commit 6f448f32fe)
2016-08-19 16:58:55 -05:00
zuul b35779c6c6 Merge "translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs." 2016-08-16 17:29:58 -05:00
Corey Farrell 824a4e84d1 Refactor usage pattern of xmldoc info tag.
This updates func_channel.c and main/message.c to use a generic xpointer
include instead of including info from each channel driver.  Now the
name attribute of info is CHANNEL or CHANNEL_EXAMPLES to be included in
documentation for func_channel.  Setting the name attribute of info to
MessageToInfo or MessageFromInfo causes it to be included in the
MessageSend application and AMI action.

Change-Id: I89fd8276a3250824241a618009714267d3a8d1ea
2016-08-16 10:42:46 -05:00
zuul 9fc83f8ffd Merge "core: Entity ID is not set or invalid" 2016-08-16 10:03:20 -05:00
Joshua Colp 8c8fe59f54 Merge "sorcery.c: Minor optimizations." 2016-08-16 08:24:31 -05:00
Joshua Colp 515a598b62 Merge "sorcery.c: Tweak some container declaration formatting." 2016-08-16 08:24:19 -05:00
Joshua Colp 4c9868624e Merge "manager: Add <see-also> tags to relate AoC events and actions" 2016-08-16 05:34:33 -05:00
Joshua Colp 2947127313 Merge "pbx.c: Additional fixes to ast_context_remove_extension_callerid2." 2016-08-16 05:32:30 -05:00