asterisk/asterisk.git
3 years agoAlembic: Increase column size of PJSIP AOR "contact".
Mark Michelson [Wed, 16 Dec 2015 17:28:14 +0000 (11:28 -0600)]
Alembic: Increase column size of PJSIP AOR "contact".

When running the PJSIP AMI "show_endpoint" test with automatic
conversion to realtime, the test would fail. This was because the AOR
"contact" column was sized at 40, and the configured contact was larger
than that.

This commit increases the size of the contact column to 255 characters.

Change-Id: Ia65bc7fd37699b7c0eaef9629a1a31eab9a24ba1

3 years agoMerge "AMI: Fixed OriginateResponse message"
Matt Jordan [Wed, 16 Dec 2015 03:22:28 +0000 (21:22 -0600)]
Merge "AMI: Fixed OriginateResponse message"

3 years agores_rtp_asterisk.c: Fix DTLS negotiation delays.
server-pandora [Mon, 14 Dec 2015 19:53:20 +0000 (11:53 -0800)]
res_rtp_asterisk.c: Fix DTLS negotiation delays.

- Trigger pending DTLS packets to send out, once the RTP instance's remote
  address is set.
- Avoids locking the DTLS structure unnecessarily by only doing this if
  DTLS is passive.
- Add DTLS locks around the structurally sensitive calls in the SSL
  portion of __rtp_recvfrom, since dtls_srtp_check_pending does not lock
  inside of itself, and we're dealing with the SSL BIO in at least two
  threads.

WebRTC channels may receive a DTLS handshake before
ast_rtp_remote_address_set is called, which causes there to be a pending
response to send out.   Previous to 1ad827, this was handled by calling
dtls_srtp_check_pending on receipt of any RTP packet - a STUN or RTP
packet could trigger the pending handshake response.  Since that was
rightfully removed, whenever the DTLS handshake is received before the
remote address is set, we would have to wait until another SSL packet
arrives.

As of Chrome M47's optimizations to their handshake process, WebRTC
conversations between Chrome M47+ and Asterisk, where Asterisk is passive,
experience a 1 second delay without this patch, because the SSL handshake
is received before ICE negotation stores the remote_address, and the next
SSL packet isn't received until after a 1 second timeout in Chrome, which
causes a new handshake request.

ASTERISK-25614 #close

Change-Id: I547f1be7e302dbf71f6553dd8cbc0657b1d0b908

3 years agoAMI: Fixed OriginateResponse message
pchero [Tue, 8 Dec 2015 19:04:12 +0000 (20:04 +0100)]
AMI: Fixed OriginateResponse message

When the asterisk sending OriginateResponse message,
it doesn't set the "Uniqueid".
And it didn't support correct response message for
Application originate.

ASTERISK-25624 #close

Change-Id: I26f54f677ccfb0b7cfd4967a844a1657fd69b74d

3 years agoFix sscanf() format string type mismatch.
Richard Mudgett [Mon, 14 Dec 2015 21:25:02 +0000 (15:25 -0600)]
Fix sscanf() format string type mismatch.

ASTERISK-25615
Reported by: George Joseph

Change-Id: Ieff35307254ca193f3d473cff2e396ca57c7ce0b

3 years agoMerge "main/utils: Don't emit an ERROR message if the read end of a pipe closes"
Matt Jordan [Mon, 14 Dec 2015 12:45:07 +0000 (06:45 -0600)]
Merge "main/utils: Don't emit an ERROR message if the read end of a pipe closes"

3 years agomain/utils: Don't emit an ERROR message if the read end of a pipe closes
Matt Jordan [Sun, 13 Dec 2015 19:13:55 +0000 (13:13 -0600)]
main/utils: Don't emit an ERROR message if the read end of a pipe closes

An ERROR or WARNING message should generally indicate that something has gone
wrong in Asterisk. In the case of writing to a file descriptor, Asterisk is not
in control of when the far end closes its reading on a file descriptor. If the
far end does close the file descriptor in an unclean fashion, this isn't a bug
or error in Asterisk, particularly when the situation can be gracefully
handled in Asterisk.

Currently, when this happens, a user would see the following somewhat cryptic
ERROR message:

  "utils.c: write() returned error: Broken pipe"

There's a few problems with this:
(1) It doesn't provide any context, other than 'something broke a pipe'
(2) As noted, it isn't actually an error in Asterisk
(3) It can get rather spammy if the thing breaking the pipe occurs often, such
    as a FastAGI server
(4) Spammy ERROR messages make Asterisk appear to be having issues, or can even
    mask legitimate issues

This patch changes ast_carefulwrite to only log an ERROR if we actually had one
that was reasonably under our control. For debugging purposes, we still emit
a debug message if we detect that the far side has stopped reading.

Change-Id: Ia503bb1efcec685fa6f3017bedf98061f8e1b566

3 years agopjsip/config_transport: Check pjproject version at runtime for async ops
George Joseph [Sat, 12 Dec 2015 17:08:50 +0000 (10:08 -0700)]
pjsip/config_transport: Check pjproject version at runtime for async ops

pjproject < 2.5.0 will segfault on a tls transport if async_operations
is greater than 1.  A runtime version check has been added to throw
an error if the version is < 2.5.0 and async_operations > 1.

To assist in the check, a new api "ast_compare_versions" was added
to utils which compares 2 major.minor.patch.extra version strings.

ASTERISK-25615 #close

Change-Id: I8e88bb49cbcfbca88d9de705496d6f6a8c938a98
Reported-by: George Joseph
Tested-by: George Joseph

3 years agochan_sip: Add TCP/TLS keepalive to TCP/TLS server
Jonathan Rose [Thu, 10 Dec 2015 17:44:03 +0000 (11:44 -0600)]
chan_sip: Add TCP/TLS keepalive to TCP/TLS server

Adds the TCP Keep Alive option to TCP and TLS server sockets. Previously
this option was only being set on session sockets.
http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/
According to the link above, the SO_KEEPALIVE option is useful for knowing
when a TCP connected endpoint has severed communication without indicating
it or has become unreachable for some reason. Without this patch, keep
alive is not set on the socket listening for incoming TCP sessions and
in Komatsu's report this resulted in the thread listening for TCP becoming
stuck in a waiting state.

ASTERISK-25364 #close
Reported by: Hiroaki Komatsu

Change-Id: I7ed7bcfa982b367dc64b4b73fbd962da49b9af36

