aboutsummaryrefslogtreecommitdiffstats
path: root/main/devicestate.c
AgeCommit message (Collapse)AuthorFilesLines
2010-05-17Merged revisions 263639 via svnmerge from mmichelson1-1/+3
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r263639 | mmichelson | 2010-05-17 17:00:28 -0500 (Mon, 17 May 2010) | 10 lines Fix logic error when checking for a devstate provider. When using strsep, if one of the list of specified separators is not found, it is the first parameter to strsep which is now NULL, not the pointer returned by strsep. This issue isn't especially severe in that the worst it is likely to do is waste some cycles when a device with no '/' and no ':' is passed to ast_device_state. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@263640 f38db490-d61c-443f-a65b-d21fe96a405b
2009-07-08Merged revisions 205409 via svnmerge from dvossel1-25/+0
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r205409 | dvossel | 2009-07-08 16:35:12 -0500 (Wed, 08 Jul 2009) | 6 lines moving ast_devstate_to_extenstate to pbx.c from devicestate.c ast_devstate_to_extenstate belongs in pbx.c. This change fixes a compile time error with chan_vpb as well. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@205412 f38db490-d61c-443f-a65b-d21fe96a405b
2009-07-08missing comma in devstatestring arraydvossel1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@205410 f38db490-d61c-443f-a65b-d21fe96a405b
2009-07-02Merged revisions 204681 via svnmerge from dvossel1-27/+41
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r204681 | dvossel | 2009-07-02 10:05:57 -0500 (Thu, 02 Jul 2009) | 14 lines Improved mapping of extension states from combined device states. This fixes a few issues with incorrect extension states and adds a cli command, core show device2extenstate, to display all possible state mappings. (closes issue #15413) Reported by: legart Patches: exten_helper.diff uploaded by dvossel (license 671) Tested by: dvossel, legart, amilcar Review: https://reviewboard.asterisk.org/r/301/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@204710 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-26Make invalid hints report Unavailable instead of Idle.russell1-10/+26
(closes issue #14413) Reported by: pj git-svn-id: http://svn.digium.com/svn/asterisk/trunk@203702 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-26Merge the new Channel Event Logging (CEL) subsystem.russell1-1/+1
CEL is the new system for logging channel events. This was inspired after facing many problems trying to represent what is possible to happen to a call in Asterisk using CDR records. For more information on CEL, see the built in HTML or PDF documentation generated from the files in doc/tex/. Many thanks to Steve Murphy (murf) and Brian Degenhardt (bmd) for their hard work developing this code. Also, thanks to Matt Nicholson (mnicholson) and Sean Bright (seanbright) for their assistance in the final push to get this code ready for Asterisk trunk. Review: https://reviewboard.asterisk.org/r/239/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@203638 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-15More 'static' qualifiers on module global variables.kpfleming1-1/+1
The 'pglobal' tool is quite handy indeed :-) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@200620 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-05Merged revisions 199297 via svnmerge from dvossel1-20/+15
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r199297 | dvossel | 2009-06-05 16:19:56 -0500 (Fri, 05 Jun 2009) | 14 lines Fixes issue with hints giving unexpected results. Hints with two or more devices that include ONHOLD gave unexpected results. (closes issue #15057) Reported by: p_lindheimer Patches: onhold_trunk.diff uploaded by dvossel (license 671) pbx.c.1.4.patch uploaded by p (license 558) devicestate.c.trunk.patch uploaded by p (license 671) Tested by: p_lindheimer, dvossel Review: https://reviewboard.asterisk.org/r/254/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@199298 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-12add 'const' qualifiers in various places where they should have beenkpfleming1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@193832 f38db490-d61c-443f-a65b-d21fe96a405b
2009-04-24Convert the ast_channel data structure over to the astobj2 framework.russell1-9/+5
There is a lot that could be said about this, but the patch is a big improvement for performance, stability, code maintainability, and ease of future code development. The channel list is no longer an unsorted linked list. The main container for channels is an astobj2 hash table. All of the code related to searching for channels or iterating active channels has been rewritten. Let n be the number of active channels. Iterating the channel list has gone from O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1). Searching for a channel by extension is still O(n), but uses a new method for doing so, which is more efficient. The ast_channel object is now a reference counted object. The benefits here are plentiful. Some benefits directly related to issues in the previous code include: 1) When threads other than the channel thread owning a channel wanted access to a channel, it had to hold the lock on it to ensure that it didn't go away. This is no longer a requirement. Holding a reference is sufficient. 2) There are places that now require less dealing with channel locks. 3) There are places where channel locks are held for much shorter periods of time. 4) There are places where dealing with more than one channel at a time becomes _MUCH_ easier. ChanSpy is a great example of this. Writing code in the future that deals with multiple channels will be much easier. Some additional information regarding channel locking and reference count handling can be found in channel.h, where a new section has been added that discusses some of the rules associated with it. Mark Michelson also assisted with the development of this patch. He did the conversion of ChanSpy and introduced a new API, ast_autochan, which makes it much easier to deal with holding on to a channel pointer for an extended period of time and having it get automatically updated if the channel gets masqueraded. Mark was also a huge help in the code review process. Thanks to David Vossel for his assistance with this branch, as well. David did the conversion of the DAHDIScan application by making it become a wrapper for ChanSpy internally. The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch. Review: http://reviewboard.digium.com/r/203/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@190423 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-25Improve performance of the ast_event cache functionality.russell1-27/+42
This code comes from svn/asterisk/team/russell/event_performance/. Here is a summary of the changes that have been made, in order of both invasiveness and performance impact, from smallest to largest. 1) Asterisk 1.6.1 introduces some additional logic to be able to handle distributed device state. This functionality comes at a cost. One relatively minor change in this patch is that the extra processing required for distributed device state is now completely bypassed if it's not needed. 2) One of the things that I noticed when profiling this code was that a _lot_ of time was spent doing string comparisons. I changed the way strings are represented in an event to include a hash value at the front. So, before doing a string comparison, we do an integer comparison on the hash. 3) Finally, the code that handles the event cache has been re-written. I tried to do this in a such a way that it had minimal impact on the API. I did have to change one API call, though - ast_event_queue_and_cache(). However, the way it works now is nicer, IMO. Each type of event that can be cached (MWI, device state) has its own hash table and rules for hashing and comparing objects. This by far made the biggest impact on performance. For additional details regarding this code and how it was tested, please see the review request. (closes issue #14738) Reported by: russell Review: http://reviewboard.digium.com/r/205/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@184339 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-09Add Doxygen documentation for API changes from 1.6.0 to 1.6.1jpeeler1-1/+0
Copied from my review board description: This is a continuation of the API changes documentation started for describing changes between releases. Most of the API changes were pretty simple needing only to be brought to attention via the new "Asterisk API Changes" list. However, if you see anything that needs further explanation feel free to supplement what is there. The current method of documenting is to add (in the header file): \version <ver number> <description of changes> and then to add the function to the change list in doxyref.h on the AstAPIChanges page. I also made sure all the functions that were newly added were tagged with \since 1.6.1. I think this is a good habit to start both for the historical aspect as well as for the future ability to easily add a "New Asterisk API" page. Review: http://reviewboard.digium.com/r/190/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@180719 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-04Slightly optimize ast_devstate_str and rename global functions devstate2str ↵tilghman1-47/+23
and config_text_file_save to have an ast_ prefix git-svn-id: http://svn.digium.com/svn/asterisk/trunk@154260 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-26actually use the cache_cache argumentrussell1-3/+6
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133946 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-26ast_device_state() gets called in two different ways. The first way is whenrussell1-2/+10
called from elsewhere in Asterisk to find the current state of a device. In that case, we want to use the cached value if it exists. The other way is when processing a device state change. In that case, we do not want to check the cache because returning the last known state is counter productive. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133945 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-26Re-work comment about how device state changes are processed to be a bit ↵russell1-6/+15
more clear git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133943 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-26Remove the code that decided when device state changes should be cached or not.russell1-26/+16
It is no longer needed. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133941 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-25Deprecate *_device_state_* APIs in favor of *_devstate_* APIstilghman1-0/+30
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133860 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-25Merged revisions 133649 via svnmerge from tilghman1-34/+5
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r133649 | tilghman | 2008-07-25 12:19:39 -0500 (Fri, 25 Jul 2008) | 8 lines Fix some errant device states by making the devicestate API more strict in terms of the device argument (only without the unique identifier appended). (closes issue #12771) Reported by: davidw Patches: 20080717__bug12771.diff.txt uploaded by Corydon76 (license 14) Tested by: davidw, jvandal, murf ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133665 f38db490-d61c-443f-a65b-d21fe96a405b
2008-07-25When the ast_device_state() function is called to retrieve device state, andrussell1-1/+1
the code checks to see if there is a cached state available, use the aggregate cached state across all servers, and not just the local state. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@133566 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-10Merge another big set of changes from team/russell/eventsrussell1-5/+210
This commit merges in the rest of the code needed to support distributed device state. There are two main parts to this commit. Core changes: - The device state handling in the core has been updated to understand device state across a cluster of Asterisk servers. Every time the state of a device changes, it looks at all of the device states on each node, and determines the aggregate device state. That resulting device state is what is provided to modules in Asterisk that take actions based on the state of a device. New module, res_ais: - A module has been written to facilitate the communication of events between nodes in a cluster of Asterisk servers. This module uses the SAForum AIS (Service Availability Forum Application Interface Specification) CLM and EVT services (Cluster Management and Event) to handle this task. This module currently supports sharing Voicemail MWI (Message Waiting Indication) and device state events between servers. It has been tested with openais, though other implementations of the spec do exist. For more information on testing distributed device state, see the following doc: - doc/distributed_devstate.txt git-svn-id: http://svn.digium.com/svn/asterisk/trunk@121559 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-10Merge another change from team/russell/eventsrussell1-0/+88
This commit breaks out some logic from pbx.c into a simple API. The hint processing code had logic for taking the state from multiple devices and turning that into the state for a single extension. So, I broke this out and made an API that lets you take multiple device states and determine the aggregate device state. I needed this for some core device state changes to support distributed device state. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@121501 f38db490-d61c-443f-a65b-d21fe96a405b
2008-01-05Merged revisions 96644 via svnmerge from russell1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r96644 | russell | 2008-01-04 20:09:19 -0600 (Fri, 04 Jan 2008) | 2 lines Don't pass an empty string as the device name. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@96645 f38db490-d61c-443f-a65b-d21fe96a405b
2008-01-04Merged revisions 96575 via svnmerge from tilghman1-9/+17
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r96575 | tilghman | 2008-01-04 17:03:40 -0600 (Fri, 04 Jan 2008) | 7 lines Fix the problem of notification of a device state change to a device with a '-' in the name. Could probably do with a better fix in trunk, but this bug has been open way too long without a better solution. Reported by: stevedavies Patch by: tilghman (Closes issue #9668) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@96576 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-21remove a bunch of useless #include "options.h"rizzo1-1/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89511 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-20move internal function declarations to include/asterisk/_private.hrizzo1-0/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89465 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-19another bunch of include removals (errno.h and asterisk/logger.h)rizzo1-1/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89425 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16Start untangling header inclusion in a way that does not affectrizzo1-6/+0
build times - tested, there is no measureable difference before and after this commit. In this change: use asterisk/compat.h to include a small set of system headers: inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h, stdlib.h, alloca.h, stdio.h Where available, the inclusion is conditional on HAVE_FOO_H as determined by autoconf. Normally, source files should not include any of the above system headers, and instead use either "asterisk.h" or "asterisk/compat.h" which does it better. For the time being I have left alone second-level directories (main/db1-ast, etc.). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89333 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-08improve linked-list macros in two ways:kpfleming1-1/+1
- the *_CURRENT macros no longer need the list head pointer argument - add AST_LIST_MOVE_CURRENT to encapsulate the remove/add operation when moving entries between lists git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89106 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-10Merge a set of device state improvements from team/russell/events.russell1-18/+92
The way a device state change propagates is kind of silly, in my opinion. A device state provider calls a function that indicates that the state of a device has changed. Then, another thread goes back and calls a callback for the device state provider to find out what the new state is before it can go send it off to whoever cares. I have changed it so that you can include the state that the device has changed to in the first function call from the device state provider. This removes the need to have to call the callback, which locks up critical containers to go find out what the state changed to. This change set changes the "simple" device state providers to use the new method. This includes parking, meetme, and SLA. I have also mostly converted chan_agent in my branch, but still have some more things to think through before presenting the plan for converting channel drivers to ensure all of the right events get generated ... git-svn-id: http://svn.digium.com/svn/asterisk/trunk@79027 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-23(closes issue #10271)russell1-1/+1
Reported by: snuffy Patches: doxygen-updates.diff uploaded by snuffy (license 35) Another big batch of doxygen documentation updates git-svn-id: http://svn.digium.com/svn/asterisk/trunk@76559 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-14Add a massive set of changes for converting to use the ast_debug() macro.russell1-10/+5
(issue #9957, patches from mvanbaak, caio1982, critch, and dimas) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@69327 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-07Fix a bunch of doxygen errors and document more thingsrussell1-3/+3
(issue #9842, snuffy) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@68339 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-06Issue 9869 - replace malloc and memset with ast_calloc, and other coding ↵tilghman1-2/+2
guidelines changes git-svn-id: http://svn.digium.com/svn/asterisk/trunk@67864 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-06Merged revisions 67594 via svnmerge from file1-6/+5
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r67594 | file | 2007-06-06 08:20:27 -0400 (Wed, 06 Jun 2007) | 10 lines Merged revisions 67593 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r67593 | file | 2007-06-06 08:18:36 -0400 (Wed, 06 Jun 2007) | 2 lines Revert channel name splitting fix for Zap. The moral of the story is don't use - in your user/peer names. (issue #9668 reported by stevedavies) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@67595 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-01Merge major changes to the way device state is passed around Asterisk. The tworussell1-53/+13
places that cared about device states were app_queue and the hint code in pbx.c. The changes include converting it to use the Asterisk event system, as well as other efficiency improvements. * app_queue: This module used to register a callback into devicestate.c to monitor device state changes. Now, it is just a subscriber to Asterisk events with the type, device state. * pbx.c hints: Previously, the device state processing thread in devicestate.c would call ast_hint_state_changed() each time the state of a device changed. Then, that code would go looking for all the hints that monitor that device, and call their callbacks. All of this blocked the device state processing thread. Now, the hint code is a subscriber of Asterisk events with the type, device state. Furthermore, when this code receives a device state change event, it queues it up to be processed by another thread so that it doesn't block one of the event processing threads. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@66958 f38db490-d61c-443f-a65b-d21fe96a405b
2007-05-23Fix a couple minor spelling mistakes.russell1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@65573 f38db490-d61c-443f-a65b-d21fe96a405b
2007-05-14Merged revisions 64276 via svnmerge from file1-3/+7
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r64276 | file | 2007-05-14 14:36:34 -0400 (Mon, 14 May 2007) | 10 lines Merged revisions 64275 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r64275 | file | 2007-05-14 14:34:06 -0400 (Mon, 14 May 2007) | 2 lines Only perform stripping of - strings from the channel name for Zap channels. Anywhere else we might remove a legitimate part of a device name. (issue #9668 reported by stevedavies) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@64277 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-13This introduces a new dialplan function, DEVSTATE, which allows you to do somerussell1-6/+68
pretty cool things. First, you can get the device state of anything in the dialplan: NoOp(SIP/mypeer has state ${DEVSTATE(SIP/mypeer)}) NoOp(The conference room 1234 has state ${DEVSTATE(MeetMe:1234)}) Most importantly, this allows you to create custom device states so you can control phone lamps directly from the dialplan. Set(DEVSTATE(Custom:mycustomlamp)=BUSY) ... exten => mycustomlamp,hint,Custom:mycustomlamp git-svn-id: http://svn.digium.com/svn/asterisk/trunk@54261 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-02Clean up ast_device_state. It's pretty now!file1-24/+18
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@53113 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-02Switch the devicestate thread to operate the same way as the logging thread. ↵file1-16/+14
Pops all entries off the list to be processed, resets the list back to a clean state, and processes each entry. The thread won't have to acquire the list lock again until it checks to see if there are more to process. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@53112 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-02Read/write lockify the devicestate stuff a bit.file1-27/+26
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@53111 f38db490-d61c-443f-a65b-d21fe96a405b
2007-01-23Cosmetic changes. Make main source files better conform to coding guidelines ↵file1-3/+3
and standards. (issue #8679 reported by johann8384) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@51486 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-30Documentation updatesoej1-1/+18
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48164 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-30Small updateoej1-0/+6
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48150 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-30Doxygen updatesoej1-1/+19
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48149 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-30Adding some generic docs on extension and device states - watchers and providersoej1-1/+44
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48139 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-04Merged revisions 44378 via svnmerge from kpfleming1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r44378 | kpfleming | 2006-10-04 14:47:22 -0500 (Wed, 04 Oct 2006) | 4 lines update thread creation code a bit reduce standard thread stack size slightly to allow the pthreads library to allocate the stack+data and not overflow a power-of-2 allocation in the kernel and waste memory/address space add a new stack size for 'background' threads (those that don't handle PBX calls) when LOW_MEMORY is defined ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44379 f38db490-d61c-443f-a65b-d21fe96a405b
2006-08-21merge new_loader_completion branch, including (at least):kpfleming1-0/+383
- restructured build tree and makefiles to eliminate recursion problems - support for embedded modules - support for static builds - simpler cross-compilation support - simpler module/loader interface (no exported symbols) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40722 f38db490-d61c-443f-a65b-d21fe96a405b