Commit Graph

6337 Commits

Author SHA1 Message Date
Joshua Colp b7af9c8b19 Merge "stasis: Remove stringfields and lock from change message." 2018-11-20 05:06:01 -06:00
Joshua Colp 614c8a60d7 Merge "stasis: Add internal filtering of messages." 2018-11-19 08:36:50 -06:00
George Joseph ece5f8015f backtrace: Refactor ast_bt_get_symbols so it doesn't crash
We've been seeing crashes in libbfd when we attempt to generate
a stack trace from multiple threads.  It turns out that libbfd
is NOT thread-safe.  It can cache the bfd structure and give it to
multiple threads without protecting itself.  To get around this,
we've added a global mutex around the bfd functions and also have
refactored the use of those functions to be more efficient and
to provide more information about inlined functions.

Also added a few more tests to test_pbx.c.  One just calls
ast_assert() and the other calls ast_log_backtrace().  Neither are
run by default.

WARNING:  This change necessitated changing the return value of
ast_bt_get_symbols() from an array of strings to a VECTOR of
strings.  However, the use of this function outside Asterisk is not
likely.

ASTERISK-28140

Change-Id: I79d02862ddaa2423a0809caa4b3b85c128131621
2018-11-19 05:49:39 -07:00
Joshua C. Colp 56eb18f395 stasis: Remove stringfields and lock from change message.
When a subscribe or unsubscribe occurs a message is published
containing this information. This change makes it so that the
message no longer uses stringfields or a lock, as both are not
really needed for the message.

Change-Id: I3f4831931d79f94fd979baf48048738df5dc1632
2018-11-18 19:53:14 -04:00
Joshua Colp 3077ad0c24 stasis: Add internal filtering of messages.
This change adds the ability for subscriptions to indicate
which message types they are interested in accepting. By
doing so the filtering is done before being dispatched
to the subscriber, reducing the amount of work that has
to be done.

This is optional and if a subscriber does not add
message types they wish to accept and set the subscription
to selective filtering the previous behavior is preserved
and they receive all messages.

There is also the ability to explicitly force the reception
of all messages for cases such as AMI or ARI where a large
number of messages are expected that are then generically
converted into a different format.

ASTERISK-28103

Change-Id: I99bee23895baa0a117985d51683f7963b77aa190
2018-11-18 15:08:16 -05:00
George Joseph fe64ca0be8 Merge "taskprocessor: Prevent race creating new taskprocessor." 2018-11-17 17:28:41 -06:00
Corey Farrell 9abd5e1004
taskprocessor: Prevent race creating new taskprocessor.
Task processors are retrieved using a 'get or create' pattern.  The
singleton container was unlocked between the get and create steps so
it's possible that two threads could create task processors with the
same name at the same time.

Change-Id: Id64fae94a6a1e940ddf38fde622dcd4391635382
2018-11-16 08:55:31 -05:00
Corey Farrell c3d7b19cdd core: Fix handling of restart from remote console.
We cannot use need_el_end and SIGURG when restarting.  Instead we need
to run el_end within the SIGHUP restartnow handler.

ASTERISK-28158

Change-Id: Ia852276363c81bdcf1aa29eb4558c5c2fa1218a0
2018-11-15 06:34:19 -05:00
George Joseph eb5b83b8ea AST-2018-010: Fix length of buffer needed for SRV and NAPTR results
When dn_expand was being called on SRV and NAPTR results, the
return value was being used to calculate the size of the buffer
needed to store the host names.  Since dn_expand returns the
length of the COMPRESSED name the buffer could be too short
to hold the EXPANDED name.  The expanded name is NULL terminated
so using strlen() is the correct way to determine the length
actually needed for the buffer.

ASTERISK-28127
Reported by: Jan Hoffmann

patches:
  patch.diff submitted by janhoffmann (license 6986)

Change-Id: I4d35d6c431c6c6836cb61d37b1378cc47f0b414d
2018-11-14 09:25:32 -05:00
Joshua Colp 9e151413db Merge "core: Ensure that el_end is always run when needed." 2018-11-14 07:06:38 -06:00
Corey Farrell 944d90a7ea taskprocessor: Do not use separate allocation for stats or name.
Merge storage for the stats object and name string into the main
allocation for struct ast_taskprocessor.

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

