Commit Graph

26915 Commits

Author SHA1 Message Date
Matt Jordan b178f8701b sorcery: Add support for object staleness
This patch enhances the sorcery API to allow for sorcery wizards to
determine if an object is stale. This includes the following:

* Sorcery objects now have a timestamp that is set on creation. Since
  sorcery objects are immutable, this can be used by sorcery wizards to
  determine if an object is stale.

* A new API call has been added, ast_sorcery_is_stale. This API call
  queries the wizards associated with the object, calling a new callback
  function 'is_stale'. Note that if a wizard does not support the new
  callback, objects are always assumed to not be stale.

* Unit tests have been added that cover the new API call.

Change-Id: Ica93c6a4e8a06c0376ea43e00cf702920b806064
2015-07-04 20:32:09 -05:00
Joshua Colp 987548413d Merge "chan_sip: Fix early call pickup channel leak." 2015-07-04 19:08:59 -05:00
Joshua Colp f35a4b8525 res/res_http_websocket: Don't send HTTP response fragmented.
This change makes it so that when accepting a WebSocket
connection the HTTP response is sent as one packet instead of
fragmented. Browsers don't like it when you send it fragmented.

ASTERISK-25103

Change-Id: I9b82c4ec2949b0bce692ad0bf6f7cea9709e7f69
2015-07-04 18:26:43 -05:00
Matt Jordan 2c17515f3c Makefile: Remove coverage files on 'make clean'
This patch updates a variety of Makefiles in Asterisk's build system to
remove .gcda and .gcno files when 'make clean' is executed. These files
are generated when '--enable-coverage' is passed to the Asterisk
configure script.

Change-Id: Ib70b41eea2ee2908885bff02e80faf9f40c84602
2015-07-04 07:47:06 -05:00
Joshua Colp fa4dd9755a Merge "chan_vpb.cc: Fix compiler warning Jenkins found." 2015-07-02 09:47:58 -05:00
Matt Jordan 45b8a2be31 Merge "dns: Fix crash when invoking cancel in DNS recurring unit test." 2015-07-02 09:43:09 -05:00
Walter Doekes 34323f9f95 chan_sip: Fix early call pickup channel leak.
When handle_invite_replaces() was called, and either ast_bridge_impart()
failed or there was no bridge (because the channel we're picking up was
still ringing), chan_sip would leak a channel.

Thanks Matt and Corey for checking the bridge path.

ASTERISK-25226 #close

Change-Id: Ie736bb182170a73eef5bcef0ab0376f645c260c8
2015-07-02 09:16:09 -05:00
Matt Jordan a889cfa0b9 Merge "sorcery/realtime: Add a bit of debug and warning messages for bad configs" 2015-07-02 08:02:08 -05:00
Joshua Colp 98c5616bae Merge "res_timing: Don't close FD 0 when out of open files." 2015-07-02 07:53:47 -05:00
Joshua Colp 8bfaccafe9 Merge "rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format." 2015-07-02 07:52:41 -05:00
Joshua Colp f398c8151a Merge "astfd: Fix buffer overflow in DEBUG_FD_LEAKS." 2015-07-02 07:51:55 -05:00
Joshua Colp 5fc08c48c4 Merge "chan_mgcp: Don't call close on fd -1." 2015-07-02 07:50:54 -05:00
Matt Jordan ef74ccb18d sorcery/realtime: Add a bit of debug and warning messages for bad configs
When a mapping does not exist between a sorcery.conf defined object and
a realtime mapping in extconf, currently, the user will receive a slew
of ERROR messages that don't really tell what is happening. Some ERROR
messages may even be misleading, as they occur after the sorcery API has
already given up on the attempt to load and create the sorcery object.

This patch adds a bit of debug and a useful WARNING message for when a
wizard's open callback fails for a particular object type. In the bad
configurations that resulted in this patch, this provided a 'root cause'
WARNING message that pointed in the right direction of the configuration
problem.