3 years agoMerge "res_pjsip: Add existence and readablity checks for tls related files"
Joshua Colp [Thu, 10 Dec 2015 13:13:40 +0000 (07:13 -0600)]
Merge "res_pjsip:  Add existence and readablity checks for tls related files"

3 years agoMerge "app_meetme: Set default value for audio_buffers."
Joshua Colp [Thu, 10 Dec 2015 12:03:25 +0000 (06:03 -0600)]
Merge "app_meetme: Set default value for audio_buffers."

3 years agoMerge "res_chan_stats: Fix bug to send correct statistics to StatsD"
Joshua Colp [Thu, 10 Dec 2015 12:02:55 +0000 (06:02 -0600)]
Merge "res_chan_stats: Fix bug to send correct statistics to StatsD"

3 years agoapp_meetme: Set default value for audio_buffers.
Corey Farrell [Mon, 7 Dec 2015 19:07:32 +0000 (14:07 -0500)]
app_meetme: Set default value for audio_buffers.

The default value was never set for audio_buffers, causing bad
audio quality.  This ensures the default is always set.

ASTERISK-25569 #close

Change-Id: I2d2ee3e644120b0f9f6ea6ab9286d7d590942a44

3 years agores_chan_stats: Fix bug to send correct statistics to StatsD
tcambron [Wed, 9 Dec 2015 15:48:29 +0000 (09:48 -0600)]
res_chan_stats: Fix bug to send correct statistics to StatsD

Fixed a bug that originally would show a negative number of
active calls occuring in Asterisk. A gauge is persistent so
incrementing and decrementing it results in a more consistent
performance. Also changed to the call to StatsD to use
ast_statsd_log_string() so that a "+" could be sent to StatsD.

ASTERISK-25619 #close

Change-Id: Iaaeff5c4c6a46535366b4d16ea0ed0ee75ab2ee7

3 years agoMerge "chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)"
Matt Jordan [Wed, 9 Dec 2015 18:40:58 +0000 (12:40 -0600)]
Merge "chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)"

3 years agores_pjsip: Add existence and readablity checks for tls related files
George Joseph [Tue, 8 Dec 2015 23:49:20 +0000 (16:49 -0700)]
res_pjsip:  Add existence and readablity checks for tls related files

Both transport and endpoint now check for the existence and readability
of tls certificate and key files before passing them on to pjproject.
This will cause the object to not load rather than waiting for pjproject
to discover that there's a problem when a session is attempted.

NOTE: chan_sip also uses ast_rtp_dtls_cfg_parse but it's located
in build_peer which is gigantic and I didn't want to disturb it.
Error messages will emit but it won't interrupt chan_sip loading.

ASTERISK-25618 #close

Change-Id: Ie43f2c1d653ac1fda6a6f6faecb7c2ebadaf47c9
Reported-by: George Joseph
Tested-by: George Joseph

3 years agochan_sip.c: Start ICE negotiation when response is sent or received.
Eugene Voityuk [Wed, 2 Dec 2015 18:42:15 +0000 (20:42 +0200)]
chan_sip.c: Start ICE negotiation when response is sent or received.

The current logic for ICE negotiation starts it
when receiving an SDP with ICE candidates. This is
incorrect as ICE negotiation can only start when each
call party have at least one pair of local and remote
candidate. Starting ICE negotiation early would result
in negotiation failure and ultimately no audio.

This change makes it so ICE negotiation is only started
when a response with SDP is received or when a response
with SDP is sent.

ASTERISK-24146

Change-Id: I55a632bde9e9827871b09141d82747e08379a8ca

3 years agoMerge "res_pjsip/config_transport: Prevent async_operations > 1 when protocol = tls"
Joshua Colp [Tue, 8 Dec 2015 19:18:08 +0000 (13:18 -0600)]
Merge "res_pjsip/config_transport: Prevent async_operations > 1 when protocol = tls"

3 years agoMerge "translate: Avoid a warning message when doing FEC within Opus Codec."
Joshua Colp [Tue, 8 Dec 2015 19:14:21 +0000 (13:14 -0600)]
Merge "translate: Avoid a warning message when doing FEC within Opus Codec."

3 years agochan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)
Filip Jenicek [Tue, 8 Dec 2015 07:57:22 +0000 (08:57 +0100)]
chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)

Asterisk may crash when calling ast_channel_get_t38_state(c)
on a locked channel which is being hung up.

ASTERISK-25609 #close

Change-Id: Ifaa707c04b865a290ffab719bd2e5c48ff667c7b

3 years agores_pjsip/config_transport: Prevent async_operations > 1 when protocol = tls
George Joseph [Tue, 8 Dec 2015 17:03:53 +0000 (10:03 -0700)]
res_pjsip/config_transport: Prevent async_operations > 1 when protocol = tls

See ASTERISK-25615.
If the transport protocol is tls and async_operations > 1, pjproject
will segfault if more than one operation is attempted on the same socket.
Until this is fixed upstream, a check has been added to throw an error
if a tls transport config has async_operations set to > 1.

ASTERISK-25615

Change-Id: I76b9a5b2a5a0054fe71ca5851e635f2dca7685a6
Reported-by: George Joseph
Tested-by: George Joseph

3 years agocodec_resample: Increase buffer for Opus Codec with FEC.
Alexander Traud [Tue, 8 Dec 2015 14:39:03 +0000 (15:39 +0100)]
codec_resample: Increase buffer for Opus Codec with FEC.

ASTERISK-25599 #close

Change-Id: Idbd187f711b2ec63dda949ca0f79aa0c1a0a0b6e

3 years agotranslate: Avoid a warning message when doing FEC within Opus Codec.
Alexander Traud [Tue, 8 Dec 2015 09:46:21 +0000 (10:46 +0100)]
translate: Avoid a warning message when doing FEC within Opus Codec.

ASTERISK-25616 #close

Change-Id: Ibe729aaf2e6e25506cff247cec5149ec1e589319

3 years agochan_sip: Fix crash involving the bogus peer during sip reload.
Richard Mudgett [Fri, 4 Dec 2015 21:36:45 +0000 (15:36 -0600)]
chan_sip: Fix crash involving the bogus peer during sip reload.

A crash happens sometimes when performing a CLI "sip reload".  The bogus
peer gets refreshed while it is in use by a new call which can cause the
crash.

* Protected the global bogus peer object with an ao2 global object
container.

ASTERISK-25610 #close

