Commit Graph

31985 Commits

Author SHA1 Message Date
Kevin Harwell
f1fb249132 res_pjsip_registrar: mitigate blocked threads on reliable transport shutdown
When a reliable transport is shutdown it's possible for the pjsip registrar
resource shutdown handler to get called multiple times. If this happens and one
of the threads is taking "too long" (slow database call for instance) then the
others get blocked waiting to delete.

Since it only takes one to delete the contact then the other threads should be
able to continue on if one of the threads is currently "deleting". This patch
makes it so now when a thread enters the shutdown handler it checks to see if a
thread is currently already "deleting". If so, then the thread does not attempt
to get the lock, and instead continues on thus avoiding the blockage.

ASTERISK-28213 #close

Change-Id: I7563ca596312b1dff4f3ab41483e89fe2862328a
2019-01-22 13:16:37 -06:00
George Joseph
9c11399be3 pjproject_bundled: Add patch for double free issue in timer heap
Fixed #2172: Avoid double reference counter decrements in
timer in the scenario of race condition between
pj_timer_heap_cancel() and pj_timer_heap_poll().

Change-Id: If000e9438c83ac5084b678eb811e902c035bd2d8
2019-01-22 09:04:33 -06:00
Sean Bright
fb6e0df173 pjsip_transport_management: Shutdown transport immediately on disconnect
The transport management code that checks for idle connections keeps a
reference to PJSIP's transport for IDLE_TIMEOUT milliseconds (32000 by
default). Because of this, if the transport is closed before this
timeout, the idle checking code will keep the transport from actually
being shutdown until the timeout expires.

Rather than passing the AO2 object to the scheduler task, we just pass
its key and look it up when it is time to potentially close the idle
connection. The other transport management code handles cleaning up
everything else for us.

Additionally, because we use the address of the transport when
generating its name, we concatenate an incrementing ID to the end of the
name to guarantee uniqueness.

Related to ASTERISK~28231

Change-Id: I02ee9f4073b6abca9169d30c47aa69b5e8ae9afb
2019-01-21 07:57:07 -06:00
Valentin Vidic
6506c5b1d4 channel.c: Fix segfault with Monitor(wav,file,i)
If the Monitor is started with the i option the read_stream will be
NULL. One code path in channel.c checks if write_stream is set but than
uses read_stream instead causing a segfault.

ASTERISK-28249

Change-Id: I1bae9126537be54895c7fea2d08dd9488d8cc525
2019-01-20 12:51:36 -06:00
Joshua C. Colp
fcd07c34fb stasis / manager / ari: Better filter messages.
Previously both AMI and ARI used a default route on
their stasis message router to handle some of the
messages for publishing out their respective
connection. This caused messages to be given to
their subscription that could not be formatted
into AMI or JSON.

This change adds an API call to the stasis message
router which allows a default route to be set as well
as formatters that the default route is expecting.
This allows both AMI and ARI to specify that their
default route only wants messages of their given
formatter. By doing so stasis can more intelligently
filter at publishing time so that they do not receive
messages which will not be turned into AMI or JSON.

ASTERISK-28244

Change-Id: I65272819a53ce99f869181d1d370da559a7d1703
2019-01-17 12:52:08 -06:00
Sean Bright
011e46d5a6 sched: Make sched_settime() return void because it cannot fail
Change-Id: I66b8b2b2778f186919d73ae9bf592104b8fb1cd5
2019-01-17 10:02:29 -06:00
Jeremy Lainé
21a1feece2 res_http_websocket: respond to CLOSE opcode
This ensures that Asterisk responds properly to frames received from a
client with opcode 8 (CLOSE) by echoing back the status code in its own
CLOSE frame.

Handling of the CLOSE opcode is moved up with the rest of the opcodes so
that unmasking gets applied. The payload is no longer returned to the
caller, but neither ARI nor the chan_sip nor pjsip made use of the
payload, which is a good thing since it was masked.

ASTERISK-28231 #close

Change-Id: Icb1b60205fc77ee970ddc91d1f545671781344cf
2019-01-16 00:24:55 +01:00
Sean Bright
44a862fb57 res_pjsip_transport_websocket: Don't assert on 0 length payloads
When --enable-dev-mode is used, pjsip_tpmgr_receive_packet() will assert
if passed a payload length of 0, so treat empty frames as if we didn't
receive them.

