Commit Graph

27712 Commits

Author SHA1 Message Date
zuul
b0e71c6571 Merge "fix: memory leaks, resource leaks, out of bounds and bugs" into 13 2016-06-21 07:02:17 -05:00
zuul
9856b4afe0 Merge "app_voicemail.c: Fix IMAP compile error." into 13 2016-06-20 15:00:53 -05:00
Richard Mudgett
c1512f4108 app_voicemail.c: Fix IMAP compile error.
Fix compile error introduced by the patch for
ASTERISK-26045

Change-Id: I5b02876266f2824f4cec2b54d6ff4db5de5778d3
2016-06-20 12:17:08 -05:00
Alexei Gradinari
5134a8043a fix: memory leaks, resource leaks, out of bounds and bugs
ASTERISK-26119 #close

Change-Id: Iecbf7d0f360a021147344c4e83ab242fd1e7512c
2016-06-20 13:06:00 -04:00
Joshua Colp
fe8aab6959 Merge "http: leverage 'bindaddr' for TLS in http.conf" into 13 2016-06-20 12:03:45 -05:00
zuul
db91fb74db Merge "ARI: Ensure announcer channels are destroyed." into 13 2016-06-20 11:39:45 -05:00
Mark Michelson
cfebe3b94a ARI: Ensure announcer channels are destroyed.
Announcer channels were not being destroyed because the
stasis_app_control structure that referenced them was not being
destroyed. The control structure was not being destroyed because it was
not being unlinked from its container. It was not being unlinked from
its container because the after bridge callback for the announcer
channel was not being run. The after bridge callback was not being run
because the after bridge datastore was not being removed from the
channel on destruction. The channel was not being destroyed because the
hangup that used to destroy the channel was now only reducing the
reference count to one. The reference count of the channel was only
being reduced to one because the stasis_app_control structure was
holding the final reference...

The control structure used to not keep a reference to the channel, so
that loop described above did not happen.

The solution is to manually remove the control structure from its
container when the playback on a bridge is complete.

ASTERISK-26083 #close
Reported by Joshua Colp

Change-Id: I0ddc0f64484ea0016245800b409b567dfe85cfb4
2016-06-20 09:33:45 -05:00
Alexander Traud
76516bd79d http: leverage 'bindaddr' for TLS in http.conf
The internal HTTP/WebSocket server supports both TCP and TLS, which can be
activated separately via the file http.conf. The source code intends to re-use
the TCP parameter 'bindaddr' for TLS, even if 'tlsbindaddr' is not specified
explicitly. This did not work because of a typo. This change resolves this typo.

ASTERISK-26126 #close

Change-Id: I5efb0409ae12044dfb3495b6b97b6d40a8c9c51f
2016-06-20 08:10:10 -05:00
zuul
4d52b4c3e5 Merge "chan_sip: bigger buffers for headers, better failure mode" into 13 2016-06-16 17:21:51 -05:00
Vasil Kolev
89cc86fc38 chan_sip: bigger buffers for headers, better failure mode
Currently chan_sip can give weird messages if the contacts don't
fit in the From: or To: headers. This fix changes the from,to and
invite variables to use ast_str, allocates and deallocates them and
resizes them if needed.

ASTERISK-26069 #close

Change-Id: I1b68fcbddca6f6cc7d7a92fe1cb0d5430282b2b3
2016-06-16 14:47:08 -05:00
Richard Mudgett
d53a36ff33 res_pjsip_transport_management.c: Misc cleanups to survive shutdown.
* In unload_module(), reordered destroying things to minimize the window
that the global transports container could be used by other threads on
shutdown.  When shutting down you need to stop things in the opposite
order of creation.

* Put the global transports container into an AO2_GLOBAL_OBJ_STATIC to
eliminate the crash potential by other threads using the container on
shutdown.