Change-Id: I5b528c742195681abcf713c6e1011ea65354eeed

3 years agochan_sip: Support parsing of Q.850 reason header in SIP BYE and CANCEL requests.
Christof Lauber [Fri, 13 Nov 2015 13:58:15 +0000 (14:58 +0100)]
chan_sip: Support parsing of Q.850 reason header in SIP BYE and CANCEL requests.

Current support for reason header did work only in SIP responses.
According to RFC3336 the reason header might appear in any SIP request.
But it seems to make most sence in BYE and CANCEL so parasing is done
there too (if use_q850_reason=yes).

Change-Id: Ib6be7b34c23a76d0e98dfd0816c89931000ac790

3 years agoMerge "res_pjsip/contacts/statsd: Make contact lifecycle events more consistent"
Joshua Colp [Mon, 7 Dec 2015 13:51:20 +0000 (07:51 -0600)]
Merge "res_pjsip/contacts/statsd:  Make contact lifecycle events more consistent"

3 years agoRevert "bridges/bridge_t38: Add a bridging module for managing T.38 state"
Matt Jordan [Sun, 6 Dec 2015 22:35:24 +0000 (16:35 -0600)]
Revert "bridges/bridge_t38: Add a bridging module for managing T.38 state"

This reverts commit f42d22d3a1ca5c8ea73df99a50c6a28caa8f8749.

Unfortunately, using a bridge to manage T.38 state will cause severe deadlocks
in core_unreal/chan_local. Local channels attempt to reach across both their
peer and the peer's bridge to inspect T.38 state. Given the propensity of
Local channel chains, managing the locking situation in such a scenario is
practically infeasible.

Change-Id: I932107387c13aad2c75a7a4c1e94197a9d6d8a51

4 years agores_pjsip/contacts/statsd: Make contact lifecycle events more consistent
George Joseph [Fri, 4 Dec 2015 22:23:21 +0000 (15:23 -0700)]
res_pjsip/contacts/statsd:  Make contact lifecycle events more consistent

It will never be perfect or even pretty, mostly because of the differences
between static and dynamic contacts.

Created:

Can't use the contact or contact_status alloc functions
because the objects come and go regardless of the actual state.

Can't use the contact_apply_handler, ast_sip_location_add_contact or
a sorcery created handler because they only get called for dynamic
contacts.  Similarly, permanent_uri_handler only gets called for
static contacts.

So, Matt had it right. :)  ast_res_pjsip_find_or_create_contact_status is
the only place it can go and not have duplicated code.  Both
permanent_uri_handler and contact_apply_handler call find_or_create.

Removed:

Can't use the destructors for the same reason as above.  The only
place to put this is in persistent_endpoint_contact_deleted_observer
which I believe is the "correct" place but even that will handle only
dynamic contacts.  This doesn't called on shutdown however.  There is
no hook to use for static contacts that may be removed because of a
config change while asterisk is in operation.

I moved the cleanup of contact_status from ast_sip_location_delete_contact
to the handler as well.

Status Change and RTT:

Although they worked fine where they were (in update_contact_status) I
moved them to persistent_endpoint_contact_status_observer to make it
more consistent with removed.  There was logic there already to detect
a state change.

Finally, fixed a nit in permanent_uri_handler rmudgett reported
eralier.

ASTERISK-25608 #close

Change-Id: I4b56e7dfc3be3baaaf6f1eac5b2068a0b79e357d
Reported-by: George Joseph
Tested-by: George Joseph

4 years agoMerge "res_format_attr_vp8: In SDP, forward max-fr and max-fs for video-codec VP8."
Matt Jordan [Fri, 4 Dec 2015 17:34:15 +0000 (11:34 -0600)]
Merge "res_format_attr_vp8: In SDP, forward max-fr and max-fs for video-codec VP8."

4 years agoMerge "res_format_attr_opus: Update to latest RFC 7587."
Matt Jordan [Fri, 4 Dec 2015 17:34:04 +0000 (11:34 -0600)]
Merge "res_format_attr_opus: Update to latest RFC 7587."

4 years agores_format_attr_vp8: In SDP, forward max-fr and max-fs for video-codec VP8.
Alexander Traud [Sat, 21 Nov 2015 12:08:49 +0000 (13:08 +0100)]
res_format_attr_vp8: In SDP, forward max-fr and max-fs for video-codec VP8.

ASTERISK-25584 #close

Change-Id: Iae00071b4ff1ae76f24995aeac4d00284fd14f91

4 years agoMerge "bridges/bridge_t38: Add a bridging module for managing T.38 state"
Matt Jordan [Fri, 4 Dec 2015 14:58:05 +0000 (08:58 -0600)]
Merge "bridges/bridge_t38: Add a bridging module for managing T.38 state"

4 years agobridges/bridge_t38: Add a bridging module for managing T.38 state
Matt Jordan [Sat, 28 Nov 2015 14:46:02 +0000 (08:46 -0600)]
bridges/bridge_t38: Add a bridging module for managing T.38 state

When 4875e5ac32 was merged, it fixed several issues with a direct media bridge
transitioning to handling a T.38 fax. However, it uncovered a race condition
caused by the bridging core. When a channel involved in a T.38 fax leaves a
bridge, the frame queued by the channel driver that should inform the far side
that it is no longer in a T.38 fax may not make it across the bridge. The
bridging framework is *extremely* aggressive in tearing down the bridge, and
control frames that are currently in flight *may* get dropped.

This patch adds a new module to the bridging framework, bridge_t38. This module
maintains some notion of the T.38 state for the two channels in a bridge. When
the bridge detects that it is being torn down or when one of the two channels
leaves, it informs the respective channel(s) that they should stop faxing. This
ensures that channels switch back to audio if they survive and are ejected out
of a bridge while faxing.

ASTERISK-25582

Change-Id: If5b0bb478eb01c4607c9f4a7fc17c7957d260ea0

4 years agoMerge "Fix crash in audiohook translate to slin"
Matt Jordan [Fri, 4 Dec 2015 13:31:10 +0000 (07:31 -0600)]
Merge "Fix crash in audiohook translate to slin"

4 years agores_format_attr_opus: Update to latest RFC 7587.
Alexander Traud [Sat, 21 Nov 2015 11:35:33 +0000 (12:35 +0100)]
res_format_attr_opus: Update to latest RFC 7587.

Beside that, the format-attribute module sends only non-default values in the
line fmtp, now. This avoids unnecessary overhead in SDP messages. Furthermore,
previously the parameter stereo was not parsed when being the first parameter.