Change-Id: I1cc7344f2b015b8b9c85a7e6ebc8cb4753a8f80b
2015-07-02 07:31:56 -05:00
Joshua Colp f18436642b dns: Fix crash when invoking cancel in DNS recurring unit test.
The recurring unit test expects the user data on a DNS query
created as a result of a recurring DNS query to be the recurring
structure itself. This is true, mostly. When invoking the user
provided callback this user data is changed to the user provided
data. This presents a race condition where the data may or may
not point to the recurring data.

This change simplifies the callback of the user provided callback
by creating a new query and populating it with the expected values.
This leaves the recurring DNS query alone and fixes the race
condition. This is more in line with how the API should be used
overall.

ASTERISK-25222 #close

Change-Id: I10fb6deec025dff097157e7ec17e6e4921778478
2015-07-02 08:54:51 -03:00
Walter Doekes 6fbb58c7f7 chan_mgcp: Don't call close on fd -1.
ASTERISK-25220 #close

Change-Id: Ic48f3a82f51ada87f2fb0e016c9efe0ad56f1ee3
2015-07-02 06:22:18 -05:00
Walter Doekes 13a318bbb1 rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format.
When running valgrind on Asterisk, it complained about:

    ==32423== Source and destination overlap in memcpy(0x85a920, 0x85a920, 304)
    ==32423==    at 0x4C2F71C: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/...)
    ==32423==    by 0x55BA91: ast_rtp_engine_unload_format (rtp_engine.c:2292)
    ==32423==    by 0x4EEFB7: ast_format_attr_unreg_interface (format.c:1437)

The code in question is a struct assignment, which may be performed by
memcpy as a compiler optimization. It is changed to only copy the struct
contents if source and destination are different.

ASTERISK-25219 #close

Change-Id: I6d3546c326b03378ca8e9b8cefd41c16e0088b9a
2015-07-02 06:19:05 -05:00
Walter Doekes 40274e3652 astfd: Fix buffer overflow in DEBUG_FD_LEAKS.
If DEBUG_FD_LEAKS was used and more file descriptors than the default of
1024 were available, some DEBUG_FD_LEAKS-patched functions would
overwrite memory past the fixed-size (1024) fdleaks buffer.

This change:
- adds bounds checks to __ast_fdleak_fopen and __ast_fdleak_pipe
- consistently uses ARRAY_LEN() instead of sizeof() or 1023 or 1024
- stores pointers to constants instead of copying the contents
- reorders the fdleaks struct for possibly tighter packing
- adds a tiny bit of documentation

ASTERISK-25212 #close

Change-Id: Iacb69e7701c0f0a113786bd946cea5b6335a85e5
2015-07-02 05:24:43 -05:00
Walter Doekes 3fab8212e3 res_timing: Don't close FD 0 when out of open files.
This fixes so a failure to get a timer file descriptor does not cascade
to closing FD 0.

On error, both res_timing_kqueue and res_timing_timerfd would call the
destructor before setting the file handle. The file handle had been
initialized to 0, causing FD 0 to be closed. This in turn, resulted in
floods of "CLI>" messages and an unusable terminal.

ASTERISK-19277 #close
Reported by: Barry Chern

For the master branch, this was already fixed. This patch only ensures
that we do not attempt to close a negative file descriptor.

Change-Id: I147d7e33726c6e5a2751928d56561494f5800350
2015-07-02 05:13:37 -05:00
Richard Mudgett 41610df8d5 chan_vpb.cc: Fix compiler warning Jenkins found.
Change-Id: I0ec7fd10d56d90d5a60b12b5a7d6807f265ac5e0
2015-07-01 17:25:31 -05:00
Scott Griepentrog 537df26f9c Channel alert pipe: improve diagnostic error return
When a frame is queued on a channel, any failure in
ast_channel_alert_write is logged along with errno.

This change improves the diagnostic message through
aligning the errno value with actual failure cases.

ASTERISK-25224
Reported by: Andrey Biglari