Change-Id: I9c5fdccd89cc8d2f3ed7e3ee405ef0fc78178f48
2019-01-14 09:36:38 -06:00
Joshua C. Colp
9e7e150a13 Merge "res_pjsip: add option to enable ContactStatus event when contact is updated" into 16 2019-01-14 08:30:05 -06:00
Friendly Automation
d76896a30b Merge "stasis/endpoint: Fix memory leak of channel_ids in ast_endpoint structure." into 16 2019-01-14 08:26:53 -06:00
Joshua C. Colp
11d63c9e4f Merge "res_pjsip_sdp_rtp: Only enable abs-send-time when WebRTC is enabled." into 16 2019-01-14 08:04:10 -06:00
Joshua C. Colp
32934180f9 Merge "RTP: reset DTMF last seqno/timestamp on RTP renegotiation" into 16 2019-01-14 08:03:50 -06:00
Joshua C. Colp
72fdba63a8 Merge "app_voicemail: Fix Channel variable VM_MESSAGEFILE for "urgent" voicemail" into 16 2019-01-14 06:19:57 -06:00
mohitdhiman
4b24da607e stasis/endpoint: Fix memory leak of channel_ids in ast_endpoint structure.
During Bridging of two channels if masquerade operation is performed on a
channel (clone channel) which was created with endpoint details
(ast_channel_alloc_with_endpoint()) and the original channel which is created
without endpoint details (ast_channel_alloc()) then both the channels must
exchange their endpoint details or else after masquerade when clone channel
is being destroyed the endpoint cleanup callbacks will be destroyed too and
after call completion unique_id of original channel will still be there in
ast_endpoint structure's channel_ids container.

ASTERISK-28197

Change-Id: Ied0451f378a3f2a36acc8c0984959a69895efa17
2019-01-11 09:01:57 -05:00
Diederik de Groot
d2c182b6ab RAII: Change order or variables in clang version
This prevents use-after-scope issues when unwinding the stack,
which happens in reverse order. The varname variable needs to
remain alive for the destruction to be able to access it.
Issue was found using clang + address-sanitizer.

ASTERISK-28232 #close

Change-Id: I00811c34ae910836a5fb6d22304528aef92624db
2019-01-08 20:34:27 -05:00
Alexei Gradinari
7f22c9f4b7 res_pjsip: add option to enable ContactStatus event when contact is updated
The commit I2f97ebfa79969a36a97bb7b9afd5b6268cf1a07d removed sending out
the ContactStatus AMI event when a contact is updated.
Thist change broke things which rely on old behavior.

This patch adds a new PJSIP global configuration option
'send_contact_status_on_update_registration' to be able to preserve old
ContactStatus behavior.
By default new behavior, i.e. the ContactStatus event will not be sent when a
device refreshes its registration.

Change-Id: I706adf7584e7077eb6bde6d9799ca408bc82ce46
2019-01-08 10:42:54 -05:00
Joshua Colp
c6271155fb res_pjsip_sdp_rtp: Only enable abs-send-time when WebRTC is enabled.
For video streams it was possible for the abs-send-time information
to be placed into RTP streams even if not negotiated. Depending on
the endpoint in use this could cause video to not flow.

We now only enable abs-send-time for negotiation if WebRTC is enabled.

ASTERISK-28230

Change-Id: I0eb682302f8da3a4ea3c42e839208d55f825ed0c
2019-01-07 14:06:58 +00:00
Alexei Gradinari
c0e57e458b RTP: reset DTMF last seqno/timestamp on RTP renegotiation
The remote side may start a new stream when renegotiating RTP.
Need to reset the DTMF last sequence number and the timestamp
of the last END packet on RTP renegotiation.

If the new time stamp is lower then the timestamp of the last DTMF END packet
the asterisk drops all DTMF frames as out of order.

This bug was caught using Cisco ip-phone SPA5XX and codec g722.
On SIP session update the SPA50X resets stream and a new timestamp is twice
smaller then the previous.

ASTERISK-28162 #close

Change-Id: Ic72b4497e74d801b27a635559c1cf29c16c95254
2019-01-04 10:59:00 -05:00
Joshua C. Colp
701cd2ee58 Merge "ast_coredumper: Refactor the pid determination process" into 16 2019-01-04 08:26:10 -06:00
Friendly Automation
140ed330ac Merge "stasis: Fix ABI between DEVMODE and non-DEVMODE." into 16 2019-01-03 17:39:18 -06:00
Joshua C. Colp
1e9da4dba6 Merge "stasic.c: Fix printf format type mismatches with arguments." into 16 2019-01-03 05:41:25 -06:00
Joshua C. Colp
92ee1bdfbb Merge "app_queue: Fix crash when using 'b' option on non-ringall queue." into 16 2019-01-03 05:12:49 -06:00
Bryan Boatright
92298434bd app_voicemail: Fix Channel variable VM_MESSAGEFILE for "urgent" voicemail
If a voicemail is marked "urgent" then the VM_MESSAGEFILE channel variable is
not updated correctly since urgent messages are in a different directory. The
fix is to update the channel variable when the path to the urgent message is
created.