ASTERISK-25583 #close

Change-Id: Iae85ba3e5960bfd5d51cf65bcffad00dd4875a73

4 years agoMerge "res_pjsip: Use a MD5 hash for static Contact IDs"
Joshua Colp [Thu, 3 Dec 2015 21:51:56 +0000 (15:51 -0600)]
Merge "res_pjsip: Use a MD5 hash for static Contact IDs"

4 years agoFix crash in audiohook translate to slin
Jonathan Rose [Wed, 2 Dec 2015 20:11:08 +0000 (14:11 -0600)]
Fix crash in audiohook translate to slin

This patch fixes a crash which would occur when an audiohook was
applied to a channel using an audio codec that could not be translated
to signed linear (such as when using pass-through codecs like OPUS or
when the codec translator module for the format in use is not loaded).

ASTERISK-25498 #close
Reported by: Ben Langfeld

Change-Id: Ib6ea7373fcc22e537cad373996136636201f4384

4 years agoMerge "res_pjsip: Update logging to show contact->uri in messages"
Joshua Colp [Thu, 3 Dec 2015 18:39:00 +0000 (12:39 -0600)]
Merge "res_pjsip:  Update logging to show contact->uri in messages"

4 years agoMerge "app_queue: Show reason of pause on CLI"
Joshua Colp [Thu, 3 Dec 2015 18:38:28 +0000 (12:38 -0600)]
Merge "app_queue: Show reason of pause on CLI"

4 years agoMerge "codec_resample: Increase buffer for Opus Codec."
Joshua Colp [Thu, 3 Dec 2015 18:38:01 +0000 (12:38 -0600)]
Merge "codec_resample: Increase buffer for Opus Codec."

4 years agores_pjsip: Use a MD5 hash for static Contact IDs
George Joseph [Thu, 3 Dec 2015 18:07:49 +0000 (11:07 -0700)]
res_pjsip: Use a MD5 hash for static Contact IDs

When 90d9a70789 was merged, it mostly tested dynamic contacts created as
a result of registering a PJSIP endpoint. Contacts generated in this
fashion typically have a long alphanumeric string as their object identifier,
which maps reasonably well for StatsD. Unfortunately, this doesn't work in the
general case. StatsD treats both '.' and ':' characters as special characters.
In particular, having a ':' appear in the middle of a StatsD metric will
result in the metric being rejected.

This causes some obvious issues with SIP URIs.

The StatsD API should not be responsible for escaping the metric name passed
to it. The metric is treated as a single long string, and it would be
challenging to know what to escape in the string passed to the function.
Likewise, we don't want to escape the metric in PJSIP, as that involves
overhead that is wasted when either res_statsd isn't loaded or enabled.

This patch takes an alternative approach. The Contact ID has been changed
to be "aor@@uri_hash" instead of "aor@@uri". This (a) won't contain any of the
aforementioned special characters, (b) can be done on Contact creation,
which has minimal impact on run-time performance, and (c) also conforms to an
earlier commit that changed the ID for dynamic contacts.

The downside of this is that StatsD users will have to map SHA1 hashes back to
the Contacts that are emitting the statistics. To that end, the CLI commands
have been updated to include the first 10 characters of the MD5 hash, which
should be enough to match what is shown in Graphite (or some other StatsD
backend).

ASTERISK-25595 #close

Change-Id: Ic674a3307280365b4a45864a3571c295b48a01e2
Reported-by: Matt Jordan
Tested-by: George Joseph

4 years agoMerge "Build System: Support include-what-you-use."
Joshua Colp [Thu, 3 Dec 2015 11:52:18 +0000 (05:52 -0600)]
Merge "Build System: Support include-what-you-use."

4 years agoMerge "res_sorcery_memory_cache.c: Fix off nominal ref leak."
Joshua Colp [Thu, 3 Dec 2015 11:51:23 +0000 (05:51 -0600)]
Merge "res_sorcery_memory_cache.c: Fix off nominal ref leak."

4 years agoMerge "sched.c: Make not return a sched id of 0."
Joshua Colp [Thu, 3 Dec 2015 11:50:50 +0000 (05:50 -0600)]
Merge "sched.c: Make not return a sched id of 0."

4 years agoMerge "Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)"
Joshua Colp [Thu, 3 Dec 2015 11:49:38 +0000 (05:49 -0600)]
Merge "Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)"

4 years agoMerge "Audit improper usage of scheduler exposed by 5c713fdf18f."
Joshua Colp [Thu, 3 Dec 2015 11:49:27 +0000 (05:49 -0600)]
Merge "Audit improper usage of scheduler exposed by 5c713fdf18f."

4 years agores_pjsip: Update logging to show contact->uri in messages
George Joseph [Tue, 1 Dec 2015 04:19:18 +0000 (21:19 -0700)]
res_pjsip:  Update logging to show contact->uri in messages

An earlier commit changed the id of dynamic contacts to contain
a hash instead of the uri.  This patch updates status change
logging to show the aor/uri instead of the id.  This required
adding the aor id to contact and contact_status and adding
uri to contact_status.  The aor id gets added to contact and
contact_status in their allocators and the uri gets added to
contact_status in pjsip_options when the contact_status is
created or updated.

ASTERISK-25598 #close

Reported-by: George Joseph
Tested-by: George Joseph

Change-Id: I56cbec1d2ddbe8461367dd8b6da8a6f47f6fe511

4 years agoUnset BRIDGEPEER when leaving a bridge
Jonathan Rose [Tue, 1 Dec 2015 22:11:07 +0000 (16:11 -0600)]
Unset BRIDGEPEER when leaving a bridge

Currently if a channel is transferred out of a bridge, the BRIDGEPEER
variable (also BRIDGEPVTCALLID) remain set even once the channel is
out of the bridge. This patch removes these variables when leaving
the bridge.

ASTERISK-25600 #close
Reported by: Mark Michelson

Change-Id: I753ead2fffbfc65427ed4e9244c7066610e546da

4 years agores_sorcery_memory_cache.c: Fix off nominal ref leak.
Richard Mudgett [Mon, 30 Nov 2015 20:22:55 +0000 (14:22 -0600)]
res_sorcery_memory_cache.c: Fix off nominal ref leak.

Change-Id: If83d63cf11cbc6df9b15251848b01feb570ade49

