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
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
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
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
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
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
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
* 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
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
* 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
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
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
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
Reduce options to 2-bit field, magic to 30 bit field. Move ref_counter
next to options and explicitly use int32_t so the fields will pack.
This reduces memory overhead for every ao2 object by 8 bytes on x86_64.
Change-Id: Idc1baabb35ec3b3d8de463c4fa3011eaf7fcafb5
* In main/config.c, AST_INCLUDE_GLOB is fixed to '1' making the #ifdefs
pointless.
* In utils/extconf.c, AST_INCLUDE_GLOB is never defined so there is a
lot of dead code.
Change-Id: I1bad1a46d7466ddf90d52cc724e997195495226c
When REF_DEBUG and AO2_DEBUG are both enabled we closed the refs log
before we shutdown astobj2_container. This caused the AO2_DEBUG
container registration container to be reported as a leak.
Change-Id: If9111c4c21c68064b22c546d5d7a41fac430430e
Use json_vsprintf from versions which contain fix for va_copy leak.
Apply fixes from jansson master:
* va_copy leak fix.
* Avoid potential invalid memory read in json_pack.
* Rename variable that shadowed another.
Change-Id: I7522e462d2a52f53010ffa1e7d705c666ec35539
* Use "o*" format specifier for optional fields in ast_json_party_id.
* Stop using ast_json_deep_copy on immutable objects, it is now thread
safe to just use ast_json_ref.
Additional changes to ast_json_pack calls in the vicinity:
* Use "O" when an object needs to be bumped. This was previously
avoided as it was not thread safe.
* Use "o?" and "O?" to replace NULL with ast_json_null(). The
"?" is a new feature of ast_json_pack starting with Asterisk 16.
Change-Id: I8382d28d7d83ee0ce13334e51ae45dbc0bdaef48
app_voicemail wasn't properly cleaning up the stasis cache or the
mwi topic pool when the module was unloaded or when a user was
deleted as a result of a reload. This resulted in leaks in both
areas.
* app_voicemail now calls ast_delete_mwi_state_full when it frees
a user structure and ast_delete_mwi_state_full in turn now calls
the new stasis_topic_pool_delete_topic function to clear the topic
from the pool.
Change-Id: Ide23144a4a810e7e0faad5a8e988d15947965df8
When writing an RTCP report to json the code attempts to pack the "ssrc" and
"source_ssrc" unsigned integer values as a signed int value type. This of course
means if the ssrc's unsigned value is greater than that which can fit into a
signed integer value it gets converted to a negative number. Subsequently, the
negative value goes out in the json report.
This patch now packs the value as a json_int_t, which is the widest integer type
available on a given system. This should make it so the value no longer
overflows.
Note, this was caught by two failing tests hep/rtcp-receiver/ and
hep/rtcp-sender.
Change-Id: I2af275286ee5e795b79f0c3d450d9e4b28e958b0
does_id_conflict() was passing a pointer to an int to a callback
that expected a pointer to a size_t.
Found by the Address Sanitizer.
Change-Id: I0ff542067eef63a14a60301654d65d34fe2ad503
There's been a long standing leak when using topic pools. The
topics in the pool get cleaned up when the last pool reference is
released but you can't remove a topic specifically. If you reloaded
app_voicemail for instance, and mailboxes went away, their topics
were left in the pool.
* Added stasis_topic_pool_delete_topic() so modules can clean up
topics from pools.
* Registered the topic pool containers so it can be examined from
the CLI when AO2_DEBUG is enabled. They'll be named
"<topic_pool_name>-pool".
Change-Id: Ib7957951ee5c9b9b4482af7b9b4349112d62bc25
Stasis message types are global ao2 objects and we make stasis messages
and cache entries hold references to them. Since there are currently
situations where cache objects are never deleted, the reference count on
the types can exceed 100000 and generate a FRACK assertion message. The
stasis message cache could conceivably also have that many messages
legitimately on large systems.
The only down side to not holding the message type ref in the stasis
message is it only makes a crash either at shutdown or when manually
unloading a busy module slightly more likely. However, this is more
exposing a pre-existing stasis shutdown ordering issue than a problem with
not holding a message type ref in stasis messages.
* Made stasis messages and cache entries no longer hold a ref to the
message type.
Change-Id: Ibaa28efa8d8ad3836f0c65957192424c7f561707
* Create the stasis message object without a lock as it is immutable.
* Create the stasis message type object without a lock as it is immutable.
* Creating the stasis message type could crash if the passed in type name
is NULL and REF_DEBUG is enabled. Added missing NULL check when passing
the ao2 object tag string.
Change-Id: I28763c58bb9f0b427c11971d0103bf94055e7b32
Since app_voicemail no longer uses the cache to maintain its state
there is no longer a need to cache these messages.
ASTERISK-27121
Change-Id: I321c708505f5ad8d00e1b0afc4c27dc2ac12ecb4
The documentation already specified EVENT_FLAG_DIALPLAN for this
event, but the implementation was using EVENT_FLAG_CALL.
Using EVENT_FLAG_DIALPLAN allows AMI clients to opt out of receiving
this highly verbose event.
ASTERISK-28033
Change-Id: I45b3119f30e4dbc17b49831f2b1a4f2c1beadafe
Generators provide such functionality as tone generation or
silence generation. RTCP frames provide RTCP information and
should not stop generators from operating.
ASTERISK-28005
Change-Id: Ieadada07b068a7aa426e8763f1b73a18e1ac34a9
The stasis cache provides a way to reconstruct the current state
of topic subscribers. Unfortunately, since every subscribe and
unsubscribe is cached, the cache continues to grow unabated while
asterisk is running. This patch removes subscribe messages from
the cache when the corresponding unsubscribe is received.
This patch also registers the cache containers with ao2 so that if
AO2_DEBUG is turned on, you can list the container and get its
stats from the CLI.
ASTERISK-27121
Change-Id: I3d18905e477f3721815da91f30da8d3fbb2d4f56
Added a check when we receive a HTTP request line or header line that is
too long. We now return an error response to the sender because we are
not able to process the request.
Change-Id: I6df2705435fd7dde4d5d3bdf7acec859cfb7c12d
Providing a buffer larger than the internal buffer of ast_iostream_gets()
fails to get lines longer than the internal buffer.
* Made ast_iostream_gets() fill the supplied buffer with read data until
either a '\n' is found or the supplied buffer is filled just like fgets().
Change-Id: If18b3f6ee500e22f0633a68779ed09f7e0f305ed
All HTTP/AMI message headers are being sent to the verbose channel.
There are multiple places this is happening. Consolidate the loop into
a function. Drop the debug/verbose message.
Convert to using ast_asprintf to perform the length calculation, memory
allocation and snprintf all in one step.
Change-Id: Ic45e673fde05bd544be95ad5cdbc69518207c1a1
When the stasis cache is used a hash is calculated for
retrieving or inserting messages. This change calculates
a hash when the message type is initialized that is then
used each time needed. This ensures that the hash is
calculated only once for the message type.
Change-Id: I4fe6bfdafb55bf5c322dd313fbd8c32cce73ef37
Changing any Menuselect option in the `Compiler Flags` section causes a
full rebuild of the Asterisk source tree. Every enabled option causes
a #define to be added to buildopts.h, thus breaking ccache caching for
every source file that includes "asterisk.h". In most cases each option
only applies to one or two files. Now we only define those options for
the specific sources which use them, this causes much better cache
matching when working with multiple builds. For example testing code
with an without MALLOC_DEBUG will now use just over half the ccache
size, only main/astmm.o will have two builds cached instead of every
file.
Reorder main/Makefile so _ASTCFLAGS set on specific object files are all
together, sorted by filename. Stop adding -DMALLOC_DEBUG to CFLAGS of
bundled pjproject, this define is no longer used by any header so only
serves to break cache.
The only code change is a slight adjustment to how main/astmm.c is
initialized. Initialization functions always exist so main/asterisk.c
can call them unconditionally. Additionally rename the astmm
initialization functions so they are not exported.
Change-Id: Ie2085237a964f6e1e6fff55ed046e2afff83c027
With the new module loader it was missed that built-in modules never
parsed dependencies from mod->info into vectors of mod. This caused
manager to be initialized before acl (named_acl). If manager.conf
used any named ACL's they would not be found and result in no ACL being
applied to the AMI user.
In addition to the manager ACL fix this adds "extconfig" to all builtin
modules which support realtime configuration. This only matters if one
of the builtin modules is configured with 'preload', depending on
"extconfig" will cause config.c to automatically be initialize during
the preload stage.
Change-Id: I482ed6bca6c1064b05bb538d7861cd7a4f02d9fc
When converting from a json object to an ast variables list the conversion
algorithm was doing a complete traversal of the entire variables list for
every item appended from the json structure.
This patch makes it so the list is no longer traversed for each new ast
variable being appended.
Change-Id: I8bf496a1fc449485150d6db36bfc0354934a3977
When publishing a device state the change can be marked as being
cachable or not. If it is not cached the change is just published
to all interested and not stored away for later query. This was not
fully taken into account when publishing in stasis. The act of
publishing would create a topic for the device even if it may be
ephemeral.
This change makes it so messages which are not cached won't create
a topic for the device. If a topic does already exist it will be
published to but otherwise the change will only be published to
the device state all topic.
ASTERISK-27591
Change-Id: I18da0e8cbb18e79602e731020c46ba4101e59f0a
The "xmldoc dump" cli command was simply concatenating xml documents
into the output file. The resulting file had multiple "xml"
processing instructions and multiple root elements which is illegal.
Normally this isn't an issue because Asterisk has only 1 main xml
documentation file but codec_opus has its own file so if it's
downloaded and you do "xmldoc dump", the result is invalid.
* Added 2 new functions to xml.c:
ast_xml_copy_node_list creates a copy of a list of children.
ast_xml_add_child_list adds a list to an existing list.
* Modified handle_dump_docs to create a new output document and
add to it the children from each input file. It then dumps the
new document to the output file.
Change-Id: I3f182d38c75776aee76413dadd2d489d54a85c07
In the past there was an assertion in the ast_sched_del function
and in order to ensure it was useful the calling function name,
line number, and filename had to be passed in. This cause the ABI
to be different between dev mode and non-dev mode.
This assertion is no longer present so the special logic can be
removed to make it the same between them both.
Change-Id: Icbc69c801e357d7004efc5cf2ab936d9b83b6ab8
Support has been added for receiving a NACK request and handling it.
Now, Asterisk can detect when a NACK request should be sent and knows
how to construct one based on the packets we've received from the remote
end. A buffer has been added that will store out of order packets until
we receive the packet we are expecting. Then, these packets are handled
like normal and frames are queued to the core like normal. Asterisk
knows which packets to request in the NACK request using a vector
which stores the sequence numbers of the packets we are currently missing.
If a missing packet is received, cycle through the buffer until we reach
another packet we have not received yet. If the buffer reaches a certain
size, send a NACK request. If the buffer reaches its max size, queue all
frames to the core and wipe the buffer and vector.
According to RFC3711, the NACK request must be sent out in a compound
packet. All compound packets must start with a sender or receiver
report, so some work was done to refactor the current sender / receiver
code to allow it to be used without having to also include sdes
information and automatically send the report.
Also added additional functionality to ast_data_buffer, along with some
testing.
For more information, refer to the wiki page:
https://wiki.asterisk.org/wiki/display/AST/WebRTC+User+Experience+Improvements
ASTERISK-27810 #close
Change-Id: Idab644b08a1593659c92cda64132ccc203fe991d
I have removed the STATIC_BUILD option immediately as it has not
been maintained in many years and is non-functional.
ASTERISK-27965
Change-Id: I64783d017b86dba9ee3c7bcfb97e59889a3f76d7
Fixes issue where error msg
"Use of before/init after destruction"
was being printed on disabled messages
in dev mode. With this
fix if message is disabled
a warning will print.
ASTERISK-25548
Change-Id: Ie0d866d1cbc60c16dbef08bc65e99505c3c1adfa
* Merge the preload and load stages, use load ordering to try preload's
first. This fixes an issue where `preload=res_config_curl` would fail
unless res_curl and func_curl were also preloaded. Now it is only
required that those modules be loaded during startup: autoload or
regular load is good enough.
* The configuration option `require` and `preload-require` were only
effective if the modules failed to load. These options will now abort
Asterisk startup if required modules fail to reach the 'Running'
state.
* Missing or invalid 'module.conf' did not prevent startup. Asterisk
doesn't do anything without modules so this a fatal error.
Change-Id: Ie4176699133f0e3a823b43f90c3348677e43a5f3
Separate "name" into "classname" and "name".
Use '.' for classname separator instead of '/'.
Prefix reserved words with '_'.
Wrap output with a top-level "testsuites" element.
Change-Id: Iec1a985eba1c478e5c1d65d5dfd95cb708442099
There is a rare case (do to the infrequent timing involved) where
CDR submission threads in batch mode can deadlock with a currently
running CDR batch process. This patch should remove the need for
holding the lock in the scheduler and should clean a few code
paths up that inconsistently submitted new work to the CDR batch
processor.
ASTERISK-27909
Change-Id: I6333e865db7c593c102c2fd948cecdb96481974d
Reported-by: Denis Lebedev
The AMI action was directly sending the text to the channel driver.
However, this makes two threads attempt to handle media and runs afowl of
CHECK_BLOCKING.
* Queue a read action to make the channel's media handling thread actually
send the text message. This changes the AMI actions success/fail response
to just mean the text was queued to be sent not that the text actually got
sent. The channel driver may not even support sending text messages.
ASTERISK-27943
Change-Id: I9dce343d8fa634ba5a416a1326d8a6340f98c379
In addition to text/* content types, incoming_in_dialog_request now
accepts application/* content types.
Also fixed a length issue when copying the body text. It was one
character short.
ASTERISK-27942
Change-Id: I4e54d8cc6158dc47eb8fdd6ba0108c6fd53f2818
* changes:
channel.c: Make CHECK_BLOCKING() save thread LWP id for messages.
channel.c: Fix usage of CHECK_BLOCKING()
autoservice: Don't start channel autoservice if the thread is a user interface.
With ./configure --enable-dev-mode[=noisy], the build fails because every
warning gets an error. Therefore, Asterisk has to be free of warnings and this
variable must go.
Change-Id: I63dd2bc4833b9bdb04602f83422d16caf289d46a
There can be one and only one thread handling a channel's media at a time.
Otherwise, we don't know which thread is going to handle the media frames.
ASTERISK-27625
Change-Id: I4d6a2fe7386ea447ee199003bf8ad681cb30454e
There can be one and only one thread handling a channel's media at a time.
Otherwise, we don't know which thread is going to handle the media frames.
ASTERISK-27625
Change-Id: Ia341f1a6f4d54f2022261abec9021fe5b2eb4905
The CHECK_BLOCKING() macro is used to indicate if a channel's handling
thread is about to do a blocking operation (poll, read, or write) of
media. A few operations such as ast_queue_frame(), soft hangup, and
masquerades use the indication to wake up the blocked thread to reevaluate
what is going on.
ASTERISK-27625
Change-Id: I4dfc33e01e60627d962efa29d0a4244cf151a84d
Executing dialplan functions from either AMI or ARI by getting a variable
could place the channel into autoservice. However, these user interface
threads do not handle the channel's media so we wind up with two threads
attempting to handle the media.
There can be one and only one thread handling a channel's media at a time.
Otherwise, we don't know which thread is going to handle the media frames.
ASTERISK-27625
Change-Id: If2dc94ce15ddabf923ed1e2a65ea0ef56e013e49
In Asterisk there are some dynamic codecs that have
a fixed payload number. This number was being improperly
used to negotiate the codec, instead of using the name
and sample rate. This could result in the wrong payload
number being negotiated for a codec.
This change makes it so that only static payloads
will be negotiated using their payload number.
ASTERISK-27848
Change-Id: Ia865830170fd3f808cdb33104f3d4c4ffdc77570
Before Asterisk sends an HTTP response (at least in the case of errors),
it attempts to read & discard the content of the request. If the client
lies about the Content-Length, or the connection is closed from the
client side before "Content-Length" bytes are sent, the request handling
thread will busy loop.
ASTERISK-27807
Change-Id: I945c5fc888ed92be625b8c35039fc6d2aa89c762