Commit Graph

459 Commits

Author SHA1 Message Date
Matthew Jordan c6df713da7 res_pjsip_authenticator_digest: Fix md5 hash buffer
An md5 hash is 32 bytes long. The char buffer must be at least 33 bytes to
avoid clobbering of the stack. This patch also fixes a potential clobbering
in test_utils.c.

Thanks to Andrew Nagy for reporting and testing this out in #asterisk-dev

Reported by: Andrew Nagy
Tested by: Andrew Nagy
........

Merged revisions 404843 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404844 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-03 21:13:30 +00:00
Richard Mudgett c2caaecc45 test_stasis.c: Fix ref leak in normal execution path.
........

Merged revisions 404764 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404783 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-03 18:33:19 +00:00
Richard Mudgett 72c282cc66 ao2_iterator: Mini-audit of the ao2_iterator loops in the new code files.
* Fixed several places where ao2_iterator_destroy() was not called.

* Fixed several iterator loop object variable reference problems.

* Fixed res_parking AMI actions returning non-zero.  Only the AMI logoff
action can return non-zero.

Review: https://reviewboard.asterisk.org/r/3087/
........

Merged revisions 404434 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-20 20:00:50 +00:00
Kevin Harwell 28c0cb28d0 channel locking: Add locking for channel snapshot creation
Original commit message by mmichelson (asterisk 12 r403311):

"This adds channel locks around calls to create channel snapshots as well
as other functions which operate on a channel and then end up
creating a channel snapshot. Functions that expect the channel to be
locked prior to being called have had their documentation updated to
indicate such."

The above was initially committed and then reverted at r403398.  The problem
was found to be in core_local.c in the publish_local_bridge_message function.
The ast_unreal_lock_all function locks and adds a reference to the returned
channels and while they were being unlocked they were not being unreffed when
no longer needed.  Fixed by unreffing the channels.

Also in bridge.c a lock was obtained on "other->chan", but then an attempt was
made to unlock "other" and not the previously locked channel.  Fixed by
unlocking "other->chan"

(closes issue ASTERISK-22709)
Reported by: John Bigelow
........

Merged revisions 404237 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404260 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-18 20:33:37 +00:00
Joshua Colp e2630fcd51 channels: Return allocated channels locked.
This change makes ast_channel_alloc return allocated channels
locked. By doing so no other thread can acquire, lock, and manipulate
the channel before it is completely set up.

(closes issue AST-1256)

Review: https://reviewboard.asterisk.org/r/3067/
........

Merged revisions 404204 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404210 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-18 19:28:05 +00:00
Jonathan Rose 655ce29aac tests: fix ast_bridge_base_new calls not using the additional arguments
r404042 gave ast_bridge_base_new two new arguments for setting a bridge creator
and name. Unfortunately since a couple test modules aren't compiled by default,
I missed the fact that this change impacted those tests and caused compilation
failures against them.
........

Merged revisions 404048 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404049 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-17 23:57:52 +00:00
Richard Mudgett 3a5e4317f5 test_voicemail_api: Add check for a registered voicemail provider before tests.
It is much nicer diagnosing a test failure if app_voicemail is actually
loaded.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403726 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-13 00:40:49 +00:00
David M. Lee 1212906351 Reverting r403311. It's causing ARI tests to hang.
........

Merged revisions 403398 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403404 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-05 22:10:20 +00:00
Richard Mudgett 3357c494cb sorcery, bucket: Change observer remove calls to take const callbacks struct.
* Make ast_sorcery_observer_remove() accept a const callbacks struct.

* Make ast_sorcery_observer_remove() tolerant of the sorcery parameter
being NULL.  Now it can be called within a module unload routine if the
sorcery initialization fails.

* Fix ast_sorcery_observer_add() to fail if the container link fails.
........

Merged revisions 403324 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403327 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-03 17:35:54 +00:00
Mark Michelson 8e8b329e14 Add channel locking for channel snapshot creation.
This adds channel locks around calls to create channel snapshots as well
as other functions which operate on a channel and then end up
creating a channel snapshot. Functions that expect the channel to be
locked prior to being called have had their documentation updated to
indicate such.
........

Merged revisions 403311 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-03 17:07:29 +00:00
David M. Lee fccb427c88 ari:Add application/json parameter support
The patch allows ARI to parse request parameters from an incoming JSON
request body, instead of requiring the request to come in as query
parameters (which is just weird for POST and DELETE) or form
parameters (which is okay, but a bit asymmetric given that all of our
responses are JSON).

For any operation that does _not_ have a parameter defined of type
body (i.e. "paramType": "body" in the API declaration), if a request
provides a request body with a Content type of "application/json", the
provided JSON document is parsed and searched for parameters.

The expected fields in the provided JSON document should match the
query parameters defined for the operation. If the parameter has
'allowMultiple' set, then the field in the JSON document may
optionally be an array of values.

(closes issue ASTERISK-22685)
Review: https://reviewboard.asterisk.org/r/2994/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403177 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-27 15:48:39 +00:00
Kinsey Moore 2c90d80b8f Make sure unit tests compile
This fixes the unit tests that were broken by r403069 and several
functions requiring a new parameter for sanitization of JSON messages
generated from object snapshots.
........

Merged revisions 403094 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403095 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-22 23:57:45 +00:00
David M. Lee 8f43c9716c test_json: Fix deprecation warnings
After a series of upgrades over recent weeks, I've discovered that
test_json.c won't compile in dev mode any more for me.

One of gcc-4.8.2, OS X Mavericks or Xcode 5 has decided to deprecate
tempnam. Which, in general, is a good thing. But for test code that just
needs a temporary file, it's just annoying.

This patch replaces usage of tempname with mkstemp, avoiding the
deprecation warning. It also removes the temporary files when the test
is complete, which apparently we weren't doing before (oops).

Review: https://reviewboard.asterisk.org/r/2957/
........

Merged revisions 401872 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-25 13:49:20 +00:00
Jonathan Rose 1d0a6d2b2c test_linkedlists: Fix memory leak
(issue ASTERISK-22467)
Reported by: Corey Farrell
Patches:
    test_linkedlists-1.8.patch uploaded by coreyfarrell (license 5909)
    test_linkedlists-11up.patch uploaded by coreyfarrell (license 5909)
........

Merged revisions 401790 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 401791 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 401792 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-24 19:57:04 +00:00
Jonathan Rose beb5cdbef5 memory leaks: Memory leak cleanup patch by Corey Farrell (first set)
(issue ASTERSIK-22467)
Reported by: Corey Farrell
Patches:
    chan_sip-parse_contact_header_test-free-contacts.patch uploaded by coreyfarrell (license 5909)
    cli-filename-completion-leak.patch uploaded by coreyfarrell (license 5909)
    func_math.patch uploaded by corefarrell (license 5909)
    main-test-cleanup.patch uploaded by coreyfarrell (license 5909)
    test_dlinklists.patch uploaded by coreyfarrell (license 5909)
........

Merged revisions 401660 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 401661 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 401662 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-23 20:10:30 +00:00
Mark Michelson f945c6a207 Get rid of uses of stasis_topic_wait()
........

Merged revisions 400362 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400364 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-03 14:59:29 +00:00
Mark Michelson ee21eee7e0 Cache string values of formats on ast_format_cap() to save processing.
Channel snapshots have string representations of the channel's native formats.
Prior to this change, the format strings were re-created on ever channel snapshot
creation. Since channel native formats rarely change, this was very wasteful.
Now, string representations of formats may optionally be stored on the ast_format_cap
for cases where string representations may be requested frequently. When formats
are altered, the string cache is marked as invalid. When strings are requested, the
cache validity is checked. If the cache is valid, then the cached strings are copied.
If the cache is invalid, then the string cache is rebuilt and copied, and the cache
is marked as being valid again.

Review: https://reviewboard.asterisk.org/r/2879
........

Merged revisions 400356 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400363 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-03 14:58:16 +00:00
Mark Michelson addbf276f5 Multiple revisions 400318-400319
........
  r400318 | mmichelson | 2013-10-02 17:08:49 -0500 (Wed, 02 Oct 2013) | 12 lines
  
  Remove unnecessary waits from stasis.
  
  Since caches are updated on publisher threads, there is no need
  to wait for the cache updates to occur after a stasis message
  is published.
  
  In the case of chan_pjsip device state changes, this set of
  changes caused an improvement to performance.
  
  Review: https://reviewboard.asterisk.org/r/2890
........
  r400319 | mmichelson | 2013-10-02 17:10:54 -0500 (Wed, 02 Oct 2013) | 3 lines
  
  Remove svn:mergeinfo property.
........

Merged revisions 400318-400319 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400335 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-02 22:22:17 +00:00
David M. Lee 2de42c2a25 Multiple revisions 399887,400138,400178,400180-400181
........
  r399887 | dlee | 2013-09-26 10:41:47 -0500 (Thu, 26 Sep 2013) | 1 line
  
  Minor performance bump by not allocate manager variable struct if we don't need it
........
  r400138 | dlee | 2013-09-30 10:24:00 -0500 (Mon, 30 Sep 2013) | 23 lines
  
  Stasis performance improvements
  
  This patch addresses several performance problems that were found in
  the initial performance testing of Asterisk 12.
  
  The Stasis dispatch object was allocated as an AO2 object, even though
  it has a very confined lifecycle. This was replaced with a straight
  ast_malloc().
  
  The Stasis message router was spending an inordinate amount of time
  searching hash tables. In this case, most of our routers had 6 or
  fewer routes in them to begin with. This was replaced with an array
  that's searched linearly for the route.
  
  We more heavily rely on AO2 objects in Asterisk 12, and the memset()
  in ao2_ref() actually became noticeable on the profile. This was
  #ifdef'ed to only run when AO2_DEBUG was enabled.
  
  After being misled by an erroneous comment in taskprocessor.c during
  profiling, the wrong comment was removed.
  
  Review: https://reviewboard.asterisk.org/r/2873/
........
  r400178 | dlee | 2013-09-30 13:26:27 -0500 (Mon, 30 Sep 2013) | 24 lines
  
  Taskprocessor optimization; switch Stasis to use taskprocessors
  
  This patch optimizes taskprocessor to use a semaphore for signaling,
  which the OS can do a better job at managing contention and waiting
  that we can with a mutex and condition.
  
  The taskprocessor execution was also slightly optimized to reduce the
  number of locks taken.
  
  The only observable difference in the taskprocessor implementation is
  that when the final reference to the taskprocessor goes away, it will
  execute all tasks to completion instead of discarding the unexecuted
  tasks.
  
  For systems where unnamed semaphores are not supported, a really
  simple semaphore implementation is provided. (Which gives identical
  performance as the original taskprocessor implementation).
  
  The way we ended up implementing Stasis caused the threadpool to be a
  burden instead of a boost to performance. This was switched to just
  use taskprocessors directly for subscriptions.
  
  Review: https://reviewboard.asterisk.org/r/2881/
........
  r400180 | dlee | 2013-09-30 13:39:34 -0500 (Mon, 30 Sep 2013) | 28 lines
  
  Optimize how Stasis forwards are dispatched
  
  This patch optimizes how forwards are dispatched in Stasis.
  
  Originally, forwards were dispatched as subscriptions that are invoked
  on the publishing thread. This did not account for the vast number of
  forwards we would end up having in the system, and the amount of work it
  would take to walk though the forward subscriptions.
  
  This patch modifies Stasis so that rather than walking the tree of
  forwards on every dispatch, when forwards and subscriptions are changed,
  the subscriber list for every topic in the tree is changed.
  
  This has a couple of benefits. First, this reduces the workload of
  dispatching messages. It also reduces contention when dispatching to
  different topics that happen to forward to the same aggregation topic
  (as happens with all of the channel, bridge and endpoint topics).
  
  Since forwards are no longer subscriptions, the bulk of this patch is
  simply changing stasis_subscription objects to stasis_forward objects
  (which, admittedly, I should have done in the first place.)
  
  Since this required me to yet again put in a growing array, I finally
  abstracted that out into a set of ast_vector macros in
  asterisk/vector.h.
  
  Review: https://reviewboard.asterisk.org/r/2883/
........
  r400181 | dlee | 2013-09-30 13:48:57 -0500 (Mon, 30 Sep 2013) | 28 lines
  
  Remove dispatch object allocation from Stasis publishing
  
  While looking for areas for performance improvement, I realized that an
  unused feature in Stasis was negatively impacting performance.
  
  When a message is sent to a subscriber, a dispatch object is allocated
  for the dispatch, containing the topic the message was published to, the
  subscriber the message is being sent to, and the message itself.
  
  The topic is actually unused by any subscriber in Asterisk today. And
  the subscriber is associated with the taskprocessor the message is being
  dispatched to.
  
  First, this patch removes the unused topic parameter from Stasis
  subscription callbacks.
  
  Second, this patch introduces the concept of taskprocessor local data,
  data that may be set on a taskprocessor and provided along with the data
  pointer when a task is pushed using the ast_taskprocessor_push_local()
  call. This allows the task to have both data specific to that
  taskprocessor, in addition to data specific to that invocation.
  
  With those two changes, the dispatch object can be removed completely,
  and the message is simply refcounted and sent directly to the
  taskprocessor.
  
  Review: https://reviewboard.asterisk.org/r/2884/