ASTERISK-28158

Change-Id: I9e23b31d4211417ddc88c6bbfd83ea4c9f3e5438
2018-11-11 09:23:15 -05:00
Joshua Colp e7b22ee133 Merge "bridge_softmix: Add SDP "label" attribute to streams" 2018-10-25 07:45:23 -05:00
George Joseph 07c950b2dd Merge "say: Remove legacy language deprecation logic" 2018-10-25 07:38:09 -05:00
Richard Mudgett 1b397ebd00 logger.c: Fix default console logging when no logger.conf available.
Default logging was not setup correctly when there was no logger.conf.
This resulted in many expected log messages not actually getting out to
the console.

Change-Id: I542e61c03b2f630ff5327f9de5641d776c6fa70c
2018-10-24 17:18:34 -05:00
George Joseph 8d1c6bb6e6 bridge_softmix: Add SDP "label" attribute to streams
Adding the "label" attribute used for participant info correlation
was previously done in app_confbridge but it wasn't working
correctly because it didn't have knowledge about which video
streams belonged to which channel.  Only bridge_softmix has that
data so now it's set when the bridge topology is changed.

ASTERISK-28107

Change-Id: Ieddeca5799d710cad083af3fcc3e677fa2a2a499
2018-10-24 08:41:23 -05:00
George Joseph a99d48d3f3 Merge "astobj2: Eliminate legacy container allocation macros." 2018-10-24 08:30:08 -05:00
George Joseph 11b73a75c8 Merge "lock: Replace __ast_mutex_logger with private log_mutex_error." 2018-10-24 07:46:11 -05:00
Sean Bright f940b7b63d say: Remove legacy language deprecation logic
These language codes (tw, ge, mx, and cz) were deprecated in 1.6.2.

Change-Id: I18e4d2af2e83556fa91e39a7338030583ef05d50
2018-10-23 08:43:41 -04:00
Richard Mudgett 544ef21bfe Merge "Fix 'statement' typo throughout code." 2018-10-22 10:25:32 -05:00
Richard Mudgett d1b9a3fbcc Merge "options.c: Remove 'internal_timing' notice" 2018-10-22 10:23:45 -05:00
Corey Farrell 687ab7aeee
astobj2: Eliminate legacy container allocation macros.
These macros have been documented as legacy for a long time but are
still used in new code because they exist.  Remove all references to:
* ao2_container_alloc_options
* ao2_t_container_alloc_options
* ao2_t_container_alloc

These macro's are also removed.  Only ao2_container_alloc remains due to
it's use in over 100 places.

Change-Id: I1a26258b5bf3deb081aaeed11a0baa175c933c7a
2018-10-19 17:33:05 -04:00
Corey Farrell 4c19b94968
lock: Replace __ast_mutex_logger with private log_mutex_error.
__ast_mutex_logger used the variable `canlog` without accepting it as a
argument.  Replace with internal macro `log_mutex_error` which takes
canlog as the first arguement.  This will prevent confusion when working
with lock.c code, many of the function declare the canlog variable and
in some cases it previously appeared to be unused.

Change-Id: I83b372cb0654c5c18eadc512f65a57fa6c2e9853
2018-10-19 12:34:08 -04:00
Sean Bright be04a64c49 options.c: Remove 'internal_timing' notice
Change-Id: I9882394617724a497df1d6f529a87965191be3ce
2018-10-18 15:18:36 -04:00
Richard Mudgett 467f7c6724 Fix 'statement' typo throughout code.
Most were in comments.  A couple were in warning messages.

Pointed out by Jonathan H on the Asterisk users mailing list.

Change-Id: I6286939dff5d0a27a2758140570106f1cb351855
2018-10-18 12:44:10 -05:00
Corey Farrell 5ab94d2a3e
taskprocessor: Warn on unused result from pushing task.
Add attribute_warn_unused_result to ast_taskprocessor_push,
ast_taskprocessor_push_local and ast_threadpool_push.  This will help
ensure we perform the necessary cleanup upon failure.