Change-Id: I1bf7b3337ad392789a9f02c650589cd065d20b5b
2015-07-01 16:53:17 -05:00
Joshua Colp c12ace3ab3 Merge "res_sorcery_realtime: Fix leak of sorcery object type." 2015-06-30 07:32:23 -05:00
Matt Jordan 3cd53bd3bc Merge "channel: Remove ignore of answer on non-outgoing channels." 2015-06-30 07:07:10 -05:00
Mark Michelson 58d18324f0 res_sorcery_realtime: Fix leak of sorcery object type.
This prevents a leak of a sorcery object type when realtime sorcery
objects are retrieved by fields or when multiple objects are retrieved.

The extent of this leak is that sorcery object types would be leaked.
These are allocated whenever an object type is registered with sorcery,
meaning that on module shutdown, these objects would be leaked. This
could be problematic if many reloads were performed, but it is not as
severe as if every sorcery object retrieved from realtime were being
leaked.

ASTERISK-25165 #close
Reported by Corey Farrell

Change-Id: I625c3b50eee4576670b7eeb013c81ad043b4b4f8
2015-06-29 14:34:58 -05:00
Matt Jordan 598a5f0d15 Merge "res_pjsip_nat: Adjust when contact should be rewritten." 2015-06-29 11:56:46 -05:00
Matt Jordan d66c059fbc Merge "res/res_corosync: Always decline module load, instead of failing" 2015-06-29 10:39:00 -05:00
Matt Jordan 80d97290bb res/res_corosync: Always decline module load, instead of failing
Returns a 'failure' from the module load routine indicates to Asterisk
that it should abort loading completely. This is rarely - in fact,
really, never - a good option. Aborting load of Asterisk from a dynamic
module implies that the core, and the rest of the dynamic modules, don't
matter: we should abandon all processing.

res_corosync is really not that important.

This patch updates the module such that, if it fails to load, it
politely declines (emitting ERROR messages along the way), and allows
Asterisk to continue to function.

Note that this issue was keeping Asterisk unit tests from running on
certain build agents.

Change-Id: I252249e81fb9b1a68e0da873f54f47e21d648f0f
2015-06-26 22:06:06 -05:00
Matt Jordan 892cc5625f main/pbx: Resolve case sensitivity regression in PBX hints
When 8297136f was merged for ASTERISK-25040, a regression was introduced
surrounding the case sensitivity of device names within hints.
Previously, device names - such as 'sip/foo' - were compared in a case
insensitive fashion. Thus, 'sip/foo' was equivalent to 'SIP/foo'. After
that patch, only the case sensitive name would match, i.e., 'SIP/foo'.
As a result, some dialplan hints stopped working.

This patch re-introduces case insensitive matching for device names in
hints.

ASTERISK-25040

ASTERISK-25202 #close

Change-Id: If5046a7d14097e1e3c12b63092b9584bb1e9cb4c
(cherry picked from commit 96bbcf495a)
2015-06-26 21:05:38 -05:00
Mark Michelson e18b22a806 res_pjsip_nat: Adjust when contact should be rewritten.
A previous change made the contact only get rewritten if the dialog's
route set was not marked frozen. Unfortunately, while the intent of this
is correct, the dialog's route set actually gets marked as frozen
earlier than expected, especially for UAS dialogs.

Instead, the idea is that the contact needs to not be rewritten if there
is a pre-existing route set on the dialog. This is now accomplished by
checking the dialog's route set list instead of checking if the route
set is frozen.

Doing this causes some broken tests to begin passing again.

ASTERISK-25196
Reported by Mark Michelson

Change-Id: I525ab251fd40a52ede327a52a2810a56deb0529e
2015-06-26 16:12:33 -05:00
Richard Mudgett 99b1aa6d26 res_pjsip_outbound_registration.c: Add a serializer shutdown group.
The client_state objects contain a serializer used to send the outbound
REGISTER messages.  Once all those message transactions are complete then
the module can shutdown.

ASTERISK-24907 #close
Reported by: Kevin Harwell

