Commit Graph

28544 Commits

Author SHA1 Message Date
Richard Mudgett
a199f94908 res_agi: Prevent an AGI from eating frames it should not. (Re-do)
A dialplan intercept routine is equivalent to an interrupt routine.  As
such, the routine must be done quickly and you do not have access to the
media stream.  These restrictions are necessary because the media stream
is the responsibility of some other code and interfering with or delaying
that processing is bad.  A possible future dialplan processing
architecture change may allow the interception routine to run in a
different thread from the main thread handling the media and remove the
execution time restriction.

* Made res_agi.c:run_agi() running an AGI in an interception routine run
in DeadAGI mode.  No touchy channel frames.

ASTERISK-25951

ASTERISK-26343

ASTERISK-26716

Change-Id: I638f147ca7a7f2590d7194a8ef4090eb191e4e43
2017-02-01 13:33:12 -06:00
Richard Mudgett
6bed318a66 Frame deferral: Revert API refactoring.
There are several issues with deferring frames that are caused by the
refactoring.

1) The code deferring frames mishandles adding a deferred frame to the
deferred queue.  As a result the deferred queue can only be one frame
long.

2) Deferrable frames can come directly from the channel driver as well as
the read queue.  These frames need to be added to the deferred queue.

3) Whoever is deferring frames is really only doing the __ast_read() to
collect deferred frames and doesn't care about the returned frames except
to detect a hangup event.  When frame deferral is completed we must make
the normal frame processing see the hangup as a frame anyway.  As such,
there is no need to have varying hangup frame deferral methods.  We also
need to be aware of the AST_SOFTHANGUP_ASYNCGOTO hangup that isn't real.
That fake hangup is to cause the PBX thread to break out of loops to go
execute a new dialplan location.

4) To properly deal with deferrable frames from the channel driver as
pointed out by (2) above, means that it is possible to process a dialplan
interception routine while frames are deferred because of the
AST_CONTROL_READ_ACTION control frame.  Deferring frames is not
implemented as a re-entrant operation so you could have the unsupported
case of two sections of code thinking they have control of the media
stream.

A worse problem is because of the bad implementation of the AMI PlayDTMF
action.  It can cause two threads to be deferring frames on the same
channel at the same time.  (ASTERISK_25940)

* Rather than fix all these problems simply revert the API refactoring as
there is going to be only autoservice and safe_sleep deferring frames
anyway.

ASTERISK-26343

ASTERISK-26716 #close

Change-Id: I45069c779aa3a35b6c863f65245a6df2c7865496
2017-02-01 13:33:12 -06:00
Joshua Colp
e371e13b9e res_pjsip: Handle invocation of callback on outgoing request when error occurs.
There are some error cases in PJSIP when sending a request that will
result in the callback for the request being invoked.  The code did not
handle this case and assumed on every error case that the callback was not
invoked.

The code has been changed to check whether the callback has been invoked
and if so to absorb the error and treat it as a success.

ASTERISK-26679
ASTERISK-26699

Change-Id: I563982ba204da5aa1428989a11c06dd9087fea91
2017-02-01 13:11:56 -06:00
Sean Bright
339c30f2b6 res_rtp_asterisk: Swap byte-order when sending signed linear
Before Asterisk 13, signed linear was converted into network byte order by a
smoother before being sent over the network. We restore this behavior by
forcing the creation of a smoother when slinear is in use and setting the
appropriate flags so that the byte order conversion is always done.

ASTERISK-24858 #close
Reported-by: Frankie Chin

Change-Id: I868449617d1a7819578f218c8c6b2111ad84f5a9
2017-02-01 10:35:44 -05:00
George Joseph
7fd28cefdb debug_utilities: Install ast_logescalator to /var/lib/asterisk/scripts
Forgot to install it with the original patch

Change-Id: I8bdb540a6694971ae5fe21f48d532332c6482e4c
2017-01-31 11:46:08 -07:00
zuul
ea54c0e1fe Merge "make_build_h: handle backslashes in external strings" into 13 2017-01-31 08:32:58 -06:00
Joshua Colp
d2f30f0225 Merge "ast_careful_fwrite to support EPIPE gracefully" into 13 2017-01-30 11:52:05 -06:00
zuul
fd3f69cd05 Merge "app_queue: Fix queues randomly disappearing on reload" into 13 2017-01-30 11:28:30 -06:00
zuul
56e925f96a Merge "libastssl/pj: libastssl/pj should have an so_version" into 13 2017-01-27 19:07:55 -06:00
zuul
484e8ed5e3 Merge "debug_utilities: Add ast_logescalator" into 13 2017-01-27 17:49:43 -06:00
George Joseph
456bc3c704 debug_utilities: Add ast_logescalator
The escalator works by creating a set of startup commands in cli.conf
that set up logger channels and issue the debug commands for the
subsystems specified.  If asterisk is running when it is executed,
the same commands will be issued to the running instance.  The original
cli.conf is saved before any changes are made and can be restored by
executing '$prog --reset'.

