George Joseph [Thu, 8 Nov 2018 15:53:44 +0000 (08:53 -0700)]
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.
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.
George Joseph [Sat, 17 Nov 2018 19:07:32 +0000 (12:07 -0700)]
CI: Pass work directory to runTestsuite
The testsuite can now use a user-specified work directory for
all it's temp files. This allows the docker containers to use
a tmpfs backed directory for the temp files instead of it's
own write-layer image.
* runTestsuite.sh now accepts a --work-dir command line argument
that gets exported as AST_WORK_DIR before running the testsuite.
* gates.jenkinsfile now specifies --work-dir to be
<testsuite_dir>/astroot.
Since the Asterisk CI docker hosts now mount /srv/jenkins/workspace
on a tmpfs, asterisk should be compiled and the testsuite run all in
memory.
George Joseph [Thu, 15 Nov 2018 17:41:44 +0000 (10:41 -0700)]
CI: Allow runUnittests to use 'expect' to run the tests
There seems to be a race condition between starting the asterisk
daemon and attempting to use 'asterisk -r' that can cause the
control socket file to not be created. Since all of the Jenkins
slaves have 'expect' installed, the runUnittests script can use
it to start asterisk in the forground and issue the commands
interactively. This is much more reliable and it can also make
startup errors more visible since they'll be in the Jenkins console
output.
If 'expect' isn't installed, the original daemon/asterisk -r
process is used.
Also added a "core show settings" before running the tests
and added "notice,warning,error" to the console log.
Corey Farrell [Mon, 12 Nov 2018 18:23:34 +0000 (13:23 -0500)]
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.
Corey Farrell [Fri, 16 Nov 2018 12:20:11 +0000 (07:20 -0500)]
pjproject-bundled: Use AST_DEVMODE for conditional compilation.
We previously allowed resample and g711 codecs to be built when
TEST_FRAMEWORK was enabled. This could cause errors if the testsuite
was run without this option enabled. Switch the build system to allow
those codecs to be built when --enable-dev-mode is used. This removes a
chance for strange testsuite errors from use of an inadequate pjsua
binary.
Torrey Searle [Wed, 24 Oct 2018 12:38:37 +0000 (14:38 +0200)]
res/res_pjsip_nat: Fix logic for REINVITES
The presence of Record-Route in re-invites is optional, thus it is
important to make sure the dialog doesn't have a routset before
rewriting the contact header.
Corey Farrell [Fri, 2 Nov 2018 11:38:19 +0000 (07:38 -0400)]
pbx_config: Only the first [globals] section is seen.
If multiple [globals] sections are used (for example via separate
included files), only the first one is processed. This can result in
lost global variables when using a modular extensions.conf.
res_pjsip: Send a 503 response when overload state if reliable transport.
When Asterisk's taskprocessors get overloaded we need to reduce the work
load. res_pjsip currently ignores new SIP requests and relies on SIP
retransmissions in the hope that the overload condition will clear soon
enough to handle the retransmitted SIP request.
This change adds the following code after ast_taskprocessor_alert_get()
has returned TRUE:
1- identifies transport type. If non-udp then send a 503 response
2- if transport type is udp/udp6 then ignore, as before.
Kevin Harwell [Tue, 6 Nov 2018 22:35:30 +0000 (16:35 -0600)]
res_pjsip: formatting error in documentation
The use of a '|' in the "global/debug" synopsis documentation caused the
generated html table on the wiki to add an extra column that included the
text after the pipe.
res_pjsip.c: Make taskprocessor scheduling algorithm pick the shortest queue
The current round-robin method does not take the current taskprocessor
load into consideration when distributing requests. Using the least-size
method the request goes to the taskprocessor that is servicing the least
number of active tasks at the current time.
Longer running tasks with the round-robin method can delay processing
tasks.
* Change the algorithm from round-robin to least-size for picking the
PJSIP taskprocessor from the default serializer pool.
Joshua Colp [Mon, 5 Nov 2018 14:30:54 +0000 (14:30 +0000)]
stasis: Clarify lifetime of topics.
As mentioned in the comment I've added in the code there is no
ability to unsubscribe all subscribers from a topic and explicitly
destroy it. This is not currently a problem as we have two types of
topics:
Long lived topics which exist for the lifetime of the system.
Ephemeral topics which feed a long lived topic.
In the case of the ephemeral topics there is no subscriber which does
not have its lifetime managed by the same entity that has created
the topic. This ensures that when the topic is being unreferenced the
subscribers are also unsubscribed and destroyed, allowing the topic
to ultimately be destroyed as well.
contrib/sip_to_pjsip: add a --quiet option to avoid prints
Using the --quiet or -q option in conjonction with /dev/stdout as the output
file allow the output to be used as a valid configuration.
Given a script that generates a valid sip.conf I can pipe the output of that
script into `sip_to_pjsip.py -q /dev/stdin /dev/stdout`. This allow me to use
that piped command in my pjsip.conf using the `exec` command.
Torrey Searle [Tue, 2 Oct 2018 12:31:43 +0000 (14:31 +0200)]
res_pjsip_session: add new flag use_callerid_contact
Add a new global flag to res_pjsip to allow the callerid to be used
as the username in the contact header. This allows chan_pjsip to have
the same behavour as chan_sip
Richard Mudgett [Thu, 18 Oct 2018 00:34:37 +0000 (19:34 -0500)]
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.
Corey Farrell [Tue, 16 Oct 2018 19:00:27 +0000 (15:00 -0400)]
astobj2: Eliminate usage of 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 still available for use but only in modules. Only
ao2_container_alloc remains due to it's use in over 100 places.
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.
Corey Farrell [Sun, 14 Oct 2018 12:58:59 +0000 (08:58 -0400)]
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.
This patch is not in the upstream pjproject and does unsafe things with
the timer->_timer_id and timer->_grp_lock values in pj_timer_entry_reset()
outside of the timer heap lock. pj_timer_entry_reset() is also called for
timers that are not about to be rescheduled in a few places.
Corey Farrell [Thu, 11 Oct 2018 11:24:40 +0000 (07:24 -0400)]
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.
Alexei Gradinari [Fri, 12 Oct 2018 17:14:03 +0000 (13:14 -0400)]
res_pjsip: set callerid_tag to empty string
This patch sets the callerid_tag to empty string by default.
If the callerid_tag is set to NULL then the tag does not
become part of a connected line update.
For example:
Alice's tag is "Alice".
Bob's tag is empty.
Charlie's tag is "Charlie".
Alice calls Bob and then does attended transfer to Charlie.
When Alice hangs up the CONNECTEDLINE(tag) is "Alice"
on the interception routine on the Charlie's channel, but should be empty.
Ths patch also fix memory leaks if there are more then one options
"callerid", "callerid_tag", "voicemail_extension" and "contact_user"
in the pjsip.conf endpoint definition.
Corey Farrell [Fri, 12 Oct 2018 17:16:29 +0000 (13:16 -0400)]
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.
Corey Farrell [Wed, 10 Oct 2018 07:54:08 +0000 (03:54 -0400)]
CI: Disable binary modules when REF_DEBUG is enabled.
In Asterisk 13 binary modules are linked to the non-REF_DEBUG variants
of ao2 functions. Cause false leaks to be reported when binary modules
are used.
Richard Mudgett [Tue, 9 Oct 2018 21:18:49 +0000 (16:18 -0500)]
res_statsd.c: Fix returned reload status.
The return status when there was no change in statsd.conf was incorrect.
This resulted in the wrong status message on the CLI when reloading the
module.
* Fixed cleanup on initial load if initializing statsd failed.
neutrino88 [Wed, 3 Oct 2018 21:51:49 +0000 (17:51 -0400)]
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