Commit Graph

80 Commits

Author SHA1 Message Date
Russell Bryant a398f9e0ac Do a bit of code cleanup.
- convert handling of IE PLTYPEs to switch statements
 - add braces to various small blocks
 - remove a bit of trailing whitespace
 - remove a couple of unnecessary ast_strdupa() uses


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191848 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-02 21:15:18 +00:00
Russell Bryant b564b2105f Change g_eid to ast_eid_default.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-27 14:00:18 +00:00
Russell Bryant 189a55f9f0 Remove unneeded AST_LIST_ENTRY() and comment on the purpose of ast_event_ref.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184344 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-25 22:11:35 +00:00
Russell Bryant ee77b475f2 Improve performance of the ast_event cache functionality.
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: https://origsvn.digium.com/svn/asterisk/trunk@184339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-25 21:57:19 +00:00
Kevin P. Fleming 887e28d7aa incorporates r159808 from branches/1.4:
------------------------------------------------------------------------
r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines

update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors

since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them

format attributes in a consistent way


------------------------------------------------------------------------

in addition:

move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@159818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-29 17:57:39 +00:00
Sean Bright b69c8e6ab5 Another big chunk of changes from the RSW branch. Bunch of stuff from main/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@137082 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-10 19:35:50 +00:00
Mark Michelson f0a019dbec Add an additional sanity check in case an event is passed between
Asterisk boxes with mismatched ie_maps.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121649 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-10 19:52:21 +00:00
Russell Bryant 823d1c7ea9 Merge some more changes from team/russell/events
This commit pulls in a batch of improvements and additions to the event API.
Changes include:
 - the ability to dynamically build a subscription.  This is useful if you're
    building a subscription based on something you receive from the network,
    or from options in a configuration file.
 - Add tables of event types and IE types and the corresponding string
    representation for implementing text based protocols that use these
	events, for showing events on the CLI, reading configuration that
	references event information, among other things.
 - Add a table that maps IE types and the corresponding payload type.
 - an API call to get the total size of an event
 - an API call to get all events from the cache that match a subscription
 - a new IE payload type, raw, which I used for transporting the Entity ID in
    my code for handling distributed device state.
 - Code improvements to reduce code duplication
 - Include the Entity ID of the server that originated the event in every event
 - an additional event type, DEVICE_STATE_CHANGE, to help facilitate distributed
    device state.  DEVICE_STATE is a state change on one server, DEVICE_STATE_CHANGE
	is the aggregate device state change across all servers.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121555 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-10 14:53:40 +00:00
Russell Bryant 7f29bc7bc6 Simplify code by using a taskprocessor for dispatching events in the Asterisk core.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@115324 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-05 22:01:56 +00:00
Steve Murphy 8b6d8da58c Introducing a small optimization to event_unsubscribe; events now use a Doubly-Linked list for events, gives fast deletions, for the sake of channel driver mwi events. From team/murf/bug11210.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16 20:28:08 +00:00
Mark Michelson 23fc97480e Fix a small logic error in ast_event_iterator_next. The previous logic allowed for the iterator
to indicate there was more data than there really was, causing the iterator read beyond the end
of the event structure. This led to invalid memory reads and potential crashes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-13 00:55:09 +00:00
Mark Michelson 9d683be81a Fix a problem regarding network vs. host byte order
in the event API.

ast_event_iterator_get_ie_type should return the ie type in
host byte order. Furthermore, ast_event_get_ie_raw should already
have its ie type argument in host byte order since it could be called
externally (and it in fact is called in this way by ast_event_get_cached).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103282 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-11 02:47:25 +00:00
Joshua Colp 4fe093b821 Goodbye again drumkilla.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98435 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-11 23:09:31 +00:00
Joshua Colp e0532df614 drumkilla ftw.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98434 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-11 23:00:21 +00:00
Russell Bryant f330fb4783 * In unaligned.h, remove some unnecessary casts and mark the arg of the
get_unaligned functions as const
* In event.c, use get_unaligned_uint32() in a couple of places to fix issues on
  architectures that don't allow unaligned access


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@92305 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-11 16:29:29 +00:00
Luigi Rizzo 915b97d300 move internal function declarations to include/asterisk/_private.h
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89465 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-20 22:18:21 +00:00
Luigi Rizzo fdb7f7ba3d Start untangling header inclusion in a way that does not affect
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: https://origsvn.digium.com/svn/asterisk/trunk@89333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16 20:04:58 +00:00
Kevin P. Fleming edc78d6023 improve linked-list macros in two ways:
- 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: https://origsvn.digium.com/svn/asterisk/trunk@89106 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-08 05:28:47 +00:00
Russell Bryant 8a6c04a0a9 Try to clarify the rules on changing ast_event and ast_event_ie
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81356 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 19:41:16 +00:00
Russell Bryant 94d9d29f18 Fix parenthesis from my last commit
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81355 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 19:33:57 +00:00
Russell Bryant 22de9a1c68 Change pointer aritmetic on void * to char *
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81354 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 18:33:31 +00:00
Russell Bryant dce06fed1d there is not actually code that sends these over the network in trunk yet
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81353 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 18:27:48 +00:00
Joshua Colp e311ae98d1 Return ast_event_get_ie_raw to using an iterator and fix logic in ast_event_iterator_next.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81348 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 16:25:30 +00:00
Joshua Colp a3b8cb670e This concludes bringing trunk back to a working state.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81345 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 16:07:35 +00:00
Joshua Colp c9445d4a68 To keep others happy... revert part of my additions so trunk works.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81344 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 16:03:51 +00:00
Joshua Colp 2351d789fd Add API calls for iterating through an event. This should allow events to have multiple information elements (while there was nothing preventing it before you could not actually access any except the first one).
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81334 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29 15:19:11 +00:00
Russell Bryant e113d36aa4 Merge a set of device state improvements from team/russell/events.
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: https://origsvn.digium.com/svn/asterisk/trunk@79027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-10 16:24:11 +00:00
Tilghman Lesher 9d05ff8ed5 Issue 9869 - replace malloc and memset with ast_calloc, and other coding guidelines changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-06 21:20:11 +00:00
Olle Johansson b28d908e85 This file really needs more documentation...
When we implement new API's - please include a small general overview in Doxygen


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64496 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-16 07:10:54 +00:00
Russell Bryant b6b1bf3213 Merge changes from team/russell/events
This set of changes introduces a new generic event API for use within Asterisk.
I am still working on a way for events to be shared between servers, but this
part is ready and can already be used inside of Asterisk.

This set of changes introduces the first use of the API, as well.  I have
restructured the way that MWI (message waiting indication) is handled.  It is
now event based instead of polling based.  For example, if there are a bunch
of SIP phones subscribed to mailboxes, then chan_sip will not have to
constantly poll the mailboxes for changes.  app_voicemail will generate events
when changes occur.

See UPGRADE.txt and CHANGES for some more information on the effects of these
changes from the user perspective.  For developer information, see the text in
include/asterisk/event.h.

As always, additional feedback is welcome on the asterisk-dev mailing list.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@62292 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-28 21:01:44 +00:00