Change-Id: I7e4079bd7b21cfe52fb431ea79e41314520c3f6d
2018-10-17 09:14:05 -04:00
George Joseph e349bf40ca Merge "refdebug: Create refstats.py script." 2018-10-16 13:43:07 -05:00
George Joseph 430f97f5e7 Merge "threadpool: Eliminate pointless AO2 usage." 2018-10-16 10:15:28 -05:00
Corey Farrell 79677ead28 refdebug: Create refstats.py script.
This allows us to process AO2 statistics for total objects, memory
usage, memory overhead and lock usage.

* Install refstats.py and reflocks.py into the Asterisk scripts folder.
* Enable support for reflocks.py without DEBUG_THREADS.

Steal a bit from the ao2 magic to flag when an object lock is used.
Remove 'lockobj' from reflocks.py since we can now record 'used' or
'unused' for those objects.

Add comments to explain thread safety of the 'struct __priv_data'
bitfields.

Change-Id: I84e9d679cc86d772cc97c888d9d856a17e0d3a4a
2018-10-15 15:35:35 -05:00
Corey Farrell f06de6900e threadpool: Eliminate pointless AO2 usage.
thread_worker_pair, set_size_data and task_pushed_data structures are
allocated with AO2 objects, passed to a taskprocessor, then released.
They never have multiple owners or use locking so AO2 only adds
overhead.

Change-Id: I2204d2615d9d952670fcb48e0a9c0dd1a6ba5036
2018-10-13 06:22:19 -05:00
Corey Farrell 675d8a46b4 main/astfd: Fix GCC8 format-truncation warning.
The field used to store call arguments was not large enough to hold the
arguments string that can be constructed for 'open'.  Expand it to
prevent this warning/error.

Change-Id: I514927f256481bc84df10a51b19d5b5fb1bc387e
2018-10-12 12:21:47 -05:00
Jenkins2 265d91a120 Merge "loader: Flag module as declined in all cases where it fails to load." 2018-10-10 12:26:58 -05:00
neutrino88 17f4e6ad4d core/frame: generate correct T.140 payload in ast_sendtext_data()
ast_sendtext_data() would create an incorrect T.140 text frame which
length include the null terminator byte. It causes ultimately RTP
packets to be send with this trailing 0. The proposed fix just set the
correct length to the text frame

ASTERISK-28089
Reported by: Emmanuel BUU
Tested by: Emmanuel BUU

Change-Id: I7ab1b9ed1e21683b2b667ea0a59d9aba3c77dd96
2018-10-05 08:57:53 -05:00
Corey Farrell c8ee1a183f
loader: Flag module as declined in all cases where it fails to load.
This has no effect on startup since AST_MODULE_LOAD_FAILURE aborts
startup, but it's possible for this code to be returned on manual load
of a module after startup.

It is an error for a module to not have a load callback but this is not
a fatal system error.  In this case flag the module as declined, return
AST_MODULE_LOAD_FAILURE only if a required module is broken.

Expand doxygen documentation for AST_MODULE_LOAD_*.

Change-Id: I3c030bb917f6e5a0dfd9d91491a4661b348cabf8
2018-10-04 19:40:47 -04:00
George Joseph 45eb9a28eb Merge "astobj2: Comment on OBJ_NOLOCK in ao2_container_clone." 2018-10-04 07:25:47 -05:00
George Joseph f55e20ae83 Merge "http.c: Reload TLS even if http.conf hasn't changed" 2018-10-04 07:23:49 -05:00
George Joseph 967fffb569 Merge "core/frame: Fix ast_frdup() and ast_frisolate() for empty text frames" 2018-10-03 13:55:24 -05:00
Corey Farrell 932d0a40cf astobj2: Comment on OBJ_NOLOCK in ao2_container_clone.
The test for OBJ_NOLOCK looks wrong but it isn't.  Add comments to
prevent confusion.