4 years agosched.c: Make not return a sched id of 0.
Richard Mudgett [Mon, 30 Nov 2015 22:42:47 +0000 (16:42 -0600)]
sched.c: Make not return a sched id of 0.

According to the API doxygen a sched ID of 0 is valid.  Unfortunately, 0
was never returned historically and several users incorrectly coded usage
of the returned sched ID assuming that 0 was invalid.

ASTERISK-25476

Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20

4 years agoAudit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)
Richard Mudgett [Wed, 25 Nov 2015 18:23:47 +0000 (12:23 -0600)]
Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)

chan_sip.c:
* Initialize mwi subscription scheduler ids earlier because of ASTOBJ to
ao2 conversion.

* Initialize register scheduler ids earlier because of ASTOBJ to ao2
conversion.

chan_skinny.c:
* Fix more scheduler usage for the valid 0 id value.

ASTERISK-25476

Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95

4 years agoAudit improper usage of scheduler exposed by 5c713fdf18f.
Richard Mudgett [Tue, 24 Nov 2015 18:44:53 +0000 (12:44 -0600)]
Audit improper usage of scheduler exposed by 5c713fdf18f.

channels/chan_iax2.c:
* Initialize struct chan_iax2_pvt scheduler ids earlier because of
iax2_destroy_helper().

channels/chan_sip.c:
channels/sip/config_parser.c:
* Fix initialization of scheduler id struct members.  Some off nominal
paths had 0 as a scheduler id to be destroyed when it was never started.

chan_skinny.c:
* Fix some scheduler id comparisons that excluded the valid 0 id.

channel.c:
* Fix channel initialization of the video stream scheduler id.

pbx_dundi.c:
* Fix channel initialization of the packet retransmission scheduler id.

ASTERISK-25476

Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8

4 years agocodec_resample: Increase buffer for Opus Codec.
Alexander Traud [Tue, 1 Dec 2015 13:55:13 +0000 (14:55 +0100)]
codec_resample: Increase buffer for Opus Codec.

ASTERISK-25599 #close

Change-Id: I1f88a88c59fb4e1e62bbdbb100c7152d48e73f10

4 years agodns: Change lookup failures from LOG_ERROR to debug 1.
George Joseph [Mon, 30 Nov 2015 17:13:35 +0000 (10:13 -0700)]
dns: Change lookup failures from LOG_ERROR to debug 1.

dns.c and dns_system_resolver.c were spitting out errors for lookup
failures for things like not finding a SRV record even though
there was an A record.  Those have been changed to debug messages.
Logging not finding ANY record is left to the higher level caller.

Also, dns_system_resolver was using Windows line endings so I
converted them to Unix style.  The actual log changes are on lines
156 and 159.

Change-Id: I65be16ea15304b96f9dcb4d289dbd3e2286fc094

4 years agoBuild System: Support include-what-you-use.
Alexander Traud [Wed, 25 Nov 2015 16:42:31 +0000 (17:42 +0100)]
Build System: Support include-what-you-use.

ASTERISK-25591 #close

Change-Id: I8d3efa0826142ece9cbed2fd0d46f3b607fee6ae

4 years agoapp_queue: Show reason of pause on CLI
Rodrigo Ramírez Norambuena [Mon, 9 Nov 2015 05:49:08 +0000 (02:49 -0300)]
app_queue: Show reason of pause on CLI

Add value of pause reason when is paused on CLI command "queue show"

ASTERISK-25581 #close

Report by: Rodrigo Ramírez Norambuena

Change-Id: I887028a40cd97b350da9a3bb2719616b7fec9864

4 years agoCHANGES: Fix a typo
Niklas Larsson [Fri, 27 Nov 2015 13:39:22 +0000 (14:39 +0100)]
CHANGES: Fix a typo

Change-Id: Iceb3d9bb78140c376174a7bee197dfcf8ef9cda7

4 years agoMerge "fastagi: record file closed after sending result"
Matt Jordan [Thu, 26 Nov 2015 04:19:18 +0000 (22:19 -0600)]
Merge "fastagi: record file closed after sending result"

4 years agoMerge "main: Slight refactor of main. Improve color situation."
Matt Jordan [Thu, 26 Nov 2015 04:17:47 +0000 (22:17 -0600)]
Merge "main: Slight refactor of main. Improve color situation."

4 years agofastagi: record file closed after sending result
Kevin Harwell [Wed, 25 Nov 2015 21:26:35 +0000 (15:26 -0600)]
fastagi: record file closed after sending result

The fastagi record-file testsuite test sometimes fails reporting an empty
recorded file. This was happening because Asterisk was sending the agi result
notification prior to actually closing the file and the data, being buffered,
had not been written to the file yet when the test attempts to check the file
size.

This patch makes it so the record file stream is closed prior to sending the
agi result notification.

ASTERISK-25593 #close

Change-Id: I6b2b3be3ae37f7c7b18e672c419a89b3b8513cde

4 years agomain: Slight refactor of main. Improve color situation.
Walter Doekes [Wed, 25 Nov 2015 19:29:55 +0000 (20:29 +0100)]
main: Slight refactor of main. Improve color situation.

Several issues are addressed here:
- main() is large, and half of it is only used if we're not rasterisk;
  fixed by spliting up the daemon part into a separate function.
- Call ast_term_init from rasterisk as well.
- Remove duplicate code reading/writing asterisk history file.
- Attempt to tackle background color issues and color changes that
  occur. Tested by starting asterisk -c until the colors stopped
  changing at odd locations.
- Remove unused term_prep() and term_prompt() functions.

ASTERISK-25585 #close

Change-Id: Ib641a0964c59ef9fe6f59efa8ccb481a9580c52f

4 years agoMerge "Fixed some typos"
Matt Jordan [Wed, 25 Nov 2015 02:23:10 +0000 (20:23 -0600)]
Merge "Fixed some typos"

4 years agoFixed some typos
David M. Lee [Tue, 24 Nov 2015 19:54:54 +0000 (13:54 -0600)]
Fixed some typos

Fixes some minor typos in the CHANGES file, plus an embarrasing typo in
the StatsD API.

Change-Id: I9ca4858c64a4a07d2643b81baa64baebb27a4eb7

4 years agores_pjsip_notify: Fix CLI usage info
Corey Farrell [Tue, 24 Nov 2015 19:07:12 +0000 (14:07 -0500)]
res_pjsip_notify: Fix CLI usage info

The usage info for 'pjsip send notify' previously referenced the
chan_sip configuration sip_notify.conf.  Fix this to reference
the correct configuration pjsip_notify.conf.