Change-Id: Ibb2fe558f98190f2a06da830e0fadfa25516f547
2015-06-26 13:45:15 -05:00
Matt Jordan c0194b55b5 Merge "threadpool, res_pjsip: Add serializer group shutdown API calls." 2015-06-26 13:36:17 -05:00
Matt Jordan 8c1161a268 Merge "res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs" 2015-06-26 13:34:54 -05:00
Matt Jordan 4208fe6ba7 Merge "res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API" 2015-06-26 13:34:47 -05:00
Matt Jordan d568177d7d Merge "res_pjsip_refer: Prevent sending duplicate headers." 2015-06-26 11:26:43 -05:00
Matt Jordan 771b9bb442 Merge "sorcery: Add ast_sorcery_object_unregister() API call." 2015-06-26 11:25:58 -05:00
Matt Jordan 8a9628dce5 Merge "res_pjsip_outbound_registration.c: Reorder load_module() and unload_module()." 2015-06-26 11:25:49 -05:00
Matt Jordan 19fcb928b2 Merge "AMI: Add Linkedid to the standard channel snapshot AMI event headers." 2015-06-26 11:00:29 -05:00
Matt Jordan 05dbfedb43 Merge "res_pjsip_nat: Rewrite route set when required." 2015-06-26 10:59:35 -05:00
Mark Michelson f536e9b59c res_pjsip_refer: Prevent sending duplicate headers.
res_pjsip_refer will attempt to add Referred-By or Replaces headers to
outbound INVITEs at times. If the INVITE gets challenged for
authentication, then we will resend the INVITE. Prior to this patch, the
Referred-By or Replaces header would be re-added to the outbound INVITE,
resulting in duplicated headers.

ASTERISK-25204 #close
Reported by Mark Michelson

Change-Id: I59fb5c08b4d253c0dba9ee3d3950b5025358222d
2015-06-26 10:41:05 -05:00
Richard Mudgett c2d48a2a28 AMI: Add Linkedid to the standard channel snapshot AMI event headers.
ASTERISK-25189 #close
Reported by: John Hardin

Change-Id: I2b1778c3fdc1dca0ed55db4e3a639eddfb16c2ac
2015-06-26 10:34:31 -05:00
Mark Michelson 700606a659 res_pjsip_nat: Rewrite route set when required.
When performing some provider testing, the rewrite_contact option was
interfering with proper construction of a route set when sending an ACK
after receiving a 200 OK response to an INVITE.

The initial INVITE was sent to address sip:foo. The 200 OK had a Contact
header with URI sip:bar. In addition, the 200 OK had Record-Route
headers for sip:baz and sip:foo, in that order. Since the Record-Route
headers had the lr parameter, the result should have been:

* Set R-URI of the ACK to sip:bar.
* Add Route headers for sip:foo and sip:baz, in that order.

However, the rewrite_contact option resulted in our rewriting the
Contact header on the 200 OK to sip:foo. The result was:

* R-URI remained sip:foo.
* We added Route headers for sip:foo and sip:baz, in that order.

The result was that sip:bar was not indicated in the ACK at all, so the
far end never received our ACK. The call eventually dropped.

The intention of rewrite_contact is to rewrite the most immediate
destination of our SIP request to be the same address on which we
received a request or response. In the case of processing a SIP response
with Record-Route headers, this means that instead of rewriting the
Contact header, we should instead rewrite the bottom-most Record-Route
header. In the case of processing a SIP request with Record-Route
headers, this means we rewrite the top-most Record-route header.
Like when we rewrite the Contact header, we also ensure to update
the dialog's route set if it exists.

ASTERISK-25196 #close
Reported by Mark Michelson

Change-Id: I9702157c3603a2d0bd8a8215ac27564d366b666f
2015-06-26 09:53:26 -05:00
Richard Mudgett af4ae3095e threadpool, res_pjsip: Add serializer group shutdown API calls.
A module trying to unload needs to wait for all serializers it creates and
uses to complete processing before unloading.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I8c80b90f2f82754e8dbb02ddf3c9121e5e966059
2015-06-25 14:33:44 -05:00
Richard Mudgett 4c133d81cd res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs
* handle_client_state_destruction() must always be passed a ref to
client_state because it will always unref client_state.
handle_registration_response() was not passing a client_state ref.