ASTERISK-28225

Change-Id: I8efbace06e6122ea0793f7bdb073d4378e8274ca
2019-01-02 13:16:20 -05:00
Joshua Colp
2d9482695d app_queue: Fix crash when using 'b' option on non-ringall queue.
When using the 'b' option to Queue with a queue that was not configured
for ring all a crash would occur as the wrong pointer would be used.

ASTERISK-28218

Change-Id: If1390f64e321047dff24fd2410c95dde74904980
2019-01-02 17:34:44 +00:00
Richard Mudgett
f196078705 stasic.c: Fix printf format type mismatches with arguments.
An int64_t is not likely the same size as a long.

* Changed the int64_t values in the statistics structs to longs so casting
is not necessary when generating the formatted CLI output.  The offending
members did not need to be int64_t anyway as they were only set by an int
type variable which was already truncating bits.

* Reordered the statistics structs to reduce potential padding bytes.

Change-Id: Ic090a070e9dc4ca650ebdb9c01ed50a581289962
2019-01-02 12:10:58 -05:00
George Joseph
4ff64bfc2c Merge "backtrace.c: Fix casting pointer to/from integral type." into 16 2019-01-02 09:51:19 -06:00
Corey Farrell
44a7faca21 stasis: Fix ABI between DEVMODE and non-DEVMODE.
Create compatibility stubs for maximum ABI compatibility.

ASTERISK-28212 #close

Change-Id: I872c04842ab6b61e9dd6d37e4166bc619aa20626
2018-12-26 13:37:16 -05:00
George Joseph
ff2ed4eeee Revert "stasis_cache: Stop caching stasis subscription change messages"
This commit caused issues with polling when combined with
the revert commit "Revert "app_voicemail: Remove need to subscribe to stasis"

This reverts commit 17d6d9e1e7.

ASTERISK-28222
Reported by: abelbeck

Change-Id: Ib6a16cbe2c0b74c76c64264f525ab647959c1483
2018-12-26 10:29:51 -06:00
George Joseph
3efe5061d5 ast_coredumper: Refactor the pid determination process
In order to get a dump of the running process, we need to find the
pid of the main asterisk process.  This can be tricky if there are
also instances of "asterisk -r" running or if an alternate location
for asterisk.conf was specified on the command line with the -C
option that also specified an alternation location for the pid file.

So now...

1. We find the asterisk executable with "which" or the --asterisk-bin
   command line option.
2. If there's only 1 process with an executable path that matches,
   we use that pid.  If not...
3. We try "<asterisk-bin> -rx 'core show settings'" and parse the
   output to find the pidfile, then read that for the pid.  If that
   didn't work...