ASTERISK-25590 #close

Change-Id: I3898271a8e8a8b1db201741e790ebe2c6bf5cdea

4 years agoMerge "translate: Provide translation modules the result of SDP negotiation."
Joshua Colp [Tue, 24 Nov 2015 14:20:46 +0000 (08:20 -0600)]
Merge "translate: Provide translation modules the result of SDP negotiation."

4 years agoMerge "res/res_endpoint_stats: Add module to emit endpoint StatsD statistics"
Matt Jordan [Tue, 24 Nov 2015 00:55:16 +0000 (18:55 -0600)]
Merge "res/res_endpoint_stats: Add module to emit endpoint StatsD statistics"

4 years agores/res_endpoint_stats: Add module to emit endpoint StatsD statistics
Matt Jordan [Wed, 18 Nov 2015 15:43:08 +0000 (09:43 -0600)]
res/res_endpoint_stats: Add module to emit endpoint StatsD statistics

This patch adds a module that emits StatsD statistics about Asterisk
endpoints. This includes:
 * A GAUGE statistic for endpoint states, tracking how many endpoints are in
   a particular state.
 * A GAUGE statistic for each endpoint, counting the number of channels
   currently associated with an endpoint.

ASTERISK-25572

Change-Id: If7e1333c5aeda8d136850b30c2101c0ee1c97305

4 years agores_sorcery_realtime.c: Fix crash from NULL sorcery object type.
Richard Mudgett [Mon, 23 Nov 2015 20:27:27 +0000 (14:27 -0600)]
res_sorcery_realtime.c: Fix crash from NULL sorcery object type.

If the sorcery object type is not found a NULL is returned.
Unfortunately, sorcery_realtime_filter_objectset() will crash after
complaining about not finding the object type and saying to expect errors.

* Use ao2_cleanup() instead of ao2_ref() to prevent the crash.

ASTERISK-25165
Reported by Corey Farrell

Change-Id: Ic3b64453ea3058cb68d5c26d97d4fe7b8eea2e97

4 years agoMerge "chan_pjsip: Handle T.38 faxes with direct media bridges"
Matt Jordan [Mon, 23 Nov 2015 19:33:04 +0000 (13:33 -0600)]
Merge "chan_pjsip: Handle T.38 faxes with direct media bridges"

4 years agoMerge "res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts"
Matt Jordan [Mon, 23 Nov 2015 15:26:40 +0000 (09:26 -0600)]
Merge "res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts"

4 years agores_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts
Matt Jordan [Wed, 18 Nov 2015 16:07:09 +0000 (10:07 -0600)]
res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts

This patch adds the ability to send StatsD statistics related to the
state of PJSIP contacts. This includes:
 * A GUAGE statistic measuring the count of contacts in a particular state.
   This measures how many contacts are reachable, unreachable, etc.
 * The RTT time for each contact, if those contacts are qualified. This
   provides StatsD engines useful time-based data about each contact.

ASTERISK-25571

Change-Id: Ib8378d73afedfc622be0643b87c542557e0b332c

4 years agores/res_pjsip_outbound_registration: Add registration statistics for StatsD
Matt Jordan [Fri, 13 Nov 2015 16:34:03 +0000 (10:34 -0600)]
res/res_pjsip_outbound_registration: Add registration statistics for StatsD

This patch adds outbound registration statistics for StatsD. This includes
the following:
 * A GUAGE metric for the overall count of outbound registrations.
 * A GUAGE metric for each state an outbound registration can be in. As the
   outbound registrations change state, the overall count of how many
   outbound registrations are in the particular state is changed.

These statistics are particularly useful for systems with a large number of
SIP trunks, and where measuring the change in state of the trunks is useful
for monitoring.

ASTERISK-25571

Change-Id: Iba6ff248f5d1c1e01acbb63e9f0da1901692eb37

4 years agores_statsd: Add functions that support variable arguments
Matt Jordan [Wed, 18 Nov 2015 16:05:07 +0000 (10:05 -0600)]
res_statsd: Add functions that support variable arguments

Often, the metric names of statistics we are generating for StatsD have some
dynamic component to them. This can be the name of a particular resource, or
some internal status label in Asterisk. With the current set of functions,
callers of the statsd API must first build the metric name themselves, then
pass this to the API functions. This results in a large amount of boilerplate
code and usage of either fixed length static buffers or dynamic memory
allocation, neither of which is desireable.

This patch adds two new functions to the StatsD API that support a printf
style format specifier for constructing the metric name. A dynamic string,
allocated in threadstorage, is used to build the metric name. This eases
the burden on users of the StatsD API.

Change-Id: If533c72d1afa26d807508ea48b4d8c7b32f414ea

4 years agochan_pjsip: Handle T.38 faxes with direct media bridges
Matt Jordan [Sat, 21 Nov 2015 03:08:49 +0000 (21:08 -0600)]
chan_pjsip: Handle T.38 faxes with direct media bridges

When a channel is in a direct media bridge, a re-INVITE may arrive that forces
Asterisk to re-negotiate the media to a T.38 fax. When this occurs, the bridge
must change its technology to a simple bridge, and re-INVITE the media back
to Asterisk.

Generally, this logic mostly already exists in Asterisk. However, prior to this
patch, there were a few bugs:
(1) The T.38 framehook currently prevents a channel capable of T.38 faxes from
    ever entering into a direct media bridge. This applies even when the only
    media being passed over the channel is audio. This patch fixes this bug
    by having the framehook specify that it defers caring about any frame type.
    This allows the channels to enter into a direct media bridge, which will
    be broken when a re-INVITE is received.
(2) When a re-INVITE is received, nothing instructed the bridging layer to
    re-inspect the allowed bridging technology. This now occurs when either
    a re-INVITE is received from a peer, or when a response is received from
    the far end (that is, when the T.38 state changes to either
    T38_PEER_REINVITE or T38_LOCAL_REINVITE).
(3) chan_pjsip needs to do a small amount of work to prevent a direct media
    bridge from being chosen when a T.38 session is in progress. When a T.38
    session supplement has a t38 datastore - which is added when we detect
    we should start thinking about T.38 on a channel - we now refuse a native
    RTP bridge.