The log output will be stored in...
$astlogdir/message.$uniqueid
$astlogdir/debug.$uniqueid
$astlogdir/dtmf.$uniqueid
$astlogdir/fax.$uniqueid
$astlogdir/security.$uniqueid
$astlogdir/pjsip_history.$uniqueid
$astlogdir/sip_history.$uniqueid

Some minor tweaks were made to chan_sip, and res_pjsip_history
so their history output could be send to a log channel as packets
are captured.

A minor tweak was also made to manager so events are output to verbose
when "manager set debug on" is issued.

Change-Id: I799f8e5013b86dc5282961b27383d134bf09e543
2017-01-27 15:09:21 -06:00
George Joseph
bcb2c1f62f Merge "tests: use datadir for sound files" into 13 2017-01-27 14:51:01 -06:00
Torrey Searle
54b027916a libastssl/pj: libastssl/pj should have an so_version
Issue introduced in b59956a87.  In the non-darwin case libastssl/pj
should be versioned.  This causes the symbol file for this lib
to not be generated.

Change-Id: Ib07ae8c40252813c488e2c1ac6204fd42816dd4c
2017-01-27 07:14:14 -07:00
George Joseph
d6f67df8ce Merge "test_voicemail_api: order of params to VERIFY macros" into 13 2017-01-27 07:04:18 -06:00
George Joseph
e28d3c4917 Merge "res_pjsip_endpoint_identifier_ip: Fix memory leak of hosts when resolving." into 13 2017-01-27 07:01:47 -06:00
George Joseph
cb504ad6ae Merge "ari: Implement 'debug all' and request/response logging" into 13 2017-01-27 07:01:21 -06:00
kkm
3c8f84786e make_build_h: handle backslashes in external strings
LikewiseOpen creates user names with a backslash in them. A gentle
massage with sed(1) allows such strings to be inserted into build.h
properly quoted. I am also adding the same for host name and other
strings used in the script that are more or less user-controlled.

ASTERISK-26754

Change-Id: Iac5ef2b67a68ee58f35ddbf86bb818ba6eabecae
2017-01-26 19:14:34 -08:00
kkm
555e8cd2ba ast_careful_fwrite to support EPIPE gracefully
When a reading end of the network socket is closed by an AMI manager,
the EPIPE is signaled when writing to our end, resulting in the
spurious log error message

  ast_careful_fwrite: fwrite() returned error: Broken pipe

Previously EPIPE was handled in ast_carefulwrite() a few lines above,
but not in this function.

ASTERISK-26753

Change-Id: I6a67335cd6526608bb9b78f796c626b1677664b8
2017-01-26 19:04:30 -08:00
kkm
be92f10a16 app_queue: Fix queues randomly disappearing on reload
With 500+ queues and a reload every minute, a random queue disappears
upon reload. The cause is mususe of the 'dead' flag. Namely, all queues
were marked dead up front, and then "resurrected" by dropping this flag
for those found in the configuration. But a queue marked dead can be
removed also when control leaves the app entry point on a PBX thread.

With this change, the queue is marked only not found, and at the end of
reload only the queues that are still not found are actually marked as
dead, so the dead flag is never reset, and set only on positively dead
queues.

ASTERISK-26755

Change-Id: I3a4537aec9eb8d8aeeaa0193407e3523feb004bf
2017-01-26 18:11:18 -08:00
George Joseph
b39c04fc02 Merge "PJPROJECT logging: Fix detection of max supported log level." into 13 2017-01-26 18:52:31 -06:00
George Joseph
f5b31cb2ae Merge "frame.c: Fix off-nominal format ref leaks." into 13 2017-01-26 16:03:28 -06:00
zuul
1a81ba335b Merge "res_musiconhold.c: Fix format ref leak when parsing MOH config class." into 13 2017-01-26 13:21:55 -06:00
Joshua Colp
616e98ce0a Merge "T.140: Fix format ref and memory leaks." into 13 2017-01-26 11:30:45 -06:00
Joshua Colp
aae9df0643 res_pjsip_endpoint_identifier_ip: Fix memory leak of hosts when resolving.
This change adds a missing unreference of the hostname when resolving and
also cleans up the iterator.

ASTERISK-26735