Change-Id: I9662b82eb39e7627a1f1944fd18f967a2b987344
2018-10-03 11:03:48 -05:00
George Joseph bc9a7c419c Merge "astobj2: Record lock usage to refs log when DEBUG_THREADS is enabled." 2018-10-03 10:17:27 -05:00
George Joseph 24dc6ee8ae Merge "loader: Fix result of module reload error." 2018-10-03 10:17:07 -05:00
George Joseph 910f5dbd44 Merge "core: Disable astobj2 locking for some common objects." 2018-10-03 10:16:20 -05:00
Sean Bright 286339aa34 http.c: Reload TLS even if http.conf hasn't changed
There is currently no way to indicate to Asterisk that TLS certificates
and/or keys have been updated other than by modifying http.conf or
restarting Asterisk.

There is already code in main/tcptls.c that determines if a reload is
actually necessary based on the hashes of the certicate and dependent
files, so this change merely gives us a way to request a reload without
explicitly modifying http.conf.

Change-Id: Ie795420dcc7eb3d91336820688a29adbcc321276
2018-10-03 08:35:12 -05:00
Corey Farrell cacbe32534
core: Disable astobj2 locking for some common objects.
* ACO options
* Indications
* Module loader ref_debug object
* Media index info and variants
* xmldoc items

These allocation locations were identified using reflocks.py on the
master branch.

Change-Id: Ie999b9941760be3d1946cdb6e30cb85fd97504d8
2018-10-02 16:47:23 -04:00
Corey Farrell b25a261aa5
loader: Fix result of module reload error.
When a module reload fails we never set AST_MODULE_RELOAD_ERROR.  This
caused reload failures to incorrectly report 'No module found'.

Change-Id: I5f3953e0f7d135e53ec797f24c97ee3f73f232e7
2018-10-02 14:12:58 -04:00
Corey Farrell e4cf513f81
loader: Improve error handling.
* Display list of unavailable dependencies when they cause another
  module to fail loading.
* When a module declines to load find all modules which depend on it so
  they can be declined and listed together.
* Prevent retry of declined modules during startup.
* When a module fails to dlopen try loading it with RTLD_LAZY so we can
  attempt to display the list of missing dependencies.

These changes are meant to reduce logger spam that is caused when a
module has many dependencies and declines to load.  This also fixes some
error paths which failed to recognize required modules.

Module load/start errors are delayed until the end of loader startup.

Change-Id: I046052c71331c556c09d39f47a3b92975f3e1758
2018-10-02 13:18:12 -04:00
neutrino88 24cece660b core/frame: Fix ast_frdup() and ast_frisolate() for empty text frames
If a channel creates an AST_TEXT_FRAME with datalen == 0, the ast_frdup()
and ast_frisolate() functions could create a clone frame with an invalid
data.ptr which would cause a crash.  The proposed fix is to make sure that
for such empty text frames, ast_frdup() and ast_frisolate() return cloned
text frames with a valid data.ptr.

ASTERISK-28076
Reported by: Emmanuel BUU
Tested by: Emmanuel BUU

Change-Id: Ib882dd028598f13c4c233edbfdd7e54ad44a68e9
2018-10-02 11:25:25 -05:00
Corey Farrell 13df745278
astobj2: Record lock usage to refs log when DEBUG_THREADS is enabled.
When DEBUG_THREADS is enabled we can know if the astobj2 mutex / rwlock
was ever used, so it can be recorded in the REF_DEBUG destructor entry.

Create contrib/scripts/reflocks.py to process locking used by
allocator.  This can be used to identify places where
AO2_ALLOC_OPT_LOCK_NOLOCK should be used to reduce memory usage.

Change-Id: I2e3cd23336a97df2692b545f548fd79b14b53bf4
2018-10-01 22:27:30 -04:00
Jenkins2 252e4a8fd4 Merge "astobj2: Reduce memory overhead." 2018-10-01 09:02:37 -05:00
Joshua Colp 69f4740fa1 Merge "lock: Improve performance of DEBUG_THREADS." 2018-10-01 08:32:49 -05:00
Corey Farrell 205c6be895
lock: Improve performance of DEBUG_THREADS.
Add a volatile flag to lock tracking structures so we only need to use
the global lock when first initializing tracking.

Additionally add support for DEBUG_THREADS_LOOSE_ABI.  This is used by
astobj2.c to eliminate storage for tracking fields when DEBUG_THREADS is
not defined.

Change-Id: Iabd650908901843e9fff47ef1c539f0e1b8cb13b
2018-09-28 14:42:04 -04:00