(4) When a BYE request is received, we don't terminate the T.38 session. If
    the other side of a T.38 fax survives the hangup (due to the 'g' flag
    in Dial, for example), we don't currently re-INVITE the media on the
    other channel back to audio. This patch now has res_pjsip_t38 intercept
    BYE requests and inform the far side that the T.38 session is terminated.
    This naturally causes the correct re-INVITEs to be sent.

ASTERISK-25582

Change-Id: Iabd6aa578e633d16e6b9f342091264e4324a79eb

4 years agoMerge "main/cli: Use proper string methods to check existence of context/exten/app"
Joshua Colp [Sat, 21 Nov 2015 17:36:42 +0000 (11:36 -0600)]
Merge "main/cli: Use proper string methods to check existence of context/exten/app"

4 years agoMerge "res/res_pjsip_t38: Add debug statements"
Joshua Colp [Sat, 21 Nov 2015 17:14:04 +0000 (11:14 -0600)]
Merge "res/res_pjsip_t38: Add debug statements"

4 years agoMerge "res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts."
Matt Jordan [Sat, 21 Nov 2015 16:57:16 +0000 (10:57 -0600)]
Merge "res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts."

4 years agomain/cli: Use proper string methods to check existence of context/exten/app
Matt Jordan [Thu, 22 Oct 2015 14:44:43 +0000 (09:44 -0500)]
main/cli: Use proper string methods to check existence of context/exten/app

Because the context, extension, and application are stored in stringfields,
checking for them being NULL doesn't work so well. This patch uses the
appropriate string library call, ast_strlen_zero, to see if there is a value
in the context/exten/app values.

Change-Id: Ie09623bfdf35f5a8d3b23dd596647fe3c97b9a23

4 years agores/res_pjsip_t38: Add debug statements
Matt Jordan [Sat, 21 Nov 2015 03:07:27 +0000 (21:07 -0600)]
res/res_pjsip_t38: Add debug statements

This patch adds some debug statements to res_pjsip_t38. These statements help
to determine which SDP negotiation callbacks are being executed, and, when
a particular callback exits, why a callback may not have applied its logic
to the local or remote SDP.

Change-Id: I61b3fb9183b7ebbb5da8e9f48b59a5d9d7042d77

4 years agoMerge "res_pjsip_outbound_registration.c: Fix 423 response handling."
Mark Michelson [Fri, 20 Nov 2015 19:03:35 +0000 (13:03 -0600)]
Merge "res_pjsip_outbound_registration.c: Fix 423 response handling."

4 years agoMerge "res_format_attr_h264: Do not reset string buffer."
Joshua Colp [Fri, 20 Nov 2015 15:20:43 +0000 (09:20 -0600)]
Merge "res_format_attr_h264: Do not reset string buffer."

4 years agoMerge "res/res_pjsip_outbound_registration: Apply configuration on object type load"
Matt Jordan [Fri, 20 Nov 2015 12:15:48 +0000 (06:15 -0600)]
Merge "res/res_pjsip_outbound_registration: Apply configuration on object type load"

4 years agoMerge "StatsD: Add sample rate compatibility"
Joshua Colp [Thu, 19 Nov 2015 16:27:07 +0000 (10:27 -0600)]
Merge "StatsD: Add sample rate compatibility"

4 years agores/res_pjsip_outbound_registration: Apply configuration on object type load
Matt Jordan [Thu, 19 Nov 2015 15:40:24 +0000 (09:40 -0600)]
res/res_pjsip_outbound_registration: Apply configuration on object type load

When Asterisk is configured to use a dynamic sorcery backend (such as
res_sorcery_astdb) with 'registration' objects, it will fail to create the
internal state objects associated with the registration objects on module
load. This is due to nothing actually querying for the specific objects
and calling their sorcery apply handler during module load.

This patch fixes that by calling get_registrations in the sorcery observer's
object_type_loaded handler. Doing this causes the sorcery backends to be
asked for the current state of all registration objects, which causes the
apply handler to be called and the internal run-time state to be created.

ASTERISK-25575 #close

Change-Id: Ie9306e797098c6d4da7bcf4a5434a15891508b23

4 years agotranslate: Provide translation modules the result of SDP negotiation.
Alexander Traud [Wed, 11 Nov 2015 12:29:24 +0000 (13:29 +0100)]
translate: Provide translation modules the result of SDP negotiation.

Previously, a trancoding module did not have access to the joint but cached
format. Therefore, the module did not have access to the attributes negotiated
via SDP (line fmtp). Now, a translation module receives the joint format.

ASTERISK-25545 #close

Change-Id: Id6878a989b50573298dab115d3371ea369e1a718

4 years agores_format_attr_h264: Do not reset string buffer.
Alexander Traud [Thu, 19 Nov 2015 07:03:54 +0000 (08:03 +0100)]
res_format_attr_h264: Do not reset string buffer.

When no parameter is present, Asterisk does not generate the line fmtp, as
expected. However, because a buffer was reset, even rtpmap and fmtp of previous
media codecs got removed. Now, Asterisk does not reset other codecs in case of
no parameter for H.264.

ASTERISK-25573 #close

Change-Id: I93811331f4a28c45418a9e14ee46c0debd47a286

4 years agoMerge "app_bridgeaddchan: ability to barge into existing call"
Matt Jordan [Thu, 19 Nov 2015 03:30:49 +0000 (21:30 -0600)]
Merge "app_bridgeaddchan: ability to barge into existing call"

4 years agoapp_bridgeaddchan: ability to barge into existing call
Alec Davis [Wed, 18 Nov 2015 08:25:15 +0000 (21:25 +1300)]
app_bridgeaddchan: ability to barge into existing call

To be able to barge into a call by dialling a prefix+extension that maps
to the extensions device.

Senario is that DECT headset users may be away from their desks and need
to transfer the call, the goal is that from any phone they dial a prefix
then their extension and are added to the bridge that they are in, from
there they can drop the headset call, as it's also on the handset,
and transfer the caller.

The dialplan would look like, where prefix=73, extension = 8512;
exten => _738512,1,BridgeAdd(SIP/cisco0001)

ASTERISK-25551 #close
Reported By: Alec Davis

Change-Id: I8eb5096a02168dcc8d7aeea416ef36ba4ed10540

4 years agoStatsD: Add sample rate compatibility
tcambron [Thu, 5 Nov 2015 21:37:59 +0000 (15:37 -0600)]
StatsD: Add sample rate compatibility

Implemented support for the StatsD sample rate parameter,
which is a parameter for determining when to send computed
statistics to a client.