Change-Id: Ic012ebaf3d89e714eec340b7b0c5e63c66af857a
2017-01-26 16:58:20 +00:00
zuul
a7e6f0dee5 Merge "Add notes about embedded ast_frame structs holding a format ref." into 13 2017-01-26 10:12:32 -06:00
George Joseph
da098e2227 Merge "astobj2.c: Add excessive ref count trap." into 13 2017-01-26 07:35:43 -06:00
Mark Michelson
9e3150b98d Add reload options to CLI/AMI stale object commands.
Marking an object as stale in a memory cache is supposed to prime the
cache so that the next time the item is retrieved, the stale item is
deleted from the cache and a background task is run to re-populate the
cache with a fresh version of the object.

The problem is, there are some object types out there for which there is
no natural reason that they would be retrieved from the backend with any
regularity. Outbound PJSIP registrations are a good example of this. At
startup, they are read, and an object-specific state is created that
refers to the initially-retrieved object for all time.

Adding the "reload" option to the CLI/AMI commands gives the cache the
opportunity to manually re-retrieve the object from the backend, both
storing the new object in the cache and applying the new object's
configuration to the module that uses that object.

Change-Id: Ieb1fe7270ceed491f057ec5cbf0e097bde96c5c8
2017-01-25 17:42:29 -06:00
zuul
3410000948 Merge "main/app.c: Memory corruption from early format destruction." into 13 2017-01-25 15:13:49 -06:00
zuul
89e9d2cfb8 Merge "stasis_bridge.c: Fix off-nominal stasis control ref leak." into 13 2017-01-25 13:52:24 -06:00
Richard Mudgett
c54f9d2bf0 T.140: Fix format ref and memory leaks.
* channel.c:ast_sendtext(): Fix T.140 SendText memory leak.

* format_compatibility.c: T.140 RED and T.140 were swapped.

* res_rtp_asterisk.c:rtp_red_init(): Fix ast_format_t140_red ref leak.

* res_rtp_asterisk.c:rtp_red_init(): Fix data race after starting periodic
scheduled red_write().

* res_rtp_asterisk.c: Some other minor misc tweaks.

Change-Id: Ifa27a2e0f8a966b1cf628607c86fc4374b0b88cb
2017-01-25 13:44:26 -06:00
zuul
e51193bf72 Merge "chan_oss.c: Fix format ref leak in oss_read()." into 13 2017-01-25 13:32:38 -06:00
George Joseph
f93861b204 Merge "res_pjsip_endpoint_identifier_ip: Ensure error defaults to 0." into 13 2017-01-25 08:28:33 -06:00
George Joseph
f2c1ee6d71 Merge "pjproject_bundled: Fix setting max log level" into 13 2017-01-24 22:30:07 -06:00
George Joseph
284b8b981e Merge "Free endpoint ACLs when destroying PJSIP endpoints." into 13 2017-01-24 15:49:07 -06:00
George Joseph
7b06dae2d8 Merge "res_pjsip_pubsub.c: Implement "pjsip show subscriptions" commands." into 13 2017-01-24 15:47:13 -06:00
Joshua Colp
a2f0adccbd res_pjsip_endpoint_identifier_ip: Ensure error defaults to 0.
When configuring a match using a netmask the error variable was
not defaulting to 0. For some people this would cause the code
to think an error occurred when adding the match when in reality
it added perfectly fine.

ASTERISK-26693

Change-Id: I850c250813742bddde65c84e739093c9e01dfe56
2017-01-24 21:39:39 +00:00
Richard Mudgett
607b3ac736 astobj2.c: Add excessive ref count trap.
Change-Id: I32e6a589cf9009450e4ff7cb85c07c9d9ef7fe4a
2017-01-24 14:10:16 -06:00
Richard Mudgett
ab8cb5a7ce main/app.c: Memory corruption from early format destruction.
* make_silence() created a malloced silence slin frame without adding a
slin format ref.  When the frame is destroyed it will unref the slin
format that never had a ref added.  Memory corruption is expected to
follow.

* Simplified and fixed counting the number of samples in a frame list for
make_silence().

* Eliminated an unnecessary RAII_VAR associated with the make_silence()
frame.

Change-Id: I47de3f9b92635b7f8b4d72309444d6c0aee6f747
2017-01-24 14:04:08 -06:00
Richard Mudgett
dcd8e4b1a0 frame.c: Fix off-nominal format ref leaks.
* ast_frisolate() could leak frame format refs on allocation
failures.

* Similified code in ast_frisolate() and code used by
ast_frisolate().