* Made struct monitored_transport.sip_received not use
ast_atomic_fetchadd_int() since it is used as a boolean value that is only
set TRUE.  It was previously incremented for every received SIP message
and could theoretically overflow.

* In monitored_transport_state_callback(), allocated the monitored
transport object without a lock since the lock was unused.

* In keepalive_global_loaded(), removed releasing the transports container
if the keepalive_thread could not be started.  I set it up to be tried
again if the user reloads the configuration.

Change-Id: I8d12d16ef564290fa6d25a32334bb5ce8fdf87ff
2016-06-15 14:39:51 -05:00
Richard Mudgett
03953d8034 res_pjsip.c: Add check that timer actually got scheduled.
Change-Id: Iabaa2e5dccf0762c258101ea0eb1487cf6959ad1
2016-06-14 16:25:07 -05:00
zuul
97a8576d16 Merge "res_pjsip_session.c: Reorganize ast_sip_session_terminate()." into 13 2016-06-14 13:36:44 -05:00
Richard Mudgett
32ab98116e res_rtp_multicast.c: Fix warning message typo.
Change-Id: Ic9928208b9957e09866abe3d9649030942ec52b3
2016-06-13 13:33:53 -05:00
Joshua Colp
e80354caab Merge "chan_rtp: Backport changes from master." into 13 2016-06-13 11:59:31 -05:00
Joshua Colp
9c2664d624 Merge "chan_rtp.c: Copy file from chan_multicast_rtp.c" into 13 2016-06-13 11:59:19 -05:00
Richard Mudgett
0429c53368 res_pjsip_session.c: Reorganize ast_sip_session_terminate().
Change-Id: I68a2128bcba4830985d2d441e70dfd1ac5bd712b
2016-06-10 17:35:29 -05:00
Richard Mudgett
5823f279f3 chan_rtp: Backport changes from master.
* Deprecate chan_multicast_rtp.

Change-Id: Ib5a45e58c75ee8abd0b4f9575379b5321feb853e
2016-06-10 17:24:00 -05:00
Richard Mudgett
dde58df318 chan_rtp.c: Copy file from chan_multicast_rtp.c
Change-Id: I1119b53f2152ab1cbec74b5be7ea44844dbda8ef
2016-06-10 16:20:45 -05:00
Alexander Traud
ca38a3cbb4 core: Not the configured but granted number of possible file descriptors.
With CLI "core show settings", simply the parameter maxfiles of the file
asterisk.conf was shown. If that parameter was not set, nothing was displayed
although the environment might have set a default number itself. Or if maxfiles
were not granted (completely), still maxfiles was shown. Now, the maximum number
of possible file descriptors in the environment is shown.

ASTERISK-26097

Change-Id: I2df5c58863b5007b34b77adbe28b885dfcdf7e0b
2016-06-10 14:07:03 -05:00
Joshua Colp
c2f68787a3 Merge "cel: Ensure only one dial status per channel exists." into 13 2016-06-10 05:09:18 -05:00
Joshua Colp
ff018e28a0 Merge "res_pjsip_registrar.c: Eliminate rx REGISTER request race condition." into 13 2016-06-09 20:25:22 -05:00
Joshua Colp
ecc186a4cc Merge "stasis: Add setting subscription congestion levels." into 13 2016-06-09 20:25:15 -05:00
Joshua Colp
e842a99e7c Merge "sorcery: Add setting object type congestion levels." into 13 2016-06-09 20:25:09 -05:00
zuul
1ac47c5aae Merge "taskprocessors: Implement high/low water mark alerts." into 13 2016-06-09 20:12:30 -05:00
zuul
2204a6e6f1 Merge "res_pjsip_session: Use distributor serializer for incoming calls." into 13 2016-06-09 20:12:28 -05:00
zuul
935d53fa08 Merge "res_pjsip_pubsub.c: Recreate subscriptions using distributor serializer." into 13 2016-06-09 19:41:20 -05:00
zuul
51ff79bdeb Merge "res_pjsip_pubsub.c: Use distributor serializer for incoming subscriptions." into 13 2016-06-09 19:41:13 -05:00
zuul
7e2dbcd771 Merge "pjsip_distributor.c: Consistently pick a serializer for messages." into 13 2016-06-09 18:48:04 -05:00
zuul
54be8fd149 Merge "pjsip_distributor.c: Ignore messages until fully booted." into 13 2016-06-09 18:47:07 -05:00
Joshua Colp
caf6cccc5c cel: Ensure only one dial status per channel exists.
CEL wrongly assumed that a channel would only have a single dial
event on it. This is incorrect. Particularly in a queue each
call attempt to a member will result in a dial event, adding
a new dial status in CEL without removing the old one. This
would cause the container to grow with only one dial status
being removed when the channel went away. The other dial status
entries would remain leaking memory.