Valid sample rate values are:
Less than or equal to 0.0 will never be sent.
Between 0.0 and 1.0 will randomly be sent.
Greater than or equal to 1.0 will always be sent.

ASTERISK-25419
Reported By: Ashley Sanders

Change-Id: I11d315d0a5034fffeae1178e650aa8264485ed52

4 years agores_pjsip_outbound_registration.c: Be tolerant of short registration timeouts.
Richard Mudgett [Tue, 17 Nov 2015 20:53:19 +0000 (14:53 -0600)]
res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts.

Change-Id: Ie16f5053ebde0dc6507845393709b4d6a3ea526d

4 years agores_pjsip_outbound_registration.c: Fix 423 response handling.
Richard Mudgett [Tue, 17 Nov 2015 20:53:57 +0000 (14:53 -0600)]
res_pjsip_outbound_registration.c: Fix 423 response handling.

Receiving a 423 Interval Too Brief response after authentication for an
outbound registration attempt results in assuming that the registrar has
rejected the registration permanently.  If there are no configured retries
for fatal responses then the outbound registration is stopped for that
endpoint.

For registrations, PJSIP/PJPROJECT intercepts the handling of 423
responses and does not include any authentication in the updated
registration request.  When the updated request is challenged then the
Asterisk code assumes that we were challenged again because the peer
rejected the authentication we sent earlier.

* Made registration challenges keep track of the CSeq number to determine
if the received challenge response was for the request we thought we sent.
If the response's CSeq number differs from the CSeq number we last sent
with authentication then authenticate again because it is a challenge to a
different request.

Change-Id: I81b4bd36d1be095bab606e34b8b44e6302971b09

4 years agoMerge "res_pjsip_rfc3326.c: Fix crash when channel goes away."
Matt Jordan [Wed, 18 Nov 2015 13:33:57 +0000 (07:33 -0600)]
Merge "res_pjsip_rfc3326.c: Fix crash when channel goes away."

4 years agoapp_queue: (try_calling): mutex 'qe->chan' freed more times than we've locked!
Alec Davis [Wed, 18 Nov 2015 06:20:22 +0000 (19:20 +1300)]
app_queue: (try_calling): mutex 'qe->chan' freed more times than we've locked!

commit aae45acbd (Mark Michelson 2015-04-15 10:38:02 -0500 6525)
refer ASTERISK-24958

above commit removed ast_channel_lock(qe->chan);
but failed to remove corresponding ast_channel_unlock(qe->chan);

ASTERISK-25561 #close
Reported Alec Davis

Change-Id: Ie05f4e2d08912606178bf1fded57cc022c7a2e1a

4 years agoMerge "format: Register format-attribute module with cached formats."
Matt Jordan [Tue, 17 Nov 2015 20:35:22 +0000 (14:35 -0600)]
Merge "format: Register format-attribute module with cached formats."

4 years agoMerge "res/res_pjsip: Fix off nominal crash with requests that fail and have a timer"
Matt Jordan [Tue, 17 Nov 2015 18:59:35 +0000 (12:59 -0600)]
Merge "res/res_pjsip: Fix off nominal crash with requests that fail and have a timer"

4 years agoMerge "Confbridge: Add a user timeout option"
Joshua Colp [Tue, 17 Nov 2015 14:12:26 +0000 (08:12 -0600)]
Merge "Confbridge: Add a user timeout option"

4 years agodns: Fix pointer increment in dns_parse_answer_ex
George Joseph [Mon, 16 Nov 2015 22:10:20 +0000 (15:10 -0700)]
dns: Fix pointer increment in dns_parse_answer_ex

When dns_parse_answer_ex was iterating over the answers it
wasn't incrementing the answer pointer correctly after the first
answer.  The result was that no answers after the first
were being returned.  For results where multiple records should
have been sorted by priority, weight, etc., there was nothing
to sort so the only the first record was returned even if it
wouldn't have been the correct record based on the sort.

ASTERISK-25565 #close
Reported-by: Daniel Tryba
Tested-by George Joseph

Change-Id: I8622604fefdcd3c11e2c5609a6382e53b1467b0b

4 years agoConfbridge: Add a user timeout option
Mark Michelson [Fri, 13 Nov 2015 20:03:35 +0000 (14:03 -0600)]
Confbridge: Add a user timeout option

This option adds the ability to specify a timeout, in seconds, for a
participant in a ConfBridge. When the user's timeout has been reached,
the user is ejected from the conference with the CONFBRIDGE_RESULT
channel variable set to "TIMEOUT".

The rationale for this change is that there have been times where we
have seen channels get "stuck" in ConfBridge because a network issue
results in a SIP BYE not being received by Asterisk. While these
channels can be hung up manually via CLI/AMI/ARI, adding some sort of
automatic cleanup of the channels is a nice feature to have.

ASTERISK-25549 #close
Reported by Mark Michelson

Change-Id: I2996b6c5e16a3dda27595f8352abad0bda9c2d98

4 years agores/res_pjsip: Fix off nominal crash with requests that fail and have a timer
Matt Jordan [Mon, 16 Nov 2015 19:56:49 +0000 (13:56 -0600)]
res/res_pjsip: Fix off nominal crash with requests that fail and have a timer

When a request is sent using pjsip_endpt_send_request and fails, a condition
exists where the request wrapper, which is an AO2 object, may be de-ref'd
more times than it should. This occurs when the request's callback is called,
and, in the callback, the timer on the PJSIP heap is cancelled. When that
occurs, the request wrapper's lifetime is decremented. When
pjsip_endpt_send_request fails, we unilaterally decrement the lifetime of
the request wrapper again, even though we've already cancelled the reference
associated with the timer.

This patch checks the return result of pj_timer_heap_cancel_if_active before
removing the reference associated with the timer. We now only decrement it
in this case if a timer is cancelled as a result of the function call.

Change-Id: I21332343a1a019c1117076f9bf2df27be2850102

4 years agohashtab: Add NULL check when destroying iterator.
Joshua Colp [Sat, 14 Nov 2015 13:02:10 +0000 (09:02 -0400)]
hashtab: Add NULL check when destroying iterator.

The hashtab API is pretty NULL tolerant which has resulted
in remaining callers not doing much checks themselves.
Unfortunately the function to destroy an iterator does not
do a NULL check and will result in a crash if passed NULL.
This change fixes that.

ASTERISK-25552 #close

Change-Id: Ic1bf8eec3639e5a440f1c941d3ae3893ac6ed619