........

Merged revisions 399887,400138,400178,400180-400181 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400186 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-30 18:55:27 +00:00
Richard Mudgett 7c796593d3 astobj2: Remove OBJ_CONTINUE support.
OBJ_CONTINUE was a strange feature that came into the world under
suspicious circumstances to support an abuse of the ao2_container by
chan_iax2.  Since chan_iax2 no longer uses OBJ_CONTINUE, it is safe to
remove it.

The simplified code should help performance slightly and make
understanding the code easier.

Review: https://reviewboard.asterisk.org/r/2887/
........

Merged revisions 399937 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399938 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-27 17:11:22 +00:00
Kinsey Moore b22612110c Restore usefulness of the CEL Peer field
This change makes the CEL peer field useful again for BRIDGE_ENTER and
BRIDGE_EXIT events and fills the field with a comma-separated list of
all channels in the bridge other than the channel that is entering or
exiting the bridge.

Review: https://reviewboard.asterisk.org/r/2840/
(closes issue ASTERISK-22393)
........

Merged revisions 399912 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399913 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-27 14:08:23 +00:00
Matthew Jordan e7d49d28ea Fix a performance problem CDRs
There is a large performance price currently in the CDR engine. We currently
perform two ao2_callback calls on a container that has an entry for every
channel in the system. This is done to create matching pairs between channels
in a bridge.

As such, the portion of the CDR logic that this patch deals with is how we
make pairings when a channel enters a mixing bridge. In general, when a
channel enters such a bridge, we need to do two things:
 (1) Figure out if anyone in the bridge can be this channel's Party B.
 (2) Make pairings with every other channel in the bridge that is not already
     our Party B.

This is a two step process. In the first step, we look through everyone in the
bridge and see if they can be our Party B (single_state_process_bridge_enter).
If they can - yay! We mark our CDR as having gotten a Party B. If not, we keep
searching. If we don't find one, we wait until someone joins who can be our
Party B.

Step 2 is where we changed the logic
(handle_bridge_pairings and bridge_candidate_process). Previously, we would
first find candidates - those channels in the bridge with us - from the
active_cdrs_by_channel container. Because a channel could be a candidate if it
was Party B to an item in the container, the code implemented multiple
ao2_container callbacks to get all the candidates. We also had to store them
in another container with some other meta information. This was rather complex
and costly, particularly if you have 300 Local channels (600 channels!) going
at once.