This change fixes the memory leak by ensuring that only one dial
status will only ever exist for each channel.

The behavior during the scenario where multiple events are received
has also been improved. For failure cases the first failure will
be the dial status. If an answer dial status is received, though,
it will take priority and the dial status for the channel will be
answer.

Memory usage has also been decreased by storing the minimal
amount of information and the code has been cleaned up slightly.

ASTERISK-25262 #close

Change-Id: I5944eb923db17b6a0faa7317ff6abc9307c009fe
2016-06-09 16:45:48 -03:00
zuul
8438315428 Merge "chan_pjsip: Lock channel when checking for RTP changes." into 13 2016-06-09 13:54:01 -05:00
Mark Michelson
715ef071a1 chan_pjsip: Lock channel when checking for RTP changes.
bridge_native_rtp can call into an RTP-capable channel driver in order
for the driver to update information about who the channel is
communicating with. For SIP channel drivers, this means deactivating
RTCP and sending a reinvite so that the endpoints can communicate
directly.

bridge_native_rtp does the right thing and has the channel locked when
calling into the channel driver. chan_pjsip can't alter session
properties in this thread, though. chan_pjsip queues a task on the
session serializer in order to update properties there.

The problem is that this queued task was not locking the channel. This
meant that the queued task could attempt to deactivate RTCP at the same
time that the channel thread was attempting to process an incoming RTCP
packet. This could lead to a crash.

This patch fixes the issue by locking the channel in the queued task
when altering RTP properties.

ASTERISK-26092 #close
Reported by Niklas Larsson