* Made the final un-REGISTER message get sent normally using the pjproject
register control structure in handle_client_state_destruction().  The
previous code attempted to short circuit the response handling for the
module to unload.  That doesn't work for a couple reasons.  One,
pjsip_regc_send() may call the registered callback before it returns and
unbalance the client_state ref count.  Two, the registered callback
handles any authentication for the un-REGISTER message.

* Made the distinction between internal registration state and external
registration status with sip_outbound_registration_status_str().  This is
necessary to avoid altering documented AMI messages with internal
changes.

* Removed references to client_state->client outside of the serializer
thread.  When handle_client_state_destruction() destroys the pjproject
register control structure that memory is freed and cannot be referenced
anymore.  These accesses were to provide information for debug and
off-nominal warning messages.

* In sip_outbound_registration_timer_cb() you should not access entry->id
after unrefing client_state because the passed in entry is normally
pointing to the timer entry in the client_state object.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: Ia7b446d8644b6b4550ef5bea49527671de65183f
2015-06-25 14:33:44 -05:00
Richard Mudgett dc63377c60 res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API
The sorcery pjsip 'registration' config object needs to be destroyed on
module unload.  Otherwise, a reload of res_pjsip could try to use
callbacks for a previously unloaded instance of the module provided by
ast_sorcery_object_register() or one of the variants.  Also, if
res_pjsip_outbound_registration were subsequently reloaded, the sorcery
config field objects would be registered in sorcery twice.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I304fad13dece2604af48353f6c6d9d5c7b064697
2015-06-25 14:32:19 -05:00
Richard Mudgett 9ec8a0f3cc sorcery: Add ast_sorcery_object_unregister() API call.
Find and unlink the specified sorcery object type to complement
ast_sorcery_object_register().  Without this function you cannot
completely unload individual modules that use sorcery for configuration.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I1c04634fe9a90921bf676725c7d6bb2aeaab1c88
2015-06-25 14:30:48 -05:00
Richard Mudgett 77ff7325a2 res_pjsip_outbound_registration.c: Reorder load_module() and unload_module().
It is best if the loading code creates and initializes the module's
infrastructure before letting the system know of its existence.  The
unloading code needs to reverse the actions of the loading code and in the
reverse order.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I5d151383e9787b5b60aa5e1627b10f040acdded4
2015-06-25 14:30:48 -05:00
Joshua Colp 8d6cf667dc channel: Remove ignore of answer on non-outgoing channels.
Due to the way that channels can now be moved around inside of
Asterisk it is possible for the outgoing flag of a channel to get
cleared before it has been answered. This results in the bridge
not receiving notification that the outgoing leg has been answered.

This most easily exhibits itself with DTMF based blond transfers.
Since the answer of the outgoing leg is ignored the other party
continues to receive both a locally generated ringing and the
media stream of the outgoing leg upon its answer. This results
in no media being heard.

This change removes the ignore of the answer and allows it
to pass through.

ASTERISK-25171 #close

Change-Id: I82aedcec4f89f34a2e5472086dfc9a6c775bca8e
2015-06-25 13:18:02 -05:00
Mark Michelson 3f1fe83633 Merge "res_pjsip_mwi: Set up unsolicited MWI upon registration." 2015-06-25 09:51:48 -05:00
Joshua Colp 6fffef78c3 Merge "test.c: Add unit test registration checks for summary and description." 2015-06-25 04:52:02 -05:00
Joshua Colp 52aa9536a1 Merge "Unit tests: Fix more unit test description strings." 2015-06-25 04:50:54 -05:00
Joshua Colp 7f30be6f5e Merge "Unit tests: Fix unit test description strings." 2015-06-25 04:48:46 -05:00