Luckily, none of it is needed: when a channel enters a bridge (which is when
we're figuring all this stuff out), the bridge snapshot tells us the unique
IDs of everyone already in the bridge. All we need to do is:
 For all channels in the bridge:
   If the channel is us or our Party B that we got in step 1, skip it
   Compare us and the candidate to figure out who is Party A (based on some
       specific rules)
   If we are Party A:
      Make a new CDR for us, append it to our chain, and set the candidate as
          Party B
   If they are Party A:
      If they don't have a Party B:
        Make a new CDR for them, append us to their chain, and us as Party B
      Otherwise:
        Copy us over as Party B on their existing CDR.

This patch does that.

Because we now use channel unique IDs to find the candidates during bridging,
active_cdrs_by_channel now looks up things using uniqueid instead of channel
name. This makes the more complex code simpler; it does, however, have the
drawback that dialplan applications and functions will be slightly slower as
they have to iterate through the container looking for the CDR by name.
That's a small price to pay however as the bridging code will be called a lot
more often.

This patch also does two other minor changes:
 (1) It reduces the container size of the channels in a bridge snapshot to 1.
     In order to be predictable for multi-party bridges, the order of the
     channels in the container must be stable; that is, it must always devolve
     to a linked list.
 (2) CDRs and the multi-party test was updated to show the relationship between
     two dialed channels. You still want to know if they talked - previously,
     dialed channels were always ignored, which is wrong when they have
     managed to get a Party B.

(closes issue ASTERISK-22488)
Reported by: Richard Mudgett

Review: https://reviewboard.asterisk.org/r/2861/
........

Merged revisions 399666 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399667 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-24 18:10:20 +00:00
Richard Mudgett e77fba4b25 Fix module load errors for test_ari_model.so.
You cannot use a function pointer variable with an external function from
another dynamically loaded module because data variables are always
resolved even with RTLD_LAZY.

* Added wrapper functions for ast_ari_validate_int() and
ast_ari_validate_string() to use instead for the function pointer
variable.

(closes issue ASTERISK-22457)
Reported by: David M. Lee
........

Merged revisions 399207 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399208 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-16 18:36:22 +00:00
Richard Mudgett 2a371cd80b Restore Dial, Queue, and FollowMe 'I' option support.
The Dial, Queue, and FollowMe applications need to inhibit the bridging
initial connected line exchange in order to support the 'I' option.

* Replaced the pass_reference flag on ast_bridge_join() with a flags
parameter to pass other flags defined by enum ast_bridge_join_flags.

* Replaced the independent flag on ast_bridge_impart() with a flags
parameter to pass other flags defined by enum ast_bridge_impart_flags.

* Since the Dial, Queue, and FollowMe applications are now the only
callers of ast_bridge_call() and ast_bridge_call_with_flags(), changed the
calling contract to require the initial COLP exchange to already have been
done by the caller.

* Made all callers of ast_bridge_impart() check the return value.  It is
important.  As a precaution, I also made the compiler complain now if it
is not checked.

* Did some cleanup in parking_tests.c as a result of checking the
ast_bridge_impart() return value.

An independent, but associated change is:
* Reduce stack usage in ast_indicate_data() and add a dropping redundant
connected line verbose message.

(closes issue ASTERISK-22072)
Reported by: Joshua Colp

Review: https://reviewboard.asterisk.org/r/2845/
........

Merged revisions 399136 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399138 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-13 22:19:23 +00:00
Matthew Jordan 361d308b21 Update CDR Unit tests to reflect container changes in r398579
When a channel joins a multi-party bridge, the ordering of the CDRs that is
created is determined by the ordering of the channels who happen to be in that
bridge. When r398579 changed the number of buckets in the container to
something sensible, it changed the ordering that the CDRs was created in,
causing one of the multiparty tests to fail. This fixes the test with the
now expected ordering.
........

Merged revisions 398628 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398629 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-08 23:30:39 +00:00
Jonathan Rose 3e6923c3f6 unit tests: test_voicemail_api leaks stringfields from snapshots
(closes issue ASTERISK-22414)
Reported by: Corey Farrell
Patches:
    test_voicemail_api-leaks-11.patch uploaded by coreyfarrell (license 5909)
........

Merged revisions 398285 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 398286 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398287 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-04 21:37:01 +00:00
Richard Mudgett 9f1379686f test_substitution: Fix failing test.
Revert the -r392190 change.  The original test was correct.  The CDR code
was actually returning an unititialized buffer.
........

Merged revisions 398025 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398026 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30 17:11:06 +00:00
Richard Mudgett b27160406c test_substituition: Fix failed test reporting to actually report failure.
You cannot put the "Testing <blah> pass/fail" on a single line before
actually performing the test.  Now any additional failure information is
logged before the test pass/fail announcement.

* Added an additional CDR(answer,u) test.
........

Merged revisions 398018 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 398019 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 398023 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398024 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30 17:03:09 +00:00
David M. Lee 9bed50db41 optional_api: Fix linking problems between modules that export global symbols
With the new work in Asterisk 12, there are some uses of the
optional_api that are prone to failure. The details are rather involved,
and captured on [the wiki][1].

This patch addresses the issue by removing almost all of the magic from
the optional API implementation. Instead of relying on weak symbol
resolution, a new optional_api.c module was added to Asterisk core.

For modules providing an optional API, the pointer to the implementation
function is registered with the core. For modules that use an optional
API, a pointer to a stub function, along with a optional_ref function
pointer are registered with the core. The optional_ref function pointers
is set to the implementation function when it's provided, or the stub
function when it's now.

Since the implementation no longer relies on magic, it is now supported
on all platforms. In the spirit of choice, an OPTIONAL_API flag was
added, so we can disable the optional_api if needed (maybe it's buggy on
some bizarre platform I haven't tested on)

The AST_OPTIONAL_API*() macros themselves remained unchanged, so
existing code could remain unchanged. But to help with debugging the
optional_api, the patch limits the #include of optional API's to just
the modules using the API. This also reduces resource waste maintaining
optional_ref pointers that aren't used.

Other changes made as a part of this patch:
 * The stubs for http_websocket that wrap system calls set errno to
   ENOSYS.

 * res_http_websocket now properly increments module use count.

 * In loader.c, the while() wrappers around dlclose() were removed. The
   while(!dlclose()) is actually an anti-pattern, which can lead to
   infinite loops if the module you're attempting to unload exports a
   symbol that was directly linked to.

 * The special handling of nonoptreq on systems without weak symbol
   support was removed, since we no longer rely on weak symbols for
   optional_api.

 [1]: https://wiki.asterisk.org/wiki/x/wACUAQ

(closes issue ASTERISK-22296)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2797/
........

Merged revisions 397989 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397990 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30 13:40:27 +00:00
Matthew Jordan 75a99a4bdd Fix bucket unit tests
After the review for buckets was completed (r2715), the handling of names in
the bucket core was deferred to the wizards. As such, the bucket unit tests
cannot expect that passing a URI with a scheme specified but no actual resource
name will automatically fail. The tests have been updated to not make this
check.
........

Merged revisions 397630 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397631 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-25 18:12:42 +00:00
Matthew Jordan 447848a580 Fix the config_options_test
The config options test requires the entire configuration item to be transparent from
the documentation system. So we let it do that too.

As an aside, please do not use this power for evil. Documentation is your friend, and
you really should document your configurations. Hiding your module's configuration
information from the system attempting to enforce some sanity in the universe is something
only a Bond villain would contemplate.
........

Merged revisions 397628 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397629 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-25 18:00:46 +00:00
Joshua Colp dd33217762 Add the bucket API.
Bucket is a URI based API for the creation, retrieval, updating, and deletion
of "buckets" and files contained within them.

Review: https://reviewboard.asterisk.org/r/2715/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397600 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-23 21:49:47 +00:00
Matthew Jordan 31ab486627 Fix sorcery unit tests
When strict XML documentation checking was re-enabled, the test objects used in
sorcery would fail to register as the types were not marked internal and the
nodoc option wasn't used for the options. This fixes that problem, such that,
as one would hope, they once again pass.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397571 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-23 18:10:11 +00:00
Kinsey Moore 20dcc49d2e Make CEL behavior conform to the documentation
This modifies the behavior of the CEL engine to conform to documented
behavior for Asterisk 12 as defined on the wiki
https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+CEL+Specification

The primary changes deal with removal of the peer field from function
calls since it is no longer directly relevant to the bridging system
and removal of the layer of CDR-like business logic that was providing
a partial emulation of Asterisk 11 CEL functionality. With this change,
there is no longer a distinction between "bridges" and "conferences"
and all participation changes are denoted with bridge enter and bridge
exit messages.

This updates the CEL unit tests to handle these changes and simplifies
some of the macros used in the process.

This also fixes a segfault when attempting to ref a configuration that
failed to load.

Review: https://reviewboard.asterisk.org/r/2788/
(issue ASTERISK-21567)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397431 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-22 17:13:16 +00:00
Kinsey Moore d7f1f31270 Refactor CEL to avoid using the event system core
This removes usage of the event system for CEL backend data
distribution and strips unused pieces out of the event system.

Review: https://reviewboard.asterisk.org/r/2732/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-17 14:46:44 +00:00
Kinsey Moore 59753b1ea1 Strip down the old event system
This removes unused code, event types, IE pltypes, and event IE types
where possible and makes several functions private that were once
public. This includes a renumbering of the remaining event and IE types
which breaks binary compatibility with previous versions. The last
remaining consumers of the old event system (or parts thereof) are
main/security_events.c, res/res_security_log.c, tests/test_cel.c,
tests/test_event.c, main/cel.c, and the CEL backends.

Review: https://reviewboard.asterisk.org/r/2703/
(closes issue ASTERISK-22139)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396887 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-17 14:39:27 +00:00
Richard Mudgett e47d3db365 Doxygen comment tweaks.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396857 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-16 17:33:21 +00:00
David M. Lee f29d969a79 Stasis: address refcount races; implementation comments
Change r395954 reordered some stasis object destruction, which should
have been fine. Unfortunately, it caused some hard to reproduce issues
related to objects being accessed after they had been destroyed. The
patch in r396329 fixed the destruction order problem; this patch
addresses the underlying issue. A few other stasis-related fixes were
also added.

 * Add ref-bumps around areas where objects may get transitively
   destroyed. (For example, where we lock a topic, unref a subscription,
   which unrefs the topic, which explodes the topic when we try to
   unlock it.)

 * Wrote an extensive doxygen page about Stasis implementation,
   relationships between objects, lifecycles of objects, how the
   refcounting works, etc. Many other comments were added, corrected, or
   cleaned up.

 * Added an assert to the topic dtor to catch extra ref decrements.

 * Fixed type used after destruction errors for graceful shutdown in
   stasis_channels.c.

 * I added two unit tests in an attempt to catch destruction order
   issues. Since the underlying cause is a race condition, though, the
   tests rarely failed even when the code was wrong.

 * Fixed a leak in stasis_cache_pattern.c.

(closes issue ASTERISK-22243)
Review: https://reviewboard.asterisk.org/r/2746/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396842 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-16 16:03:34 +00:00
Joshua Colp 0f31413bca Tweak comment for why usleep is used.
........

Merged revisions 396656 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 396657 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396658 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-14 19:06:59 +00:00
Joshua Colp a0aa754a39 Tweak test_hashtab_thrash test to allow the critical threads to execute.
Depending on certain conditions it was possible for the hashtab counting thread
to starve other threads, preventing them from executing in the expected fashion.
This change adds a sleep to allow the others to do what they need to do. While
this doesn't thrash the hashtab as much as previously, it at least works.

(closes issue ASTERISK-22276)
Reported by: Matt Jordan
........

Merged revisions 396619 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 396620 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396621 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-14 18:10:08 +00:00
David M. Lee 94ee8f2e33 Missed a spot in r396559
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396560 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-13 15:11:44 +00:00
David M. Lee 46356c1fcb Fix build warnings when printf a tv_usec.
The debug logs added in r396528 neglected to account for suseconds_t
being an int.

See r392076 for more info.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-13 14:57:34 +00:00
Matthew Jordan 8f90378b34 Pipe test output through test object not stdout
Otherwise, it doesn't show up in the automated test failures


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396535 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-10 20:29:56 +00:00
Matthew Jordan d759158f22 Add some debugging when test_hashtab_thrash fails
Disabling DEBUG_THREADS caused this test to fail on the 32-bit build agent.
Adding some debugging to see why it thinks the test is timing out.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-10 19:45:31 +00:00
Richard Mudgett 1d57078837 Fix stasis/core unit test. Should have had the CR/LF.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396480 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-08 22:57:06 +00:00
Richard Mudgett 154f45dd02 Add missing CR/LF to FakeMI stasis test AMI event.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396463 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-08 20:52:49 +00:00
David M. Lee b97d318b7b Tweak caching topics to fix CEL tests
The Stasis changes in r395954 had an unanticipated side effect: messages
published directly to an _all topic does not get forwarded to the
corresponding caching topic.

This patch fixes that by changing how caching topics forward messages,
and how the caching pattern forwards are setup.

For the caching pattern, the all_topic is forwarded to the
all_topic_cached. This forwards messages published directly to the
all_topic to all_topic_cached.

In order to avoid duplicate messages on all_topic_cached, caching topics
were changed to no longer forward uncached messages. Subscribers to an
individual caching topic should only expect to receive cache updates,
and subscription change messages. Since individual caching topics are
new, this shouldn't be a problem.

There are a few minor changes to the pre-cache split behavior.

 * For topics changed to use the caching pattern, the all_topic_cached
   will forward snapshots in addition to cache updates. Since
   subscribers by design ignore unexpected messages, this should be
   fine.

 * Caching topics that don't use the caching pattern no longer forward
   non-cache updates. This makes no difference for the current caching
   topics.

   * mwi_topic_cached, channel_by_name_topic and
     presence_state_topic_cached have no subscribers

   * device_state_topic_cached's only subscriber only processes cache
     udpates

(issue ASTERISK-22243)
Review: https://reviewboard.asterisk.org/r/2738


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396329 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-06 14:28:23 +00:00
David M. Lee 10c91bc96e Address JSON thread safety issues.
In tracking down some unit tests failures, I ended up reading the fine
print[1] regarding Jansson's thread safety.

In short:
 1. Ref-counting is non-atomic.
 2. json_dumps() and friends are not thread safe.

This patch adds locking where necessary to our ast_json_* wrapper API,
with documentation in json.h describing the thread safety limitations of
the API.

 [1]: http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety

Review: https://reviewboard.asterisk.org/r/2716/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396119 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-02 14:27:35 +00:00
Matthew Jordan 2fdde7dc14 Fix test modules
More missing include files. :-\


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396062 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-02 03:12:38 +00:00
Matthew Jordan 38236e54a8 Remove dead code from features.c; refactor pickup code into pickup.c
This patch does the following:
 * It moves the pickup code out of features.c and into pickup.c
 * It removes the vast majority of dead code out of features.c. In particular,
   this includes the parking code.

(issue ASTERISK-22134)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-02 02:32:44 +00:00
David M. Lee e1b959ccbb Split caching out from the stasis_caching_topic.
In working with res_stasis, I discovered a significant limitation to
the current structure of stasis_caching_topics: you cannot subscribe
to cache updates for a single channel/bridge/endpoint/etc.

To address this, this patch splits the cache away from the
stasis_caching_topic, making it a first class object. The stasis_cache
object is shared amongst individual stasis_caching_topics that are
created per channel/endpoint/etc. These are still forwarded to global
whatever_all_cached topics, so their use from most of the code does
not change.

In making these changes, I noticed that we frequently used a similar
pattern for bridges, endpoints and channels:

     single_topic  ---------------->  all_topic
           ^
           |
     single_topic_cached  ----+---->  all_topic_cached
                              |
                              +---->  cache

This pattern was extracted as the 'Stasis Caching Pattern', defined in
stasis_caching_pattern.h. This avoids a lot of duplicate code between
the different domain objects.

Since the cache is now disassociated from its upstream caching topics,
this also necessitated a change to how the 'guaranteed' flag worked
for retrieving from a cache. The code for handling the caching
guarantee was extracted into a 'stasis_topic_wait' function, which
works for any stasis_topic.

(closes issue ASTERISK-22002)
Review: https://reviewboard.asterisk.org/r/2672/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395954 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-01 13:49:34 +00:00
Kinsey Moore a673c9ed1d Disable CEL tests that need rearchitecting to operate properly
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395881 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-31 15:27:29 +00:00
Kinsey Moore 858fc5a648 Enforce conference exit order for CEL tests
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395837 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-31 03:49:44 +00:00
Kinsey Moore 5d160491b0 Clean up and improve test_cel
Improve reliability of attended transfer merge and link tests.
Stop using ast_log(LOG_ERROR, ...); in favor of ast_test_status_update
Remove fred and eve channel helpers since they are not necessary


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395653 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-29 14:51:00 +00:00
Kinsey Moore d8956f690e Rename everything Stasis-HTTP to ARI
This renames all files and API calls from several variants of
Stasis-HTTP to ARI including:
* Stasis-HTTP -> ARI
* STASIS_HTTP -> ARI
* stasis_http -> ari (ast_ari for global symbols, file names as well)
* stasis http -> ARI

Review: https://reviewboard.asterisk.org/r/2706/
(closes issue ASTERISK-22136)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395603 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-27 23:11:02 +00:00
Kinsey Moore fc05248bd1 Improve reliability of bridge merge CEL test
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395588 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-27 04:05:03 +00:00
Matthew Jordan 56a90d435c Fix incorrect reference to stasis/bridging.h
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395381 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-25 04:18:05 +00:00
Matthew Jordan cafc115896 A great big renaming patch
This patch renames the bridging* files to bridge*. This may seem pedantic
and silly, but it fits better in line with current Asterisk naming conventions:
* channel is not "channeling"
* monitor is not "monitoring"
etc.

A bridge is an object. It is a first class citizen in Asterisk. "Bridging" is
the act of using a bridge on a set of channels - and the API that fulfills that
role is more than just the action.

(closes issue ASTERISK-22130)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395378 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-25 04:06:32 +00:00
David M. Lee fec667646f Fix bridge/channel AMI event ordering issues
The stasis_cache_update messages are somewhat cumbersome to handle
with the stasis_message_router. Since all updates have the same
message type, they are normally handled with the same route.

Since caching itself is a first class component of stasis-core, it
makes sense for the router to handle the cache update messages itself.
This patch adds stasis_message_router_add_cache_update() and
stasis_message_router_remove_cache_update() to handle the routing of
stasis_cache_update messages.

This patch also corrects an issue with manager_{bridging,channels}.c,
where events might be reordered. The reordering occurs because the
components use different message routers, which they needed because
they both needed to route cache update messages. They now both use
manager's router, and add cache routes for just the cache updates they
are interested in.

(closes issue ASTERISK-22038)
Review: https://reviewboard.asterisk.org/r/2677/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395118 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-23 13:39:50 +00:00
Kinsey Moore 8aac17a3ee Make the CEL blind transfer test pass consistently
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395074 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-22 20:42:28 +00:00
Kinsey Moore c3b8939be8 Add CEL local optimization record type
This adds a new CEL event type, AST_CEL_LOCAL_OPTIMIZE, to represent
local channel optimizations. Local channel optimizations were one of
several things conveyed by the now defunct BRIDGE_UPDATE event type.
This also adds a unit test to test generation of this new CEL event.

Review: https://reviewboard.asterisk.org/r/2676/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394870 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-20 13:25:05 +00:00
Kinsey Moore 684c83b29b Add transfer support to CEL
This adds CEL support for blind and attended transfers and call pickup.
During the course of adding this functionality I noticed that
CONF_ENTER, CONF_EXIT, and BRIDGE_TO_CONF events are particularly
useless without a bridge identifier, so I added that as well.

This adds tests for blind transfers, several types of attended
transfers, and call pickup.

The extra field in CEL records now consists of a JSON blob whose fields
are defined on a per-event basis.

Review: https://reviewboard.asterisk.org/r/2658/
(closes issue ASTERISK-21565)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394858 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-20 13:10:22 +00:00
Richard Mudgett 40ce5e0d18 Change ast_hangup() to return void and be NULL safe.
Since ast_hangup() is effectively a channel destructor, it should be a
void function.

* Make the few silly callers checking the return value no longer do so.
Only the CDR and CEL unit tests checked the return value.

* Make all callers take advantage of the NULL safe change and remove the
NULL check before the call.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-17 22:30:28 +00:00
David M. Lee c3ffc13e41 Fixed intermittent crash when loading test_json.so
The JSON test attempted an overly clever use of RAII_VAR to run code
at the beginning and end of each test, in order to validate that no
JSON objects were leaked during the test.

The problem is that the validation code would run during the initial
load, when the tests were initialized. This happens during startup,
when other parts of the system might actively be allocating and
freeing JSON objects.

This patch changes the RAII_VAR to use the new
ast_test_register_{init,cleanup} functions to run the validations
properly.

(closes issue ASTERISK-21978)
Review: https://reviewboard.asterisk.org/r/2669/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394203 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-12 18:23:39 +00:00
David M. Lee c2bb638f1f Correct test_cel cleanup.
When I corrected the CEL test crash in r394037, I didn't quite pay attention
to how the globals and locals were being shuffled around in the cleanup
callback. I removed the nulling of the global variables, which caused them
to be double cleaned.

This patch puts the global nulling code back (since the vars are cleaned up
by RAII_VARs), and removes the explicit ao2_cleanup() (since they were no-ops,
because the variables had just been nulled).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394089 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-11 15:37:51 +00:00
David M. Lee d3939686cd test_voicemail_api: fix warning found by gcc-4.8
The voicemail_api test had code like strncmp(a, b, sizeof(a)), but a was a
char pointer, instead of a literal or char array. This meant that sizeof was
the size of the pointer, not the length of the string.

Since the string is in a stringfield and should be null terminated, I just
changed it to a plain strcmp.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394050 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-11 04:34:49 +00:00
David M. Lee 31a58b2604 Fixed some CEL test crashes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394037 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-11 02:02:48 +00:00
David M. Lee 951c87634f Fix int width problem for 32-bit
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393679 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-04 13:18:45 +00:00
David M. Lee a75fd32212 ARI - channel recording support
This patch is the first step in adding recording support to the
Asterisk REST Interface.

Recordings are stored in /var/spool/recording. Since recordings may be
destructive (overwriting existing files), the API rejects attempts to
escape the recording directory (avoiding issues if someone attempts to
record to ../../lib/sounds/greeting, for example).

(closes issue ASTERISK-21594)
(closes issue ASTERISK-21581)
Review: https://reviewboard.asterisk.org/r/2612/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393550 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-03 17:58:45 +00:00
David M. Lee c9a3d4562d Update events to use Swagger 1.3 subtyping, and related aftermath
This patch started with the simple idea of changing the /events data
model to be more sane. The original model would send out events like:

    { "stasis_start": { "args": [], "channel": { ... } } }

The event discriminator was the field name instead of being a value in
the object, due to limitations in how Swagger 1.1 could model objects.
While technically sufficient in communicating event information, it was
really difficult to deal with in terms of client side JSON handling.

This patch takes advantage of a proposed extension[1] to Swagger which
allows type variance through the use of a discriminator field. This had
a domino effect that made this a surprisingly large patch.

 [1]: https://groups.google.com/d/msg/wordnik-api/EC3rGajE0os/ey_5dBI_jWcJ

In changing the models, I also had to change the swagger_model.py
processor so it can handle the type discriminator and subtyping. I took
that a big step forward, and using that information to generate an
ari_model module, which can validate a JSON object against the Swagger
model.

The REST and WebSocket generators were changed to take advantage of the
validators. If compiled with AST_DEVMODE enabled, JSON objects that
don't match their corresponding models will not be sent out. For REST
API calls, a 500 Internal Server response is sent. For WebSockets, the
invalid JSON message is replaced with an error message.

Since this took over about half of the job of the existing JSON
generators, and the .to_json virtual function on messages took over the
other half, I reluctantly removed the generators.

The validators turned up all sorts of errors and inconsistencies in our
data models, and the code. These were cleaned up, with checks in the
code generator avoid some of the consistency problems in the future.

 * The model for a channel snapshot was trimmed down to match the
   information sent via AMI. Many of the field being sent were not
   useful in the general case.
 * The model for a bridge snapshot was updated to be more consistent
   with the other ARI models.

Another impact of introducing subtyping was that the swagger-codegen
documentation generator was insufficient (at least until it catches up
with Swagger 1.2). I wanted it to be easier to generate docs for the API
anyways, so I ported the wiki pages to use the Asterisk Swagger
generator. In the process, I was able to clean up many of the model
links, which would occasionally give inconsistent results on the wiki. I
also added error responses to the wiki docs, making the wiki
documentation more complete.

Finally, since Stasis-HTTP will now be named Asterisk REST Interface
(ARI), any new functions and files I created carry the ari_ prefix. I
changed a few stasis_http references to ari where it was non-intrusive
and made sense.

(closes issue ASTERISK-21885)
Review: https://reviewboard.asterisk.org/r/2639/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393529 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-03 16:32:41 +00:00
David M. Lee dcf03554a0 Shuffle RESTful URL's around.
This patch moves the RESTful URL's around to more appropriate
locations for release.

The /stasis URL's are moved to /ari, since Asterisk REST Interface was
a more appropriate name than Stasis-HTTP. (Most of the code still has
stasis_http references, but they will be cleaned up after there are no
more outstanding branches that would have merge conflicts with such a
change).

A larger change was moving the ARI events WebSocket off of the shared
/ws URL to its permanent home on /ari/events. The Swagger code
generator was extended to handle "upgrade: websocket" and
"websocketProtocol:" attributes on an operation.

The WebSocket module was modified to better handle WebSocket servers
that have a single registered protocol handler. If a client
connections does not specify the Sec-WebSocket-Protocol header, and
the server has a single protocol handler registered, the WebSocket
server will go ahead and accept the client for that subprotocol.

(closes issue ASTERISK-21857)
Review: https://reviewboard.asterisk.org/r/2621/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-03 16:32:00 +00:00
Kinsey Moore 6e3a5d2d48 Add CEL unit tests and do some cleanup
This adds several unit tests for CEL functionality and provides the
requisite framework for creating additional unit tests.

This also cleans up some reference leaks that were occurring in
Stasis-Core message callback code.

Review: https://reviewboard.asterisk.org/r/2646/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393410 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-02 14:01:53 +00:00
Matthew Jordan ca61a05506 Handle an originated channel being sent into a non-empty bridge
Originated channels are a bit odd - they are technically a dialed channel (thus
the party B or peer) but, since there is no caller, they are treated as the
party A. When entering into a bridge that already contains participants, the CDR
engine - if the CDR record is in the Dial state - attempts to match the person
entering the bridge with an existing participant. The idea is that if you dialed
someone and the person you dialed is already in the bridge, you don't need a new
CDR record, the existing CDR record describes the relationship.

Unfortunately, for an originated channel, there is no Party B. If no one was in
the bridge this didn't cause any issues; however, if participants were in the
bridge the CDR engine would attempt to match a non-existant Party B on the
channel's CDR record and explode.

This patch fixes that, and a unit test has been added to cover this case.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393164 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-28 17:31:33 +00:00
David M. Lee f33d074d1a Few more menuselect fixes missed in r392777
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392779 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-24 22:05:28 +00:00
Joshua Colp c3f9ddc9ad Add missing ast_sorcery_generic_alloc conversions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392647 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-23 13:24:18 +00:00
Joshua Colp a330d0867e Make sorcery details opaque and add extended fields.
Sorcery specific object information is now opaque and allocated with the object.
This means that modules do not need to be recompiled if the sorcery specific part
is changed. It also means that sorcery can store additional information on objects
and ensure it is freed or the reference count decreased when the object goes away.

To facilitate the above a generic sorcery allocator function has been added which
also ensures that allocated objects do not have a lock.

Extended fields have been added thanks to all of the above which allows specific fields
to be marked as extended, and thus simply stored as-is within the object. Type safety
is *NOT* enforced on these fields. A consumer of them has to query and ultimately perform
their own safety check. What does this mean? Extra modules can extend already defined
structures without having to modify them.

Tests have also been included to verify extended field functionality.

Review: https://reviewboard.asterisk.org/r/2585/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392586 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-22 14:26:25 +00:00
Matthew Jordan da1f4f0c3d Fix the test_substitution test
In r391947, the CDR function was modified such that it will return a
value for the start,answer, and end times if asked. That time will just
be 0 if it hasn't happened yet.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392190 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-18 22:37:09 +00:00
Matthew Jordan 6258bbe7bd Update Asterisk's CDRs for the new bridging framework
This patch is the initial push to update Asterisk's CDR engine for the new
bridging framework. This patch guts the existing CDR engine and builds the new
on top of messages coming across Stasis. As changes in channel state and bridge
state are detected, CDRs are built and dispatched accordingly. This
fundamentally changes CDRs in a few ways.
(1) CDRs are now *very* reflective of the actual state of channels and bridges.
    This means CDRs track well with what an actual channel is doing - which
    is useful in transfer scenarios (which were previously difficult to pin
    down). It does, however, mean that CDRs cannot be 'fooled'. Previous
    behavior in Asterisk allowed for CDR applications, channels, and other
    properties to be spoofed in parts of the code - this no longer works.
(2) CDRs have defined behavior in multi-party scenarios. This behavior will not
    be what everyone wants, but it is a defined behavior and as such, it is
    predictable.
(3) The CDR manipulation functions and applications have been overhauled. Major
    changes have been made to ResetCDR and ForkCDR in particular. Many of the
    options for these two applications no longer made any sense with the new
    framework and the (slightly) more immutable nature of CDRs.

There are a plethora of other changes. For a full description of CDR behavior,
see the CDR specification on the Asterisk wiki.

(closes issue ASTERISK-21196)

Review: https://reviewboard.asterisk.org/r/2486/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-17 03:00:38 +00:00
David M. Lee dbdb2b1b3a Add vtable and methods for to_json and to_ami for Stasis messages
When a Stasis message type is defined in a loadable module, handling
those messages for AMI and res_stasis events can be cumbersome.

This patch adds a vtable to stasis_message_type, with to_ami and
to_json virtual functions. These allow messages to be handled
abstractly without putting module-specific code in core.

As an example, the VarSet AMI event was refactored to use the to_ami
virtual function.

(closes issue ASTERISK-21817)
Review: https://reviewboard.asterisk.org/r/2579/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391403 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-11 15:46:35 +00:00
Kinsey Moore 63c7141421 Ensure that all unit tests compile with the cache clear rework in place
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-07 16:22:24 +00:00
Kinsey Moore 759a7e4a30 Rework stasis cache clear events
Stasis cache clear message payloads now consist of a stasis_message
representative of the message to be cleared from the cache. This allows
multiple parallel caches to coexist and be cleared properly by the same
cache clear message even when keyed on different fields.

This change fixes a bug where multiple cache clears could be posted for
channels. The cache clear is now produced in the destructor instead of
ast_hangup.

Additionally, dummy channels are no longer capable of producing channel
snapshots.

Review: https://reviewboard.asterisk.org/r/2596


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-07 12:56:56 +00:00
Jonathan Rose b90bba7a30 Stasis: Update security events to use Stasis
Also moves ACL messages to the security topic and gets rid of the
ACL topic

(closes issue ASTERISK-21103)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2496/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-17 17:36:10 +00:00
Kinsey Moore 2a9cbd693e Move JSON event generators into separate modules
This moves the JSON event generators out of the Stasis-HTTP modules and
into standalone JSON-related counterparts so that Stasis-HTTP and
res_stasis can depend on them without creating dependency cycles. This
also provides a future location for Swagger Model validator functions
once the generators for that code are written.

Review: https://reviewboard.asterisk.org/r/2534/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388668 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-14 12:47:52 +00:00
David M. Lee 4666079b05 Address unload order issues for res_stasis* modules
I've noticed when doing a graceful shutdown that the res_stasis_http.so
module gets unloaded before the modules that use it, which causes some
asserts during their unload.

While r386928 was a quick hack to get it to not assert and die, this
patch increases the use counts on res_stasis.so and res_stasis_http.so
properly. It's a bigger change than I expected, hence the review instead
of just committing it.

Review: https://reviewboard.asterisk.org/r/2489/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-10 17:12:57 +00:00
David M. Lee 07e2eb71e9 Fixed set-but-not-used warning caught by newer GCC
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388014 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-08 19:00:55 +00:00
David M. Lee 0eb4cf8c19 Remove required type field from channel blobs
When we first introduced the channel blob types, the JSON blobs were
self identifying by a required "type" field in the JSON object
itself. This, as it turns out, was a bad idea.

When we introduced the message router, it was useless for routing based
on the JSON type. And messages had two type fields to check: the
stasis_message_type() of the message itself, plus the type field in the
JSON blob (but only if it was a blob message).

This patch corrects that mistake by removing the required type field
from JSON blobs, and introducing first class stasis_message_type objects
for the actual message type.

Since we now will have a proliferation of message types, I introduced a
few macros to help reduce the amount of boilerplate necessary to set
them up.

Review: https://reviewboard.asterisk.org/r/2509


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388005 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-08 18:34:50 +00:00
David M. Lee e06e519a90 Initial support for endpoints.
An endpoint is an external device/system that may offer/accept
channels to/from Asterisk. While this is a very useful concept for end
users, it is surprisingly not a core concept within Asterisk itself.

This patch defines ast_endpoint as a separate object, which channel
drivers may use to expose their concept of an endpoint. As the channel
driver creates channels, it can use ast_endpoint_add_channel() to
associate channels to the endpoint. This updated the endpoint
appropriately, and forwards all of the channel's events to the
endpoint's topic.

In order to avoid excessive locking on the endpoint object itself, the
mutable state is not accessible via getters. Instead, you can create a
snapshot using ast_endpoint_snapshot_create() to get a consistent
snapshot of the internal state.

This patch also includes a set of topics and messages associated with
endpoints, and implementations of the endpoint-related RESTful
API. chan_sip was updated to create endpoints with SIP peers, but the
state of the endpoints is not updated with the state of the peer.

Along for the ride in this patch is a Stasis test API. This is a
stasis_message_sink object, which can be subscribed to a Stasis
topic. It has functions for blocking while waiting for conditions in
the message sink to be fulfilled.

(closes issue ASTERISK-21421)
Review: https://reviewboard.asterisk.org/r/2492/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387932 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-08 13:39:08 +00:00
Joshua Colp 40074542bf Add support for observers and JSON objectset creation to sorcery.
This change adds the ability for modules to add themselves as observers
to sorcery object types. Observers can be notified when objects are
created, updated, or deleted as well as when the object type is loaded or
reloaded. Observer notifications are done using a thread pool in a serialized
fashion so the caller of the sorcery API calls is minimally impacted.

This also adds the ability to create JSON changesets of a sorcery object.

Tests are also present to confirm all of the above functionality.

Review: https://reviewboard.asterisk.org/r/2477/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-06 13:04:08 +00:00
David M. Lee e2cd14876f Just a couple of Stasis-HTTP nitpick fixes.
* Fixed crash when res_stasis_http is unloaded before the
  implementation modules.
* Cleaned up test initialization for test_stasis_http.so.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386928 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-30 13:37:09 +00:00
Joshua Colp 02be50b1ac Add support for a realtime sorcery module.
This change does the following:

1. Adds the sorcery realtime module
2. Adds unit tests for the sorcery realtime module
3. Changes the realtime core to use an ast_variable list instead of variadic arguments
4. Changes all realtime drivers to accept an ast_variable list

Review: https://reviewboard.asterisk.org/r/2424/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386731 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-27 12:01:29 +00:00
Mark Michelson 74f2318051 Merge the pimp_my_sip branch into trunk.
The pimp_my_sip branch is being merged at this point because
it offers basic functionality, and from an API standpoint, things
are complete.

SIP work is *not* feature-complete; however, with the completion
of the SUBSCRIBE/NOTIFY API, all APIs (except a PUBLISH API) have
been created, and thus it is possible for developers to attempt
to create new SIP work.

API documentation can be found in the doxygen in the code, but
usability documentation is still lacking.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-25 18:25:31 +00:00
David M. Lee 1c21b8575b This patch adds a RESTful HTTP interface to Asterisk.
The API itself is documented using Swagger, a lightweight mechanism for
documenting RESTful API's using JSON. This allows us to use swagger-ui
to provide executable documentation for the API, generate client
bindings in different languages, and generate a lot of the boilerplate
code for implementing the RESTful bindings. The API docs live in the
rest-api/ directory.

The RESTful bindings are generated from the Swagger API docs using a set
of Mustache templates.  The code generator is written in Python, and
uses Pystache. Pystache has no dependencies, and be installed easily
using pip. Code generation code lives in rest-api-templates/.

The generated code reduces a lot of boilerplate when it comes to
handling HTTP requests. It also helps us have greater consistency in the
REST API.

(closes issue ASTERISK-20891)
Review: https://reviewboard.asterisk.org/r/2376/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386232 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-22 14:58:53 +00:00
Kinsey Moore 191cf99ae1 Move device state distribution to Stasis-core
In the move from Asterisk's event system to Stasis, this makes
distributed device state aggregation always-on, removes unnecessary
task processors where possible, and collapses aggregate and
non-aggregate states into a single cache for ease of retrieval. This
also removes an intermediary step in device state aggregation.

Review: https://reviewboard.asterisk.org/r/2389/
(closes issue ASTERISK-21101)
Patch-by: Kinsey Moore <kmoore@digium.com>


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@385860 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-16 15:33:59 +00:00
David M. Lee c599aca553 Moved core logic from app_stasis to res_stasis
After some discussion on asterisk-dev, it was decided that the bulk of
the logic in app_stasis actually belongs in a resource module instead
of the application module.

This patch does that, leaves the app specific stuff in app_stasis, and
fixes up everything else to be consistent with that change.

 * Renamed test_app_stasis to test_res_stasis
 * Renamed app_stasis.h to stasis_app.h
   * This is still stasis application support, even though it's no
     longer in an app_ module. The name should never have been tied to
     the type of module, anyways.
 * Now that json isn't a resource module anymore, moved the
   ast_channel_snapshot_to_json function to main/stasis_channels.c,
   where it makes more sense.

Review: https://reviewboard.asterisk.org/r/2430/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@385742 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-15 16:43:47 +00:00
Matthew Jordan b8d4e573f1 Add multi-channel Stasis messages; refactor Dial AMI events to Stasis
This patch does the following:
 * A new Stasis payload has been defined for multi-channel messages. This
   payload can store multiple ast_channel_snapshot objects along with a single
   JSON blob. The payload object itself is opaque; the snapshots are stored
   in a container keyed by roles. APIs have been provided to query for and
   retrieve the snapshots from the payload object.
 * The Dial AMI events have been refactored onto Stasis. This includes dial
   messages in app_dial, as well as the core dialing framework. The AMI events
   have been modified to send out a DialBegin/DialEnd events, as opposed to
   the subevent type that was previously used.
 * Stasis messages, types, and other objects related to channels have been
   placed in their own file, stasis_channels. Unit tests for some of these
   objects/messages have also been written.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384910 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-08 14:26:37 +00:00
David M. Lee a2a53cc306 Stasis application WebSocket support
This is the API that binds the Stasis dialplan application to external
Stasis applications. It also adds the beginnings of WebSocket
application support.

This module registers a dialplan function named Stasis, which is used
to put a channel into the named Stasis app. As a channel enters and
leaves the Stasis diaplan application, the Stasis app receives a
'stasis-start' and 'stasis-end' events.

Stasis apps register themselves using the stasis_app_register and
stasis_app_unregister functions. Messages are sent to an application
using stasis_app_send.

Finally, Stasis apps control channels through the use of the
stasis_app_control object, and the family of stasis_app_control_*
functions.

Other changes along for the ride are:
 * An ast_frame_dtor function that's RAII_VAR safe
 * Some common JSON encoders for name/number, timeval, and
   context/extension/priority

Review: https://reviewboard.asterisk.org/r/2361/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384879 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-08 13:27:45 +00:00
Joshua Colp 426095bc55 Add a res_sorcery_astdb module which uses the astdb to persist objects.
Review: https://reviewboard.asterisk.org/r/2420/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384857 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-06 16:00:20 +00:00
David M. Lee b23e8e1950 stasis: Fixed message ordering issues when forwarding
This patch fixes an issue of message ordering that occurs when
multiple topics are forwarded to an aggregator topic (such as
ast_channel_topic_all()).

It is (very reasonably) expected that the rules governing message
dispatch order still apply, so long as the messages start from the
same thread, and are received by the same subscription. Because the
existing code had an additional layer of dispatching via the Stasis
thread pool for forwards, those promises couldn't be kept.

Forwarding subscriptions no longer have their own mailbox, and now
dispatch directly from the forwarding topic's stasis_publish()
call. This means that the topic's lock is held for the duration of not
only a message's dispatch, but the dispatch of all the forwards. This
shouldn't be a problem right now, but if an aggregator topic had many
subscribers, it could become a problem. But I figure we can write more
clever code when the time comes, if necessary.

Review: https://reviewboard.asterisk.org/r/2419/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384413 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-01 13:37:51 +00:00
Richard Mudgett a1c94fece8 Add uuid wrapper API call ast_uuid_generate_str().
* Updated test_uuid.c to test the new API call.

* Made system use the new API call to eliminate "10's of lines" where
used.

* Fixed untested ast_strdup() return in stasis_subscribe() by eliminating
the need for it.  struct stasis_subscription now contains the uniqueid[]
string.

* Fixed some issues in exchangecal_write_event():
  Create uid with enough space for a UUID string to avoid a realloc.
  Fix off by one error if the calendar event provided a UUID string.
  There is no need to check for NULL before calling ast_free().


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384302 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-28 23:59:20 +00:00
Kinsey Moore 71206544a7 Break the world. Stasis message type accessors should now all be named correctly.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384261 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-28 15:45:18 +00:00
David M. Lee cf9324b25e Move more channel events to Stasis; move res_json.c to main/json.c.
This patch started out simply as fixing the bouncing tests introduced
in r382685, but required some other changes to give it a decent
implementation.

To fix the bouncing tests, the UserEvent and Newexten AMI events
needed to be refactored to dispatch via Stasis. Dispatching directly
to AMI resulted in those events sometimes getting ahead of the
associated Newchannel events, which would understandably confuse anyone.

I found that instead of creating a zillion different message types and
structures associated with them, it would be preferable to define a
message type that has a channel snapshot and a blob of structured data
with a small bit of additional information. The JSON object model
provides a very nice way of representing structured data, so I went
with that.

 * Move JSON support from res_json.c to main/json.c
   * Made libjansson-dev a required dependency
 * Added an ast_channel_blob message type, which has a channel
   snapshot and JSON blob of data.
 * Changed UserEvent and Newexten events so that they are dispatched
   via ast_channel_blob messages on the channel's topic.
 * Got rid of the ast_channel_varset message; used ast_channel_blob
   instead.
 * Extracted the manager functions converting Stasis channel events to
   AMI events into manager_channel.c.

(issue ASTERISK-21096)
Review: https://reviewboard.asterisk.org/r/2381/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-22 14:06:46 +00:00
Joshua Colp 07d01e1c41 Pass the sorcery instance to wizards for CUD operations as well as retrieve.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383405 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-20 14:52:23 +00:00
David M. Lee 49e3489cac A simplistic router for stasis_message's.
Often times, when subscribing to a topic, one wants to handle
different message types differently. While one could cascade if/else
statements through the subscription handler, it is much cleaner to
specify a different callback for each message type. The
stasis_message_router is here to help!

A stasis_message_router is constructed for a particular stasis_topic,
which is subscribes to. Call stasis_message_router_unsubscribe() to
cancel that subscription.

Once constructed, routes can be added using
stasis_message_router_add() (or stasis_message_router_set_default()
for any messages not handled by other routes). There may be only one
route per stasis_message_type. The route's callback is invoked just as
if it were a callback for a subscription; but it only gets called for
messages of the specified type.

(issue ASTERISK-20887)
Review: https://reviewboard.asterisk.org/r/2390/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383242 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-15 17:35:16 +00:00
Kinsey Moore ccb5526508 Take advantage of the fact that stasis_unsubscribe now returns NULL
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-15 13:04:52 +00:00
Kinsey Moore c6b06e40dc Add message dump capability to stasis cache layer
The cache dump mechanism allows the developer to retreive multiple
items of a given type (or of all types) from the cache residing in a
stasis caching topic in addition to the existing single-item cache
retreival mechanism.  This also adds to the caching unit tests to
ensure that the new cache dump mechanism is functioning properly.

Review: https://reviewboard.asterisk.org/r/2367/
(issue ASTERISK-21097)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382705 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-08 16:00:14 +00:00
David M. Lee 4edd8be35c This patch adds a new message bus API to Asterisk.
For the initial use of this bus, I took some work kmoore did creating
channel snapshots. So rather than create AMI events directly in the
channel code, this patch generates Stasis events, which manager.c uses
to then publish the AMI event.

This message bus provides a generic publish/subscribe mechanism within
Asterisk. This message bus is:

 - Loosely coupled; new message types can be added in seperate modules.
 - Easy to use; publishing and subscribing are straightforward
   operations.

In addition to basic publish/subscribe, the patch also provides
mechanisms for message forwarding, and for message caching.

(issue ASTERISK-20887)
(closes issue ASTERISK-20959)
Review: https://reviewboard.asterisk.org/r/2339/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382685 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-08 15:15:13 +00:00
Joshua Colp a4f45a2c95 Add support for registering a sorcery handler which supports multiple fields using a regex.
Review: https://reviewboard.asterisk.org/r/2332/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382340 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-01 18:01:56 +00:00
Joshua Colp cce1c9547f Add support for retrieving multiple objects from sorcery using a regex on their id.
Review: https://reviewboard.asterisk.org/r/2329/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-16 16:24:21 +00:00
David M. Lee 222e8a3afb Add a serializer interface to the threadpool
This patch adds the ability to create a serializer from a thread pool. A
serializer is a ast_taskprocessor with the same contract as a default
taskprocessor (tasks execute serially) except instead of executing out
of a dedicated thread, execution occurs in a thread from a
ast_threadpool. Think of it as a lightweight thread.

While it guarantees that each task will complete before executing the
next, there is no guarantee as to which thread from the pool individual
tasks will execute. This normally only matters if your code relys on
thread specific information, such as thread locals.

This patch also fixes a bug in how the 'was_empty' parameter is computed
for the push callback, and gets rid of the unused 'shutting_down' field.

Review: https://reviewboard.asterisk.org/r/2323/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381326 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-12 21:45:59 +00:00
David M. Lee f2b9c12704 Minor fixes to res_json and test_json.
* Made input checking more consistent with other Asterisk code
* Added validation to ast_json_dump_new_file
* Fixed tests for ownereship semantics

(issue ASTERISK-20887)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-11 20:39:11 +00:00
Joshua Colp 27882b8599 Add additional functionality to the Sorcery API.
This commit adds native implementation support for copying and diffing objects,
as well as the ability to load or reload on a per-object type level.

Review: https://reviewboard.asterisk.org/r/2320/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381134 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-10 14:58:37 +00:00
Kinsey Moore 67102c3d3f Add aggregate operations for stuctures with string fields
Add struct-level comparison and copying of string fields to reduce the
complexity of whole-struct comparison and copying when using string
fields. The new macros do not take into account non-stringfield data.

Review: https://reviewboard.asterisk.org/r/2308/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381017 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-07 15:16:44 +00:00
Joshua Colp ffaf79b1eb Fix an issue where building with DEBUG_FD_LEAKS enabled would not work due to sorcery using calls called "open" and "close".
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380407 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-29 20:19:28 +00:00
Joshua Colp 734d864de2 Add a unit test which confirms the apply handler callback is called when it should be.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-27 18:40:15 +00:00
Joshua Colp 3fa4278a31 Merge the sorcery data access layer API.
Sorcery is a unifying data access layer which provides a pluggable mechanism to allow
object creation, retrieval, updating, and deletion using different backends (or wizards).

This is a fancy way of saying "one interface to rule them all" where them is configuration,
realtime, and anything else that comes along.

Review: https://reviewboard.asterisk.org/r/2259/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380069 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-25 14:01:04 +00:00
Mark Michelson 84c50fde1f Address David's latest feedback on reviewboard:
* Add a max_size option for threadpools. Also added a test for this option.
* Fixed comments to be more accurate and have fewer typos.
* Updated copyright dates on new files.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379375 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-17 16:04:10 +00:00
Mark Michelson 967e380ba8 Make the threadpool listener opaque.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379126 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15 21:09:55 +00:00
Mark Michelson 663479a558 Make ast_taskprocessor_listener opaque.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379125 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15 20:48:45 +00:00
Mark Michelson c6bc51ef28 Make the initial size of the threadpool part of the options passed in.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379123 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15 19:44:25 +00:00
Mark Michelson edc2e4dac0 Remove threadpool listener alloc and destroy callbacks.
This replaces the destroy callback with a shutdown callback
instead.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379122 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15 19:36:33 +00:00
Mark Michelson 65c7d6e2c3 Remove alloc and destroy callbacks from the taskprocessor.
Now user data is allocated by the creator of the taskprocessor
listener and that user data is passed into ast_taskprocessor_listener_alloc().
Similarly, freeing of the user data is left up to the user himself. He can
free the data when the taskprocessor shuts down, or he can choose to hold
onto it if it makes sense to do so.

This, unsurprisingly, makes threadpool allocation a LOT cleaner now.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15 18:40:36 +00:00
Automerge script f7f7850f7a Merged revisions 378935 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk

................
  r378935 | dlee | 2013-01-12 00:43:37 -0600 (Sat, 12 Jan 2013) | 41 lines
  
  Fix XML encoding of 'identity display' in NOTIFY messages.
  
  XML encoding in chan_sip is accomplished by naively building the XML
  directly from strings. While this usually works, it fails to take into
  account escaping the reserved characters in XML.
  
  This patch adds an 'ast_xml_escape' function, which works similarly to
  'ast_uri_encode'. This is used to properly escape the local_display
  attribute in XML formatted NOTIFY messages.
  
  Several things to note:
   * The Right Thing(TM) to do would probably be to replace the
     ast_build_string stuff with building an ast_xml_doc. That's a much
     bigger change, and out of scope for the original ticket, so I
     refrained myself.
   * It is with great sadness that I wrote my own ast_xml_escape
     function. There's one in libxml2, but it's knee-deep in
     libxml2-ness, and not easily used to one-off escape a
     string.
   * I only escaped the string we know is causing problems
     (local_display). At least some of the other strings are
     URI-encoded, which should be XML safe. Rather than figuring out
     what's safe and escaping what's not, it would be much cleaner to
     simply build an ast_xml_doc for the messages and let the XML
     library do the XML escaping. Like I said, that's out of scope.
  
  (closes issue ABE-2902)
  Reported by: Guenther Kelleter
  Tested by: Guenther Kelleter
  Review: http://reviewboard.digium.internal/r/365/
  
  ........
  
  Merged revision 378919 from https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
  ........
  
  Merged revisions 378933 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 378934 from http://svn.asterisk.org/svn/asterisk/branches/11
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378946 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-12 07:21:01 +00:00
Automerge script 2c1720b4f7 Merged revisions 378915,378918 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk

................
  r378915 | dlee | 2013-01-11 16:31:42 -0600 (Fri, 11 Jan 2013) | 21 lines
  
  Add JSON API for Asterisk.
  
  This provides a JSON API by pulling in and wrapping the Jansson JSON
  library[1]. The Asterisk API basically mirrors the Jansson
  functionality, with a few minor tweaks.
  
   * Some names have been asteriskified to protect the innocent.
   * Jansson provides both reference-stealing and reference-borrowing
     versions of several API's. The Asterisk API is exclusively
     reference-stealing for operations that put elements into arrays and
     objects.
   * No support for doubles, since we usually don't need that.
   * Coming along for the ride is the ast_test_validate macro, which made
     the unit tests much easier to write.
  
   [1]: http://www.digip.org/jansson/
  
  (issue ASTERISK-20887)
  (closes issue ASTERISK-20888)
  Review: https://reviewboard.asterisk.org/r/2264/
................
  r378918 | file | 2013-01-11 17:05:38 -0600 (Fri, 11 Jan 2013) | 11 lines
  
  Retain XMPP filters across reconnections so external modules continue to function as expected.
  
  Previously if an XMPP client reconnected any filters added by an external module were lost.
  This issue exhibited itself with chan_motif not receiving and reacting to Jingle signaling.
  
  (closes issue ASTERISK-20916)
  Reported by: kuj
  ........
  
  Merged revisions 378917 from http://svn.asterisk.org/svn/asterisk/branches/11
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378927 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-11 23:20:57 +00:00
Mark Michelson bdd8da406b Address review board feedback from Matt and Richard
* Remove extraneous whitespace
* Bump up debug levels of messages and add identifying info to messages.
* Account for potential failures of ao2_link()
* Add additional test and some more test data
* Add some comments in places where they could be useful
* Make threadpool listeners and their callbacks optional



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378652 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-07 22:16:06 +00:00
Mark Michelson f5e9cf5975 Add automerge property back after conflict.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377879 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-11 21:52:09 +00:00
Mark Michelson 8760e32ae3 Add auto-increment option and accompanying test.
This allows for the threadpool to automatically grow if tasks
are pushed to it and no idle threads are currently available.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377803 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-11 16:34:00 +00:00
Mark Michelson 1310e659bd Solve the issue about the "CHANGE THIS" and "XXX CHANGE THIS XXX" taskprocessor names.
Unfortunately, this required a taskprocessor listener change that makes listener allocation
utterly silly. I'm going to change the scheme so that allocation of taskprocessor listeners
is done internally within taskprocessor code. This will make it parallel with threadpool
code, which is a good thing.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377687 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 20:14:23 +00:00
Mark Michelson 90d76a5026 Make thread state waiting a little less ugly and not possible to lock up.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377686 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 19:32:50 +00:00
Mark Michelson 957cb0742b Improve timedwaits in tests to actually behave like they should.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377654 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 15:55:56 +00:00
Mark Michelson 64deed062a Add threadpool options and accompanying test.
The only test added so far is an idle thread timeout
option. This will greatly aid threadpool users who wish
to maintain a threadpool by allowing for idle threads to
die out as necessary.

Test passes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 06:13:09 +00:00
Mark Michelson 5dd22df050 Improve shutdown procedure.
This helps tests to pass more often than before.
They are far less likely to queue extra processes
into the control taskprocessor since they are prevented
once the threadpool begins to shut down.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 05:25:38 +00:00
Mark Michelson b6a73bb451 Add some useful debugging in threadpool test failure conditions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377475 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-09 19:06:35 +00:00
Mark Michelson 293b18ecce Create longer thread destruction test.
This one involves shrinking the threadpool in such
a way that both idle and active threads are affected.

This test made me re-realize why the zombie state exists,
so I re-added it. We don't want to clog up the control
taskprocessor by waiting on active threads to complete
what they are doing. Instead, we mark them as zombies so
that when they are done, they can clean themselves up
properly.

Without the zombie state available, the new test actually
will deadlock.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377474 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-09 18:56:25 +00:00
Mark Michelson 4deecdef72 Add a task distribution test.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377418 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-08 00:22:33 +00:00
Mark Michelson b353c80dc0 Add threadpool reactivation test.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 23:42:42 +00:00
Mark Michelson afdbd80bc3 Add a single-thread multi-task test.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 22:35:11 +00:00
Mark Michelson d9f4952b8a Add test where we create a thread and push a task.
Passes!



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377380 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 19:50:38 +00:00
Mark Michelson 2dc89eb485 Add test where we add a task then create a thread for it.
It passes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377379 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 19:34:11 +00:00
Mark Michelson f275c11e78 Add threadpool destruction test.
It worked on the first try. Fun time.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377378 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 19:16:28 +00:00
Mark Michelson ec29862a92 Fix up categories of threadpool tests.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377369 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 01:03:49 +00:00
Mark Michelson 4590bfd93d Add new threadpool test and fix some taskprocessor bugs.
The new thread creation test fails because Asterisk locks up
while trying to lock a taskprocessor.

While trying to debug that, I found a race condition during taskprocessor
creation where a default taskprocessor listener could try to operate on
a partially started taskprocessor. This was fixed by adding a new callback
to taskprocessor listeners.

Then while testing that change, I found some bugs in the taskprocessor
tests where I was not properly unlocking when done with a lock. Scoped
locks have spoiled me a bit.

I still have not figured out why the threadpool thread creation test
is locking up.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377368 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 00:30:35 +00:00
Mark Michelson c32634e0dd Add initial simple threadpool test.
This one simply pushes a task into the threadpool and ensures
that the listener gets the callbacks expected.

It currently crashes, so I need to figure out what's wrong.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-06 20:25:17 +00:00
Automerge script d16d0200d2 Merged revisions 376575 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk

........
  r376575 | rmudgett | 2012-11-21 12:33:16 -0600 (Wed, 21 Nov 2012) | 20 lines
  
  Add red-black tree container type to astobj2.
  
  * Add red-black tree container type.
  
  * Add CLI command "astobj2 container dump <name>"
  
  * Added ao2_container_dump() so the container could be dumped by other
  modules for debugging purposes.
  
  * Changed ao2_container_stats() so it can be used by other modules like
  ao2_container_check() for debugging purposes.
  
  * Updated the unit tests to check red-black tree containers.
  
  (closes issue ASTERISK-19970)
  Reported by: rmudgett
  Tested by: rmudgett
  
  Review: https://reviewboard.asterisk.org/r/2110/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-21 19:20:22 +00:00
Mark Michelson ff06346ea2 Add doxygen to taskprocessor tests.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376498 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-19 20:35:39 +00:00
Automerge script 558c108b92 Merged revisions 376457 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk

........
  r376457 | mjordan | 2012-11-18 20:14:54 -0600 (Sun, 18 Nov 2012) | 7 lines
  
  Fix uninitialized in this function error
  
  With some versions of gcc, n_buckets will be flagged as being uninitialized
  before use.  While its technically impossible (since the switch statement,
  even without a default, accounts for all possibilities), we'll initialize the
  variable to 0 anyway.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376462 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-19 02:19:08 +00:00
Mark Michelson 623d741ba1 Restructure taskprocessor load test to test integrity of task execution.
This throws a random number to each task and stores a copy locally. After
all tasks have executed, the data is checked to be sure tasks executed
in the correct order.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376413 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-17 22:27:39 +00:00
Mark Michelson da0e2169de Add a second default taskprocessor test that executes 20000 tasks.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376412 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-17 21:55:42 +00:00
Mark Michelson f209bc6f9d Change the default taskprocessor test so it will never hang forever.
Changes the ast_cond_wait() to an ast_cond_timedwait() so that
if there is an issue, we'll never wait forever for the task to
finish execution.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376411 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-17 21:48:59 +00:00
Mark Michelson ec68a15619 Test that shutdown callback is called when expected.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376383 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-16 05:00:42 +00:00
Mark Michelson 12de4198b8 Add a shutdown callback to taskprocessor listeners.
This helps account for the fact that it is unknown just
how many references may exist for a given taskprocessor
listener, so simply unreffing it from the taskprocessor
shutdown function is not enough to convey the gravity
of the situation.

By putting in a shutdown callback, it now becomes clear
to the listener not to try to do any further operations
on the taskprocessor.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376381 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-16 04:33:53 +00:00
Automerge script e8898ec8ba Merged revisions 376341,376344-376345 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk

................
  r376341 | dlee | 2012-11-15 18:08:00 -0600 (Thu, 15 Nov 2012) | 34 lines
  
  Migrate hashtest/hashtest2 to be unit tests.
  
  Both hashtest and hashtest2 are manual testing apps that thrash hash
  tables (hashtab and ao2 containers, respectively), by spinning up
  several threads that randomly insert, delete, lookup and iterate over
  the hash table. If the app doesn't crash, the hash table probably passes
  the test. Those utils are not a part of the typical Asterisk build, so
  they do not usually get compiled. This all makes them less that useful.
  
  This patch removes those manual test programs and replaces them with
  Asterisk unit test modules (test_{hashtab,astobj2}_thrash.so). It also
  attempts to make the tests more deterministic.
  
  * Rather than spinning up some number of threads that operate on the
    hash table randomly, spin up four threads that concurrenly add,
    remove, lookup and iterate over the hash table.
  * Each thread checks the state of the hash table both during and after
    execution, and indicates a test failure if things are not as expected.
  * Each thread times out after 60 seconds to prevent deadlocking the unit
    test run.
  
  (closes issue ASTERISK-20505)
  Reported by: Matt Jordan
  Review: https://reviewboard.asterisk.org/r/2189/
  ........
  
  Merged revisions 376306 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 376315 from http://svn.asterisk.org/svn/asterisk/branches/10
  ........
  
  Merged revisions 376339 from http://svn.asterisk.org/svn/asterisk/branches/11
................
  r376344 | dlee | 2012-11-15 18:14:00 -0600 (Thu, 15 Nov 2012) | 1 line
  
  Somehow I put in svn-1.6 merge information. Oops.
................
  r376345 | dlee | 2012-11-15 18:15:30 -0600 (Thu, 15 Nov 2012) | 15 lines
  
  Fixed extconf.c breakage introduced in r376306.
  
  To quote wdoekes:
  > Note that I'm not confirming legitimacy of having that file in tree at
  > all. Is anyone using aelparse/conf2ael?
  ........
  
  Merged revisions 376340 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 376342 from http://svn.asterisk.org/svn/asterisk/branches/10
  ........
  
  Merged revisions 376343 from http://svn.asterisk.org/svn/asterisk/branches/11
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376352 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-16 00:19:48 +00:00
Mark Michelson 426e8d1454 Refine the taskprocessor listener test a bit more.
This makes it easier to follow and tests more thoroughly.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376140 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-12 00:36:16 +00:00
Mark Michelson 7d84963667 Add a test that ensures that taskprocessor listener callbacks
are properly called.

The new test is a bit raw in that it uses magic numbers, but that
can be improved upon easily.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-09 23:23:32 +00:00
Mark Michelson 6fc8d830f8 Add a basic taskprocessor test.
This just queues a task and ensures that the task
gets executed by the default taskprocessor listener.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-09 19:42:47 +00:00
Andrew Latham b106b77041 Title update
Update title that was left behind many years ago. Used revision 6596 as my guide for what it should be.

(issue ASTERISK-20259)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@375007 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-14 21:56:13 +00:00
Sean Bright b9eeff1521 app_queue: Support persisting and loading of long member lists.
Greenlight in #asterisk brought up that he was receiving an error message "Could
not create persistent member string, out of space" when running app_queue in
Asterisk 10.  dump_queue_members() made an assumption that 8K would be enough to
store the generated string, but with queues that have large member lists this is
not always the case.  This patch removes the limitation and uses ast_str instead
of a fixed sized buffer.

The complicating factor comes from the fact that ast_db_get requires a buffer
and buffer size argument, which doesn't let us pull back more than what we pass
in, so I introduced a new ast_db_get_allocated() which returns an ast_strdup()'d
copy of the value from astdb.

As an aside, I did some testing on the maximum size of data that we can store in
the BDB library we distribute and was able to store a 10MB string and retrieve
it with no problems, so I feel this is a safe patch.

Review: https://reviewboard.asterisk.org/r/2136/
........

Merged revisions 374108 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 374135 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 374150 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374151 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-01 20:36:25 +00:00
Andrew Latham fd98835f1f Doxygen Updates Janitor Work
* Whitespace, doc-blocks, spelling, case, missing and incorrect tags.
* Add cleanup to Makefile for the Doxygen configuration update
* Start updating Doxygen configuration for cleaner output
* Enable inclusion of configuration files into documentation
* remove mantisworkflow...
* update documentation README
* Add markup to Tilghman's email and talk with him about updating his email, he knows...
* no code changes on this commit other than the mentioned Makefile change

(issue ASTERISK-20259)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373384 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-22 20:43:30 +00:00
Richard Mudgett fb1d9a90a4 Enhance astobj2 to support other types of containers.
The new API allows for sorted containers, insertion options, duplicate
handling options, and traversal order options.

* Adds the ability for containers to be sorted when they are created.

* Adds container creation options to handle duplicates when they are
inserted.

* Adds container creation option to insert objects at the beginning or end
of the container traversal order.

* Adds OBJ_PARTIAL_KEY to allow searching with a partial key.  The partial
key works similarly to the OBJ_KEY flag.  (The real search speed
improvement with this flag will come when red-black trees are added.)

* Adds container traversal and iteration order options: Ascending and
Descending.

* Adds an AST_DEVMODE compile feature to check the stats and integrity of
registered containers using the CLI "astobj2 container stats <name>" and
"astobj2 container check <name>".  The channels container is normally
registered since it is one of the most important containers in the system.

* Adds ao2_iterator_restart() to allow iteration to be restarted from the
beginning.

* Changes the generic container object to have a v_method table pointer to
support other types of containers.

* Changes the container nodes holding objects to be ref counted.

The ref counted nodes and v_method table pointer changes pave the way to
allow other types of containers.

* Includes a large astobj2 unit test enhancement that tests the new
features.

(closes issue ASTERISK-19969)
Reported by: rmudgett

Review: https://reviewboard.asterisk.org/r/2078/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372997 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-12 21:02:29 +00:00
Mark Michelson 96de9ecf30 I forgot to add the unit tests for scoped locks earlier today.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371633 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-23 04:12:32 +00:00
Kinsey Moore 9b16c8b0f6 Clean up and ensure proper usage of alloca()
This replaces all calls to alloca() with ast_alloca() which calls gcc's
__builtin_alloca() to avoid BSD semantics and removes all NULL checks
on memory allocated via ast_alloca() and ast_strdupa().

(closes issue ASTERISK-20125)
Review: https://reviewboard.asterisk.org/r/2032/
Patch-by: Walter Doekes (wdoekes)
........

Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31 20:21:43 +00:00
Russell Bryant ee04ec77b4 Fix ast_event_new unit test.
One of my recent commits broke this test.  The error was:

[test_event.c:event_new_test:214]: Events expected to be identical
have different size: 69 != 59

The difference in size occurred because the first event had
the EID IE added to the event twice.  ast_event_new() now always
adds it automatically.  Previously it only added it if there
were no IEs specified, which was kind of weird.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370541 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-30 13:45:42 +00:00
Kevin P. Fleming 39ae307bdb Silence a warning message from older versions of GCC.
Revision 370426 introduced the use of a nested function in tests/test_acl.c,
but the lack of the 'auto' scope specifier on the function and a forward
declaration resulted in compilation errors on the automated test systems.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370453 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-24 19:12:09 +00:00
Kevin P. Fleming 0385c0e9cb Allow permit/deny ACL lines to contain multiple items and negated entries.
Rules in ACLs (specified using 'permit' and 'deny') can now contain multiple
items (separated by commas), and items in the rule can be negated by prefixing
them with '!'. This simplifies Asterisk Realtime configurations, since it is no
longer necessray to control the order that the 'permit' and 'deny' columns are
returned from queries.

Review: https://reviewboard.asterisk.org/r/1592/
Initial patch contributed by Tilghman Lesher
Unit tests written by Kevin P. Fleming



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370426 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-24 16:47:33 +00:00
Matthew Jordan b6a0ae0b35 Unit tests for the Jitter Buffer API; remove unnecessary resync
This patch includes the following:
* Unit tests for the abstract Jitter Buffer API.  This includes both fixed
  and adaptive flavors, testing nominal creation, frame input, frame retrieval,
  resyncing; off nominal frame input overflow, out of order, and others.
* Tweaks to the abstract_jb API to remove the unnecessary resync_threshold
  parameter from the create function (resync_threshold is already in the
  struct passed into the create function)
* Ensure the fixed jitter buffer is empty before destroying it, to avoid an
  ASSERT
* Don't "resync" the adaptive jitter buffer.  The mechanism that was being
  used actually causes the jitter buffer to think its being overflowed by going
  around the jitterbuf API and attempting to 'resynch' it improperly.  If a
  resync is needed, the jitter buffer will do it properly by itself.  Note that
  this is only an optimization needed for trunk, as the worst that happens is 
  the loss of three voice packets before the adaptive jitter buffer will resync
  anyway.
  
Review: https://reviewboard.asterisk.org/r/2035


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370387 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-23 21:15:26 +00:00
Terry Wilson a7dfafdc56 Handle deprecated (aliased) option names with the config options api
Add a simple way to register "deprecated" option names that alias to a
different "current" name.

Review: https://reviewboard.asterisk.org/r/2026/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370043 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-12 21:43:09 +00:00
Terry Wilson 1609fca6bb Add the ability to set flags via the config options api
Allows the setting of flags via the config options api.
For example, code like this:

#define OPT1 1 << 0
#define OPT2 1 << 1
#define OPT3 1 << 2

struct thing {
   unsigned int flags;
};

and a config like this:

[blah]
opt1=yes
opt2=no
opt3=yes

Review: https://reviewboard.asterisk.org/r/2004/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369454 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-28 01:12:06 +00:00
Jason Parker 6334142050 Multiple revisions 368963,368965
........
  r368963 | qwell | 2012-06-14 13:47:03 -0500 (Thu, 14 Jun 2012) | 14 lines
  
  Remove global symbol requirement from app_voicemail.
  
  This uses the existing "function installation" stuff that already existed for
  other functions, like getting message counts.
  
  (closes issue AST-807)
  (issue AST-901)
  (issue AST-908)
  
  Review: https://reviewboard.asterisk.org/r/1965/
  ........
  
  Merged revisions 368962 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11
........
  r368965 | qwell | 2012-06-14 14:04:57 -0500 (Thu, 14 Jun 2012) | 11 lines
  
  These functions that were moved need to be static.
  
  Also wrap test functions in a #ifdef.
  
  (issue AST-807)
  (issue AST-901)
  (issue AST-908)
  ........
  
  Merged revisions 368964 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11
........

Merged revisions 368963,368965 from http://svn.asterisk.org/svn/asterisk/branches/10-digiumphones


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368966 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-14 19:40:11 +00:00
Terry Wilson 9f704b5d59 Fix reloading an unchanged file with the Config Options API
Adding multiple file support broke reloading an unchanged file. This
adds an enum for return values for the aco_process_* functions and
ensures that the config is not applied if res is not ACO_PROCESS_OK.

Review: https://reviewboard.asterisk.org/r/1979/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368673 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-07 20:32:07 +00:00
Terry Wilson aeeff8cfa2 Add default handler documentation and standardize acl handler
Added documentation describing what flags and arguments to pass to
aco_option_register for default option types. Also changed the ACL
handler to use the flags parameter to differentiate between "permit"
and "deny" instead of adding an additional vararg parameter.

Review: https://reviewboard.asterisk.org/r/1969/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-07 15:43:37 +00:00
Mark Michelson 14a985560e Merge changes dealing with support for Digium phones.
Presence support has been added. This is accomplished by
allowing for presence hints in addition to device state
hints. A dialplan function called PRESENCE_STATE has been
added to allow for setting and reading presence. Presence
can be transmitted to Digium phones using custom XML
elements in a PIDF presence document.

Voicemail has new APIs that allow for moving, removing,
forwarding, and playing messages. Messages have had a new
unique message ID added to them so that the APIs will work
reliably. The state of a voicemail mailbox can be obtained
using an API that allows one to get a snapshot of the mailbox.
A voicemail Dialplan App called VoiceMailPlayMsg has been
added to be able to play back a specific message.

Configuration hooks have been added. Configuration hooks
allow for a piece of code to be executed when a specific
configuration file is loaded by a specific module. This is
useful for modules that are dependent on the configuration
of other modules.

chan_sip now has a public method that allows for a custom
SIP INFO request to be sent mid-dialog. Digium phones use
this in order to display progress bars when files are played.

Messaging support has been expanded a bit. The main
visible difference is the addition of an AMI action
MessageSend.

Finally, a ParkingLots manager action has been added in order
to get a list of parking lots.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368435 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-04 20:26:12 +00:00
Terry Wilson d54717c39e Add new config-parsing framework
This framework adds a way to register the various options in a config
file with Asterisk and to handle loading and reloading of that config
in a consistent and atomic manner.

Review: https://reviewboard.asterisk.org/r/1873/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368181 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-01 16:33:25 +00:00
Richard Mudgett d4fa095a64 Change ao2 global array to ao2 global object holder.
Review: https://reviewboard.asterisk.org/r/1921/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-16 16:34:42 +00:00
Richard Mudgett 005cd92e78 Fix type punned compiler warning in test_config.c
........

Merged revisions 365476 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 365478 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365479 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-07 18:51:44 +00:00
Michael L. Young fdf3cd0e2e Update security events unit tests
The security events framework API was changed in Asterisk 10 but the unit tests
were not updated at the same time.

This patch does the following:
* Adds two more security events that were added to the API 
* Add challenge, received_challenge and received_hash in the inval_password 
  security event unit test

(Closes issue ASTERISK-19760)
Reported by: Michael L. Young
Tested by: Michael L. Young
Patches:
issue-asterisk-19760-trunk.diff uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/1897/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365248 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-03 19:36:33 +00:00
Terry Wilson f7c174ff84 Multiple revisions 364365,364369
........
  r364365 | twilson | 2012-04-27 17:31:01 -0500 (Fri, 27 Apr 2012) | 11 lines
  
  Fix ast_parse_arg numeric type range checking and add tests
  
  ast_parse_arg wasn't checking for strto* parse errors or limiting
  the results by the actual range of the numeric types. This patch fixes
  that and adds unit tests as well.
  
  Review: https://reviewboard.asterisk.org/r/1879/
  ........
  
  Merged revisions 364340 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
  r364369 | twilson | 2012-04-27 17:33:10 -0500 (Fri, 27 Apr 2012) | 2 lines
  
  Add missing test_config.c
........

Merged revisions 364365,364369 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@364397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-04-27 22:54:20 +00:00
Michael L. Young a011ae78dc Add leading and trailing backslashes
A couple of unit tests did not have have leading or trailing backslashes when
setting their test category resulting in a warning message being displayed.
Added the backslash where needed.
........

Merged revisions 362680 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 362681 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362682 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-04-19 21:14:35 +00:00
Michael L. Young 33c9161d1e Fix building security events test
The Security Events Framework API changed in trunk to support IPv6.  This broke
the building of the security events test which was based around IPv4.  This
patches fixes the build by changing the test to conform to the new changes.

(related to issue ASTERISK-19447)

Review: https://reviewboard.asterisk.org/r/1874/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362432 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-04-18 17:03:16 +00:00
Richard Mudgett 38e892b370 Add global ao2 array container.
Global ao2 objects must always exist after initialization because there is
no access control to obtain another reference to the global object.

It is expected that module configuration could use these new API calls to
replace an active configuration parameter object with an updated
configuration parameter object.

With these new API calls, the global object could be replaced, removed, or
referenced without the risk of someone using a stale global object
pointer.

Review: https://reviewboard.asterisk.org/r/1824/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-27 17:13:32 +00:00
Matthew Jordan a699bb72ad Add tests for main/jitterbuf.c
This patch adds unit tests for main/jitterbuf.c.  This includes checking for
the following:
  * Nominal insertion and retrieval of frames
  * Insertion and retrieval of frames where the frames are inserted out of
    order with respect to the previous frame
  * Insertion and retrieval of frames where some number of frames that would
    occur in the expected sequence are instead dropped
  * Insertion and retrieval of frames with an arrival time that does not occur
    at the same rate as the surrounding frames
  * Resynchronization of the jitter buffer when an inserted frame breaks the
    resynchronization threshold
  * Overfilling of the jitter buffer

For each of the tests, both JB_TYPE_VOICE and JB_TYPE_CONTROL permutations
exist.

Review: https://reviewboard.asterisk.org/r/1815

(issue: ASTERISK-18964)
Reported by: Kris Shaw
Tested by: Kris Shaw, Matt Jordan



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@359406 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-14 18:56:15 +00:00
Terry Wilson 699d2bd705 Make hints for invalid SIP devices return Unavail, not idle
This patch drastically simplifies the device state aggegation code.
The old method was not only overly complex, but also made it impossible
to return AST_DEVICE_INVALID from the aggregation code. The unit test
update is as a result of fixing that bug.

The SIP change stems from a bug introduced by removing a DNS lookup
for hostname-based SIP channels.

(closes issue ASTERISK-16702)
Review: https://reviewboard.asterisk.org/r/1808/
........

Merged revisions 358943 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 358944 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@358945 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-13 20:06:57 +00:00
Tilghman Lesher 9af5c769c3 Enable macros in 1.8 to find the next highest "h" extension in a context, like in 1.4.
This change restores functionality that was present in 1.4, when AEL macros
were implemented with the Macro dialplan application.  Macros are fraught with
functionality issues, because they consume a large portion of the underlying
application stack.  This limits the ability of AEL users to call many layers
of subroutines, an issue which Gosub does not have (originally tested to
100,000 levels deep).  Therefore, starting in 1.6.0, AEL macros were
implemented with Gosub.

However, there were some implicit behaviors of Macro, which were not replicated
at the same time as with the transition to Gosub, one of which is documented in
the related issue.  In particular, the "h" extension is designed to execute not
in the Macro context, but in the topmost calling context.  Due to legacy issues
with a misapplied bugfix many years ago, when a macro exited in 1.4, it looks
in all calling contexts, bubbling up from the deepest level until it finds an
"h" extension.

Since AEL hides the complexity of the underlying dialplan logic from the AEL
programmer, it's reasonable to assume that this behavior should not change in
the transition from Asterisk 1.4 LTS to Asterisk 1.8 LTS, lest we break
working AEL configurations in the transition to Asterisk 1.8 LTS.  This fix
is the result, which implements a search for the "h" extension in all calling
Gosub contexts.

Fixes ASTERISK-19336

Patch: 20120308__ael_bugfix_for_trunk__2.diff (License #5003) by Tilghman Lesher
	(with slight modifications for 1.8)

Tested by: Johan Wilfer

Review: https://reviewboard.asterisk.org/r/1776/
........

Merged revisions 358810 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 358811 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@358812 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-13 08:06:20 +00:00
Kinsey Moore 8d1bde49a9 Fix case-sensitivity for device-specific event subscriptions and CCSS
This change fixes case-sensitivity for device-specific subscriptions such that
the technology identifier is case-insensitive while the remainder of the device
string is still case-sensitive.  This should also preserve the original case of
the device string as passed in to the event system.  CCSS is the only feature
affected as it is the only consumer of device-specific event subscriptions.

The second part of this patch addresses similar case-sensitivity issues within
CCSS itself that prevented it from functioning correctly after the fix to the
events system.

This adds a unit test to verify that the event system works as expected.

(closes issue ASTERISK-19422)
Review: https://reviewboard.asterisk.org/r/1780/
........

Merged revisions 357940 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 357941 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-02 21:06:12 +00:00
Terry Wilson a9d607a357 Opaquify ast_channel structs and lists
Review: https://reviewboard.asterisk.org/r/1773/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357542 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-29 16:52:47 +00:00
Richard Mudgett 50c8557f03 Add ability to clone ao2 containers.
Occasionally there is a need to put all objects in one container also into
another container.

Some reasons you might need to do this:

1) You need to reconfigure a container.  You would do this by creating a
new container with the new configuration and ao2_container_dup the old
container into it.  Then replace the old container with the new.  Then
destroy the old container.

2) You need the contents of a container to remain stable while operating
on all of the objects.  You would do this by creating a cloned container
of the original with ao2_container_clone.  The cloned container is a
snapshot of the objects at the time of the cloning.  When done, just
destroy the cloned container.

Review: https://reviewboard.asterisk.org/r/1746/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357145 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-28 00:42:38 +00:00
Terry Wilson 6dcfd18308 Fix some tests that didn't get opaquification changes
Review: https://reviewboard.asterisk.org/r/1766/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-23 01:53:17 +00:00
Terry Wilson 34c55e8e7c Opaquify char * and char[] in ast_channel
Review: https://reviewboard.asterisk.org/r/1733/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@354968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-13 17:27:06 +00:00
Richard Mudgett f2c2d83c92 Audit of ao2_iterator_init() usage for v10.
Fix double format_cap iterator cleanup.
........

Merged revisions 352992 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@352996 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-01-27 19:33:49 +00:00
Richard Mudgett ca41b4aba0 Doubly linked lists unit test and update to implementation.
Update the doubly linked list implementation.  Now safe traversing can
insert before and after the current node when traversing in either
direction.

Updated the linked lists unit test test_linkedlist to also test doubly
linked lists.  The old test_dlinkedlist requires a manual check of results
and probably should be removed.

Review: https://reviewboard.asterisk.org/r/1569/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@347110 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-12-06 19:09:56 +00:00
Terry Wilson fa57bbe17c Add a unit test for ast_sockaddr_split_hostport
Review: https://reviewboard.asterisk.org/r/1575/
........

Merged revisions 344157 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 344175 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@344214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-09 19:31:27 +00:00
Richard Mudgett f7ce570c35 Fix AST_LIST_INSERT_BEFORE_CURRENT() updating the wrong variable.
AST_LIST_INSERT_BEFORE_CURRENT() could not be used twice in an iteration
or before AST_LIST_REMOVE_CURRENT() without corrupting the list.
AST_LIST_INSERT_BEFORE_CURRENT() could also corrupt the list if
AST_LIST_INSERT_BEFORE_CURRENT() or AST_LIST_REMOVE_CURRENT() is used on
the next iteration.

* Fixed cut and paste error using the wrong variable in
AST_LIST_INSERT_BEFORE_CURRENT().

* Added linked list unit tests for AST_LIST_INSERT_BEFORE_CURRENT(),
AST_LIST_APPEND_LIST(), and AST_LIST_INSERT_LIST_AFTER().
........

Merged revisions 342661 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 342662 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@342663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-29 04:31:51 +00:00
Paul Belanger ca0f2acab7 Set 'core' support level for test_format_api.c
........

Merged revisions 341146 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@341147 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-17 16:39:14 +00:00
Paul Belanger dbb8332ff7 Merged revisions 338556 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r338556 | pabelanger | 2011-09-29 17:14:34 -0400 (Thu, 29 Sep 2011) | 9 lines
  
  Merged revisions 338555 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r338555 | pabelanger | 2011-09-29 17:12:21 -0400 (Thu, 29 Sep 2011) | 2 lines
    
    Test modules should depend on the TEST_FRAMEWORK flag
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@338557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-29 21:16:07 +00:00
Jason Parker 930bd5660a Merged revisions 338552 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r338552 | qwell | 2011-09-29 15:54:55 -0500 (Thu, 29 Sep 2011) | 9 lines
  
  Merged revisions 338551 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r338551 | qwell | 2011-09-29 15:54:13 -0500 (Thu, 29 Sep 2011) | 1 line
    
    Test modules have a support level of core.
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@338553 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-29 20:55:15 +00:00
Jason Parker a6c29b931e Merged revisions 338228 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r338228 | qwell | 2011-09-28 15:54:35 -0500 (Wed, 28 Sep 2011) | 9 lines
  
  Merged revisions 338227 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r338227 | qwell | 2011-09-28 15:52:47 -0500 (Wed, 28 Sep 2011) | 1 line
    
    Add support levels to non-module sections of menuselect (cflags, utils, etc).
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@338229 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-28 20:55:42 +00:00
Richard Mudgett 55b70ae625 Merged revisions 337974 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r337974 | rmudgett | 2011-09-26 14:35:23 -0500 (Mon, 26 Sep 2011) | 37 lines
  
  Merged revisions 337973 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r337973 | rmudgett | 2011-09-26 14:30:39 -0500 (Mon, 26 Sep 2011) | 30 lines
    
    Fix deadlock when using dummy channels.
    
    Dummy channels created by ast_dummy_channel_alloc() should be destoyed by
    ast_channel_unref().  Using ast_channel_release() needlessly grabs the
    channel container lock and can cause a deadlock as a result.
    
    * Analyzed use of ast_dummy_channel_alloc() and made use
    ast_channel_unref() when done with the dummy channel.  (Primary reason for
    the reported deadlock.)
    
    * Made app_dial.c:dial_exec_full() not call ast_call() holding any channel
    locks.  Chan_local could not perform deadlock avoidance correctly.
    (Potential deadlock exposed by this issue.  Secondary reason for the
    reported deadlock since the held lock was part of the deadlock chain.)
    
    * Fixed some uses of ast_dummy_channel_alloc() not checking the returned
    channel pointer for failure.
    
    * Fixed some potential chan=NULL pointer usage in func_odbc.c.  Protected
    by testing the bogus_chan value.
    
    * Fixed needlessly clearing a 1024 char auto array when setting the first
    char to zero is enough in manager.c:action_getvar().
    
    (closes issue ASTERISK-18613)
    Reported by: Thomas Arimont
    Patches:
          jira_asterisk_18613_v1.8.patch (license #5621) patch uploaded by rmudgett
    Tested by: Thomas Arimont
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-26 19:40:12 +00:00
Kinsey Moore 486b6042f3 Merged revisions 337062 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r337062 | kmoore | 2011-09-20 16:05:01 -0500 (Tue, 20 Sep 2011) | 18 lines
  
  Merged revisions 337061 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r337061 | kmoore | 2011-09-20 16:04:11 -0500 (Tue, 20 Sep 2011) | 11 lines
    
    Make CANMATCH with the new pattern match engine behave more like the old one
    
    When checking an extension for E_CANMATCH using the new extension matching
    algorithm, an exact match was not returned as a possible match resulting in the
    queue failing to allow a caller to exit on DTMF.  This removes the requirement
    that an extension be longer than acquired digits for an E_CANMATCH operation
    to succeed.
    
    (closes issue ASTERISK-18044)
    Review: https://reviewboard.asterisk.org/r/1367/
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337063 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-20 21:05:42 +00:00
Paul Belanger 606ca8ee8c Merged revisions 332177 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r332177 | pabelanger | 2011-08-16 16:11:49 -0400 (Tue, 16 Aug 2011) | 11 lines
  
  Merged revisions 332176 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r332176 | pabelanger | 2011-08-16 16:10:13 -0400 (Tue, 16 Aug 2011) | 4 lines
    
    Flag test modules as 'core'
    
    Review: https://reviewboard.asterisk.org/r/1369/
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@332178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-16 20:15:23 +00:00
Terry Wilson 7b07828f2b Merged revisions 331659 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r331659 | twilson | 2011-08-12 11:31:21 -0500 (Fri, 12 Aug 2011) | 11 lines
  
  Merged revisions 331658 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r331658 | twilson | 2011-08-12 11:30:26 -0500 (Fri, 12 Aug 2011) | 4 lines
    
    Fix netsock2 multiple zero-expansion test
    
    Remove erroneous single bracket.
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@331660 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-12 16:32:24 +00:00
Russell Bryant 6a15e95a32 astobj2: Avoid using temporary objects + ao2_find() with OBJ_POINTER.
There is a fairly common pattern making its way through the code base where we
put a temporary object on the stack so we can call ao2_find() with OBJ_POINTER.
The purpose is so that it can be passed into the object hash function.
However, this really seems like a hack and potentially error prone.  This patch
is a first stab at approach to avoid having to do that.

It adds a new flag, OBJ_KEY, which can be used instead of OBJ_POINTER in these
situations.  Then, the hash function can know whether it was given an object or
some custom data to hash.

The patch also changes some uses of ao2_find() for iax2_user and iax2_peer
objects to reflect how OBJ_KEY would be used.

So long, and thanks for all the fish.

Review: https://reviewboard.asterisk.org/r/1184/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@330273 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-07-29 19:34:36 +00:00
Terry Wilson aada2733d6 Merged revisions 328992 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/2.0

................
  r328992 | twilson | 2011-07-20 15:18:25 -0500 (Wed, 20 Jul 2011) | 12 lines
  
  Merged revisions 328987 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r328987 | twilson | 2011-07-20 15:16:58 -0500 (Wed, 20 Jul 2011) | 5 lines
    
    We can't guarantee an eth0 is present
    
    FreeBSD test fails on this case presumably because there is no eth0 on the test
    machine. Better to just remove this test for now.
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@328996 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-07-20 20:19:16 +00:00