4. We get a list of all the pids matching <asterisk-bin> and look
   in /proc/<pid>/cmdline for a -C argument and retry the "core show
   settings" using the same -C option.  We can't parse the output
   of "ps" to get the -C path because it may contain spaces.  The
   contents of /proc/<pid>/cmdline are delimited by NULLs.  For BSDs
   we may have to mount /proc first. :(

ASTERISK-28221
Reported by: Andrew Nagy

Change-Id: I8aa1f3f912f949df2b5348908803c636bde1d57c
2018-12-24 14:17:32 -05:00
Richard Mudgett
59717b5e85 backtrace.c: Fix casting pointer to/from integral type.
The backtrace library bfd.h include file does not get the sizes of
pointers and ints right on some platforms.  On my old test box the size
of bfd_vma is 8 while the size of a pointer is 4.  gcc on the box
complains of the integer casting to/from pointers size mismatch.

* uintptr_t to the rescue by doing an appropriate two stage cast.

Change-Id: Icb2621583f50c8728de08a3c824d95fe53cc45d0
2018-12-19 13:50:51 -05:00
Joshua C. Colp
08e6cb6480 Merge "res/res_ari: Add additional hangup reasons" into 16 2018-12-19 05:14:41 -06:00
Friendly Automation
0110532bf9 Merge "app_voicemail: Don't delete mailbox state unless mailbox is deleted" into 16 2018-12-19 05:05:54 -06:00
George Joseph
4cbe04de77 Merge "res_pjsip: Patch for res_pjsip_* module load/reload crash" into 16 2018-12-18 10:43:11 -06:00
George Joseph
955129e9a4 Merge "res_rtp_asterisk: Remove some unused structure fields." into 16 2018-12-18 10:42:07 -06:00
George Joseph
aebb822d1f app_voicemail: Don't delete mailbox state unless mailbox is deleted
The free_user function was automatically deleting the stasis mailbox
state but this only makes sense when the mailbox is actually
deleted, not just the structure freed.  This was causing issues
where leave_voicemail would publish the mwi message to stasis and
delete the state before the message could be processed by
res_pjsip_mwi.

* Removed the delete of state from free_user().

* Created a new free_user_final() function that both frees the data
  structure and deletes the state.  This function is only called
  during module load/unload where it's appropriate to delete the
  state.

ASTERISK-28215

Change-Id: I305e8b3c930e9ac41d901e5dc8a58fd7904d98dd
2018-12-18 11:40:12 -05:00
Friendly Automation
9b57199a7a Merge "res_format_attr_h264.c: Make sure profile-level-id fmtp attribute is set" into 16 2018-12-17 08:27:36 -06:00
Sean Bright
970805180e res_rtp_asterisk: Remove some unused structure fields.
All of the fields that were removed were no longer referenced except for
'lastrxts' and 'rxseqno' which were only ever written to.

Change-Id: I5a5d31eb33e97663843698f58d0d97f22a76627c
2018-12-14 12:56:27 -05:00
Joshua C. Colp
9e159914dc Merge "bridge_builtin_features.c: Set auto(mix)mon variables on both channels" into 16 2018-12-14 09:37:04 -06:00
Sean Bright
f60afac587 res_format_attr_h264.c: Make sure profile-level-id fmtp attribute is set
The profile-iop octet (the 2nd) of profile-level-id can be zero
according to RFC 6184 Section 8.1. So we ignore its value when deciding
to include profile-level-id in the outgoing SDP.

ASTERISK-27959 #close
Reported by: David Kuehling

Change-Id: Id28cd916a3d7748058fe9609b585d07d9e243f73
2018-12-13 17:03:54 -05:00
Joshua C. Colp
84d693a689 Merge "utils: Don't set or clear flags that don't need setting or clearing" into 16 2018-12-13 08:23:42 -06:00
Joshua C. Colp
b924594104 Merge "confbridge: announce to the marked users when they join an empty conference" into 16 2018-12-13 08:00:21 -06:00
Sean Bright
640aac768b bridge_builtin_features.c: Set auto(mix)mon variables on both channels
This is how features behaved up through Asterisk 11, but was changed
when the new bridging framework was implemented in Asterisk 12.

Reported by rrittgarn in #asterisk.

Change-Id: I72cf86223947a8118c75f46e2c603dbc11e3125b
2018-12-13 08:52:40 -05:00
Friendly Automation
67e91d012b Merge "stasis: Add statistics gathering in developer mode." into 16 2018-12-12 13:12:04 -06:00
Joshua C. Colp
36db878adc Merge "Use non-blocking socket() and pipe() wrappers" into 16 2018-12-12 11:31:20 -06:00
Alexei Gradinari
2610379605 confbridge: announce to the marked users when they join an empty conference
Currently the file sound_only_person is not played when a marked
user (with announce_only_user=yes) joins an empty conference.

This patch fixes it.

ASTERISK-28201 #close

Change-Id: I85b67687e6b220939c3af8091d83a70a7b174cf4
2018-12-12 12:16:15 -05:00
Joshua C. Colp
68ec7d93e8 stasis: Add statistics gathering in developer mode.
This change adds statistics gathering to Stasis topics,
subscriptions, and message types. These can be viewed using
CLI commands and provide insight into how Stasis is used
and how long certain operations take to execute.

These are only available when Asterisk is compiled in
developer mode and do not have any impact under normal
operation.

ASTERISK-28117

Change-Id: I94411b53767f89ee01714daaecf0c2f1666e863f
2018-12-12 12:14:44 -05:00
Friendly Automation
ff147bcf92 Merge "stasis: Allow filtering by formatter" into 16 2018-12-12 11:09:28 -06:00
Joshua C. Colp
569e556656 Merge "pjproject_bundled: check whether UPDATE is supported on outgoing calls" into 16 2018-12-12 11:01:39 -06:00
Joshua C. Colp
88af756419 Merge "build: Update config.guess and config.sub" into 16 2018-12-12 11:01:18 -06:00
George Joseph
66820f19c2 Merge "Revert "RTP: reset DTMF last seqno/timestamp on voice packet with marker bit"" into 16 2018-12-11 14:17:35 -06:00