Change-Id: I3464e226a3c41f6b915f97891e07fa1599e2a159
2016-06-09 10:37:53 -05:00
George Joseph
a99ddc6a0d build: Fix ast_sockaddr initialization to be more portable
A change to glibc 2.22 changed the order of the sockadddr_storage
members which caused the places where we do an initialization of
ast_sockaddr with '{ { 0, 0, } }' to fail compilation.  Those
initializers (which we shouldn't have been using anyway) have been
replaced with memsets.

Change-Id: Idd1b3b320903d8771bfe221f0b015685de628fa4
2016-06-09 09:50:00 -05:00
zuul
bd3b6e9f19 Merge "astfd: Not maximum size of a single file but maximum file descriptors." into 13 2016-06-09 08:21:35 -05:00
zuul
c09af61c76 Merge "BuildSystem: Avoid 'ar cru' and use 'ar cr' instead." into 13 2016-06-08 22:50:39 -05:00
Joshua Colp
9d8a174092 Merge "res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded" into 13 2016-06-08 19:03:05 -05:00
Joshua Colp
f834852137 Merge "Fix #include poll.h and sys/cdefs.h" into 13 2016-06-08 16:18:34 -05:00
Matt Jordan
eabb398d71 res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded
A crash can occur in res_hep_pjsip or res_hep_rtcp if res_hep has not
loaded and does not have a configuration file. Previously when this
occurred, checks were put in to see if the configuration was loaded
successfully. While this is a good idea - and has been added to the
offending function in res_hep - the reality is res_hep_pjsip and
res_hep_rtcp have no business running if res_hep isn't also running.

As such, this patch also adds a function to res_hep that returns whether
or not it successfully loaded. Oddly enough, ast_module_check returns
"everything is peachy" even if a module declined its load - so it cannot
be solely relied on. res_hep_pjsip and res_hep_rtcp now also check this
function to see if they should continue to load; if it fails, they
decline their load as well.

ASTERISK-26096 #close

Change-Id: I007e535fcc2e51c2ca48534f48c5fc2ac38935ea
2016-06-08 12:26:29 -05:00
Alexander Traud
0d84421f93 astfd: Not maximum size of a single file but maximum file descriptors.
With menuselect "DEBUG_FD_LEAKS" and CLI "core show fd", the maximum size of a
single file was shown. Now, the maximum number of possible file descriptors is
shown.

ASTERISK-26097

Change-Id: Icf98d145774b38cac144ca76d19eaef42ce659a3
2016-06-08 13:00:23 +02:00
zuul
c9b873add8 Merge "ari/resource_channels: Add 'formats' to channel create/originate" into 13 2016-06-08 00:11:29 -05:00
Timo Teräs
9c5a0b814b Fix #include poll.h and sys/cdefs.h
POSIX defines poll.h, sys/poll.h should not be used at is c-library
internal header which may or may not exist. Notable in musl it
generates warning of being incorrect. And add explict include of
sys/cdefs.h where needed.

Change-Id: I142930df53fe7585a06b854b6faddc5301e024be
2016-06-07 19:01:26 -05:00
Richard Mudgett
9c35f34301 res_pjsip_registrar.c: Eliminate rx REGISTER request race condition.
This patch fixes a race condition processing received REGISTER requests
and their retransmissions caused by REGISTER requests being processed by
two threads.  The "sip_transaction Unable to register REGISTER transaction
(key exists)" message is a notable symptom of this issue.

This issue was more likely to happen before the pjsip/distributor
serializers were created.  Instead of steps one and two below placing the
REGISTER messages into the same pjsip/distributor they were placed in
random pjsip/default serializers.

1) REGISTER requests come in and get placed on the pjsip/distributor
serializer.

2) Before the first request is processed a retransmission comes in and is
placed on the same pjsip/distributor serializer.

3) The first request goes up the pjsip stack and is then shunted off to
the pjsip/aor/<aor> serializer.

4) Before the first request is completed processing in the pjsip/aor/<aor>
serializer, the second request goes up the pjsip stack and is also shunted
off to the pjsip/aor/<aor> serializer.

5) The first request completes processing and sends out its response.

6) The second request completes processing and tries to send out its
response but pjlib complains that the REGISTER transaction key already
exists.

7) Sadness ensues.

* The race is eliminated by removing the pjsip/aor/<aor> serializer and
continuing the processing in the pjsip/distributor serializer.  Now any
retransmissions queued in the pjsip/distributor serializer will be
processed after the first message is completely processed.

ASTERISK-26088 #close
Reported by:  Richard Mudgett

Change-Id: I842d714346088bf717ea27437f1dd85bff0bab5a
2016-06-07 18:57:36 -05:00
Richard Mudgett
557333ea4c stasis: Add setting subscription congestion levels.
Stasis subscriptions and message routers create taskprocessors to process
the event messages.  API calls are needed to be able to set the congestion
levels of these taskprocessors for selected subscriptions and message
routers.

* Updated CDR, CEL, and manager's stasis subscription congestion levels
based upon stress testing.  Increased the congestion levels to reduce the
potential for bursty call setup/teardown activity from triggering the
taskprocessor overload alert.  CDRs in particular need an extra high
congestion level because they can take awhile to process the stasis
messages.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: Id0a716394b4eee746dd158acc63d703902450244
2016-06-07 18:57:36 -05:00
Richard Mudgett
110d772467 sorcery: Add setting object type congestion levels.
Sorcery creates taskprocessors for object types to process object observer
callbacks.  An API call is needed to be able to set the congestion levels
of these taskprocessors for selected object types.