Change-Id: I79566d4d36b3d7801bf0c8294fcd3e9a86a2ed6d
2017-01-24 14:01:47 -06:00
Richard Mudgett
00a227e93d stasis_bridge.c: Fix off-nominal stasis control ref leak.
Change-Id: Ib17218343a6596832060180e19386da9df150ac8
2017-01-24 13:57:41 -06:00
Richard Mudgett
38a2021c68 res_musiconhold.c: Fix format ref leak when parsing MOH config class.
Change-Id: Ica8e8e2ce7604c2c61ec55bef07dc675361d2ea5
2017-01-24 13:40:11 -06:00
Richard Mudgett
ab7a9fc5b2 chan_oss.c: Fix format ref leak in oss_read().
Change-Id: I0a5d56c7dcf327d60f86a4c25a23571733709fd0
2017-01-24 13:38:32 -06:00
Richard Mudgett
1484a991e1 Add notes about embedded ast_frame structs holding a format ref.
mod_format.h: Note ast_filestream.fr holds a format ref.

translate.h: Note ast_trans_pvt.f holds a format ref.

Change-Id: I86bda354d725207b41e08920355d7c31b2d7f749
2017-01-24 13:36:51 -06:00
George Joseph
17f4989d49 ari: Implement 'debug all' and request/response logging
The 'ari set debug' command has been enhanced to accept 'all' as an
application name.  This allows dumping of all apps even if an app
hasn't registered yet.  To accomplish this, a new global_debug global
variable was added to res/stasis/app.c and new APIs were added to
set and query the value.

'ari set debug' now displays requests and responses as well as events.
This required refactoring the existing debug code.

* The implementation for 'ari set debug' was moved from stasis/cli.{c,h}
  to ari/cli.{c,h}, and stasis/cli.{c,h} were deleted.
* In order to print the body of incoming requests even if a request
  failed, the consumption of the body was moved from the ari stubs
  to ast_ari_callback in res_ari.c and the moustache templates were
  then regenerated.  The body is now passed to ast_ari_invoke and then
  on to the handlers.  This results in code savings since that template
  was inserted multiple times into all the stubs.

An additional change was made to the ao2_str_container implementation
to add partial key searching and a sort function.  The existing cli
code assumed it was already there when it wasn't so the tab completion
was never working.

Change-Id: Ief936f747ce47f1fb14035fbe61152cf766406bf
2017-01-24 10:48:41 -07:00
Richard Mudgett
30cb4eb57f PJPROJECT logging: Fix detection of max supported log level.
The mechanism used for detecting the maximum log level compiled into the
linked pjproject did not work.  The API call simply stores the requested
level into an integer and does no range checking.  Asterisk was assuming
that there was range checking and limited the new value to the allowable
range.  To get the actual maximum log level compiled into the linked
pjproject we need to get and save off the initial set log level from
pjproject.  This is the maximum log level supported.

* Get and save off the initial log level setting before altering it to the
desired level on startup.  This has to be done by a macro rather than
calling a core function to avoid incorrectly linking pjproject.

* Split the initial log level warning messages to warn if the linked
pjproject cannot support the requested startup level and if it is too low
to get the pjproject buildopts for "pjproject show buildopts".

* Adjust the CLI "pjproject set log level" to check the saved max log
level and to generate normal output messages instead of a warning message.

ASTERISK-26743 #close

Change-Id: I40aa76653e2a1dece66c3f8734594b4f0471cfb4
2017-01-24 11:23:05 -06:00
Tzafrir Cohen
cd2677f966 tests: use datadir for sound files
Some (voicemail-related) tests API symlinks beep.gsm and other files
from ast_config_AST_VAR_DIR. It should use ast_config_AST_DATA_DIR.

ASTERISK-26740 #close

Change-Id: Id49c56fb9e16df64b1a2b829693ca7601252df89
2017-01-24 08:34:57 -06:00
Tzafrir Cohen
b62f84bfb1 test_voicemail_api: order of params to VERIFY macros
Fix order of parameters in calls to VM_API_INT_VERIFY and
VM_API_STRING_VERIFY

ASTERISK-26739 #close

Change-Id: I30dc6b36893aadad6012be3f16f93aa5720870d6
Note: status: builds. Not tested any further.
2017-01-24 08:34:18 -06:00
George Joseph
48178e5918 Merge "res_pjsip_endpoint_identifier_ip: Read settings before resolving." into 13 2017-01-24 07:08:44 -06:00
Richard Mudgett
e3dcb9ddd9 res_pjsip_pubsub.c: Implement "pjsip show subscriptions" commands.
ASTERISK-23828 #close

Change-Id: Ifb8a3b61f447aedc58a8e6b36a810f7566018567
2017-01-23 18:06:08 -06:00
Mark Michelson
75497c33ea Free endpoint ACLs when destroying PJSIP endpoints.
If endpoint ACLs were specified, they were not being freed
when endpoints were destroyed. On systems with realtime endpoints, this
could add up quickly since each DB lookup would allocate the ACL without
freeing it.

ASTERISK-26731 #close
Reported by Ustinov Artem

Change-Id: Ie1f8bf5b7a0de628c975beba01e69c56893331ad
2017-01-23 16:20:42 -06:00