* Updated PJSIP's contact and contact_status sorcery object type observer
default congestion levels based upon stress testing.  Increased the
congestion levels to reduce the potential for bursty register/unregister
and subscribe/unsubscribe activity from triggering the taskprocessor
overload alert.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: I4542e83b556f0714009bfeff89505c801f1218c6
2016-06-07 18:57:36 -05:00
Richard Mudgett
610eee2a36 taskprocessors: Implement high/low water mark alerts.
When taskprocessors get backed up, there is a good chance that we are
being overloaded and need to defer adding new work to the system.

* Implemented a high/low water alert mechanism for modules to check if the
system is being overloaded and take appropriate action.  When a
taskprocessor is created it has default congestion levels set.  A
taskprocessor can later have those congestion levels altered for specific
needs if stress testing shows that the taskprocessor is a symptom of
overloading or needs to handle bursty activity without triggering an
overload alert.

* Add CLI "core show taskprocessor" low/high water columns.

* Fixed __allocate_taskprocessor() to not use RAII_VAR().  RAII_VAR() was
never a good thing to use when creating a taskprocessor because of the
nature of how its references needed to be cleaned up on a partial
creation.

* Made res_pjsip's distributor check if the taskprocessor overload alert
is active before placing a message representing brand new work onto a
distributor serializer.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: I182f1be603529cd665958661c4c05ff9901825fa
2016-06-07 18:57:36 -05:00
Richard Mudgett
26e3492246 res_pjsip_session: Use distributor serializer for incoming calls.
We must continue using the serializer that the original INVITE came in on
for the dialog.  There may be retransmissions already enqueued in the
original serializer that can result in reentrancy and message sequencing
problems.

Outgoing call legs create the pjsip/outsess/<endpoint> serializers for
their dialogs.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: I24d7948749c582b8045d5389ba3f6588508adbbc
2016-06-07 13:16:19 -05:00
Richard Mudgett
ceb1007ed7 res_pjsip_pubsub.c: Recreate subscriptions using distributor serializer.
* Resolves potential reentrancy problems if system restarted in the middle
of subscription message transactions.

* Fixes memory leak recreating persistent subscriptions when the
subscription resource tree could not be created.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: I71e34d7ae8ed35a694f1030e820e2548c48697be
2016-06-07 13:16:19 -05:00
Richard Mudgett
27bafc3a8b res_pjsip_pubsub.c: Use distributor serializer for incoming subscriptions.
We must continue using the serializer that the original SUBSCRIBE came in
on for the dialog.  There may be retransmissions already enqueued in the
original serializer that can result in reentrancy and message sequencing
problems.  The "sip_transaction Unable to register SUBSCRIBE transaction
(key exists)" message is a notable symptom of this issue.

Outgoing subscriptions still create the pjsip/pubsub/<endpoint>
serializers for their dialogs.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: I18b00bb74a56747b2c8c29543a82440b110bf0b0
2016-06-07 13:16:19 -05:00
Richard Mudgett
16b08444da pjsip_distributor.c: Consistently pick a serializer for messages.
Incoming messages that are not part of a dialog or a recognized response
to one of our requests need to be sent to a consistent serializer.  Under
load we may be queueing retransmissions before we can process the original
message.  We don't need to throw these messages onto random serializers
and cause reentrancy and message sequencing problems.

* Created a pool of pjsip/distributor serializers that get picked by
hashing the call-id and remote tag strings of the received messages.

* Made ast_sip_destroy_distributor() destroy items in the reverse order of
creation.

ASTERISK-26088
Reported by:  Richard Mudgett

Change-Id: I2ce769389fc060d9f379977f559026fbcb632407
2016-06-07 13:16:19 -05:00