summaryrefslogtreecommitdiff
path: root/include/asterisk/astobj2.h
AgeCommit message (Collapse)Author
2016-04-14res_pjsip: Add serialized scheduler (res_pjsip/pjsip_scheduler.c)George Joseph
There are several places that do scheduled tasks or periodic housecleaning, each with its own implementation: * res_pjsip_keepalive has a thread that sends keepalives. * pjsip_distributor has a thread that cleans up expired unidentified requests. * res_pjsip_registrar_expire has a thread that cleans up expired contacts. * res_pjsip_pubsub uses ast_sched directly and then calls ast_sip_push_task. * res_pjsip_sdp_rtp also uses ast_sched to send keepalives. There are also places where we should be doing scheduled work but aren't. A good example are the places we have sorcery observers to start registration or qualify. These don't work when changes are made to a backend database without a pjsip reload. We need to check periodically. As a first step to solving these issues, a new ast_sip_sched facility has been created. ast_sip_sched wraps ast_sched but only uses ast_sched as a scheduled queue. When a task is ready to run, ast_sip_task_pusk is called for it. This ensures that the task is executed in a PJLIB registered thread and doesn't hold up the ast_sched thread so it can immediately continue processing the queue. The serializer used by ast_sip_sched is one of your choosing or a random one from the res_pjsip pool if you don't choose one. Another feature is the ability to automatically clean up the task_data when the task expires (if ever). If it's an ao2 object, it will be dereferenced, if it's a malloc'd object it will be freed. This is selectable when the task is scheduled. Even if you choose to not auto dereference an ao2 task data object, the scheduler itself maintains a reference to it while the task is under it's control. This prevents the data from disappearing out from under the task. There are two scheduling models. AST_SIP_SCHED_TASK_PERIODIC specifies that the invocations of the task occur at the specific interval. That is, every "interval" milliseconds, regardless of how long the task takes. If the task takes longer than the interval, it will be scheduled at the next available multiple of interval. For exmaple: If the task has an interval of 60 secs and the task takes 70 secs (it better not), the next invocation will happen at 120 seconds. AST_SIP_SCHED_TASK_DELAY specifies that the next invocation of the task should start "interval" milliseconds after the current invocation has finished. Also, the same ast_sched facility for fixed or variable intervals exists. The task's return code in conjunction with the AST_SIP_SCHED_TASK_FIXED or AST_SIP_SCHED_TASK_VARIABLE flags controls the next invocation start time. One res_pjsip.h housekeeping change was made. The pjsip header files were added to the top. There have been a few cases lately where I've needed res_pjsip.h just for ast_sip calls and had compiles fail spectacularly because I didn't add the pjsip header files to my source even though I never referenced any pjsip calls. Finally, a few new convenience APIs were added to astobj2 to make things a little easier in the scheduler. ao2_ref_and_lock() calls ao2_ref() and ao2_lock() in one go. ao2_unlock_and_unref() does the reverse. A few macros were also copied from res_phoneprov because I got tired of having to duplicate the same hash, sort and compare functions over and over again. The AO2_STRING_FIELD_(HASH|SORT|CMP)_FN macros will insert functions suitable for aor_container_alloc into your source. This facility can be used immediately for the situations where we already have a thread that wakes up periodically or do some scheduled work. For the registration and qualify issues, additional sorcery and schema changes would need to be made so that we can easily detect changed objects on a periodic basis without having to pull the entire database back to check. I'm thinking of a last-updated timestamp on the rows but more on this later. Change-Id: I7af6ad2b2d896ea68e478aa1ae201d6dd016ba1c
2014-07-18astobj2: assert on invalid ref and backtrace cleanupScott Griepentrog
If a reference count goes negative, instead of just logging that fact, be more helpful with a backtrace and an assert that will DO_CRASH. This patch also removes the duplicate ao2_bt() function and cleans up extraneous usage of the ast_log_backtrace() call. Review: https://reviewboard.asterisk.org/r/3765/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418963 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-13astobj2: correct define for ao2_t_cleanupScott Griepentrog
This change maps the ao2_t_cleanup() function to the correct debug function so that it can be used. Review: https://reviewboard.asterisk.org/r/3764/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418488 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-11astobj2: Add tag variants for ao2_bump, ao2_cleanup, and ao2_replaceMatthew Jordan
Tags are useful in hunting down ref imbalances; this patch adds tag variants for these commonly used macros/functions. Review: https://reviewboard.asterisk.org/r/3750/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418419 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-11astobj2: tweak ao2_replace to do nothing when it would be a NoOpCorey Farrell
This change causes ao2_replace to do nothing when src == dst. This avoids REF_DEBUG logging when we're not actually doing anything. Review: https://reviewboard.asterisk.org/r/3743/ ........ Merged revisions 418396 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-22astobj2: Add an ao2_replace macro to astobj2.hGeorge Joseph
This macro replaces one object reference with another cleaning up the original. param dst Pointer to the object that will be cleaned up. param src Pointer to the object replacing it. src's ref count is bumped if it's non-NULL. dst's ref count is decremented if it's non-NULL. src is assigned to dst, This patch was reviewed on IRC by coreyfarrell and mjordan. Tested by: George Joseph ........ Merged revisions 416995 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416996 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-06Split astobj2.c into more maintainable components.George Joseph
Split astobj2.c into the following files to improve maintainability. astobj2.c - object primitives, object primitive misc and initialization code. astobj2_private.h - internal object declarations needed by the containers. astobj2_container.c - generic conainer and container misc code. astobj2_container_hash.c - hash container specific code. astobj2_container_rbtree.c - rbtree container specific code. astobj2_container_private.h - generic container definitions and rtti prototypes. https://reviewboard.asterisk.org/r/3576/ ........ Merged revisions 415317 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415319 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-11main/astobj2: Make REF_DEBUG a menuselect item; improve REF_DEBUG outputMatthew Jordan
This patch does the following: (1) It makes REF_DEBUG a meneselect item. Enabling REF_DEBUG now enables REF_DEBUG globally throughout Asterisk. (2) The ref debug log file is now created in the AST_LOG_DIR directory. Every run will now blow away the previous run (as large ref files sometimes caused issues). We now also no longer open/close the file on each write, instead relying on fflush to make sure data gets written to the file (in case the ao2 call being performed is about to cause a crash) (3) It goes with a comma delineated format for the ref debug file. This makes parsing much easier. This also now includes the thread ID of the thread that caused ref change. (4) A new python script instead for refcounting has been added in the contrib/scripts folder. (5) The old refcounter implementation in utils/ has been removed. Review: https://reviewboard.asterisk.org/r/3377/ ........ Merged revisions 412114 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 412115 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 412153 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412154 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-09astobj2: Correct ao2_iterator opacity violationsKinsey Moore
This corrects the ao2_iterator opacity violations in res_pjsip_session.c by adding a global function to get the number of elements inside the container hidden behind the iterator. (closes issue ASTERISK-23053) Review: https://reviewboard.asterisk.org/r/3111/ Reported by: Richard Mudgett ........ Merged revisions 405253 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405254 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-27astobj2: Remove OBJ_CONTINUE support.Richard Mudgett
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-06astobj2: Add warn unused attribute to some functions.Richard Mudgett
* Fixed resulting warnings with improper use of ao2_global_obj_replace(). * Made a couple uses of ao2_global_obj_replace_unref(x, NULL) into the equivalent and more appropriate ao2_global_obj_release() call. ........ Merged revisions 398533 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-16Stasis: address refcount races; implementation commentsDavid M. Lee
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-02Move ast_str_container_alloc and friendsKinsey Moore
This moves ast_str_container_alloc, ast_str_container_add, ast_str_container_remove, and related private functions into strings.c/h since they really don't belong in astobj2.c/h. As a result of this move, utils also had to be updated. Review: https://reviewboard.asterisk.org/r/2719/ (closes issue ASTERISK-22041) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396105 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-20Regroup the ao2 search_flags.Richard Mudgett
Moved the OBJ_POINTER, OBJ_KEY, and OBJ_PARTIAL_KEY flags together into a field and renamed them to OBJ_SEARCH_OBJECT, OBJ_SEARCH_KEY, and OBJ_SEARCH_PARTIAL_KEY respectively. The values were selected to keep existing code compiling and working until the codebase can be changed to stop using these values as bit flags and use them as an enum field. The old names are defined to the new names for backward compatibility. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394846 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-14Make ao2 global objects not always use the debug version of the ao2_ref() calls.Richard Mudgett
The debug versions of ao2_ref() should only be used if REF_DEBUG is enabled so nothing is written to /tmp/refs unexpectedly. (closes issue ASTERISK-21785) Reported by: abelbeck Patches: jira_asterisk_21785_v11.patch (license #5621) patch uploaded by rmudgett Tested by: abelbeck ........ Merged revisions 388700 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388701 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-08Initial support for endpoints.David M. Lee
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-06Update ao2_destructor_fn doxygen.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387741 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-21Fix astobj2 doxygen comment.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383519 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-11Fix compilation error with REF_DEBUGKinsey Moore
When the red/black tree work was committed, there was an extra ", " in the REF_DEBUG definition of ao2_container_alloc_rbtree. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381218 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-21Add red-black tree container type to astobj2.Richard Mudgett
* 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/trunk@376575 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-02Fix a variety of ref counting issuesMatthew Jordan
This patch resolves a number of ref leaks that occur primarily on Asterisk shutdown. It adds a variety of shutdown routines to core portions of Asterisk such that they can reclaim resources allocate duringd initialization. Review: https://reviewboard.asterisk.org/r/2137 ........ Merged revisions 374177 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 374178 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 374196 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-12Enhance astobj2 to support other types of containers.Richard Mudgett
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-08-30Clean up doxygen warningsMatthew Jordan
This patch fixes numerous doxygen warnings across Asterisk. It also updates the makefile to regenerate the doxygen configuration on the local system before running doxygen to help prevent warnings/errors on the local system. Much thanks to Andrew for tackling one of the Asterisk janitor projects! (issue ASTERISK-20259) Reported by: Andrew Latham Patches: doxygen_partial.diff uploaded by Andrew Latham (license 5985) make_progdocs.diff uploaded by Andrew Latham (license 5985) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371989 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-01Make astobj2.h not include linkedlists.h.Richard Mudgett
Using astobj2 does not require linkedlists.h be included even though astob2 uses linked lists internally. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370720 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-01Add new config-parsing frameworkTerry Wilson
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-05-21Minor documentation changeTerry Wilson
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@367124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-16Remove missed idx parameter to some ao2 global holder macros.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366700 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-16Change ao2 global array to ao2 global object holder.Richard Mudgett
Review: https://reviewboard.asterisk.org/r/1921/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-29Misc changes to make astobj2 enhancement diffs easier to follow.Richard Mudgett
* Rename astobj2 API parameter funcname to func. * Rename astobj2 API iterator parameter to iter. * Update some documentation for OBJ_MULTIPLE. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360827 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-27Add global ao2 array container.Richard Mudgett
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-14Force non-inlining of ao2_iterator_destroy when TEST_FRAMEWORK is enabledMatthew Jordan
In r357272, astobj2 was changed to automatically enable REF_DEBUG when the TEST_FRAMEWORK flag was enabled. Unfortunately, some compilers (gcc 4.5.1 at least) will attempt to inline ao2_iterator_destroy in handle_astobj2_test. This by itself is not a problem; unfortunately, the compiler believes that there is a code path wherein an object allocated on the stack will be free'd. As warnings are treated as errors, this prevents compilation of astobj2. This patch works around that by adding the noinline attribue to ao2_iterator_destroy, but only if the TEST_FRAMEWORK flag is enabled. Preventing inlining is only needed for the test method defined in astobj2, which is also only enabled if TEST_FRAMEWORK is enabled. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@359306 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-28Astobj2 locking enhancement.Richard Mudgett
Add the ability to specify what kind of locking an ao2 object has when it is allocated. The locking could be one of: MUTEX, RWLOCK, or none. New API: ao2_t_alloc_options() ao2_alloc_options() ao2_t_container_alloc_options() ao2_container_alloc_options() ao2_rdlock() ao2_wrlock() ao2_tryrdlock() ao2_trywrlock() The OBJ_NOLOCK and AO2_ITERATOR_DONTLOCK flags have a slight meaning change. They no longer mean that the object is protected by an external mechanism. They mean the lock associated with the object has already been manually obtained by one of the ao2_lock calls. This change is necessary for RWLOCK support since they are not reentrant. Also an operation on an ao2 container may require promoting a read lock to a write lock by releasing the already held read lock to re-acquire as a write lock. Replaced API calls: ao2_t_link_nolock() ao2_link_nolock() ao2_t_unlink_nolock() ao2_unlink_nolock() with the respective ao2_t_link_flags() ao2_link_flags() ao2_t_unlink_flags() ao2_unlink_flags() API calls to be more flexible and to allow an anticipated enhancement to control linking duplicate objects into a container. The changes to format.c and format_cap.c are taking advantange of the new ao2 locking options to simplify the use of the format capabilities containers. Review: https://reviewboard.asterisk.org/r/1554/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-28Add ability to clone ao2 containers.Richard Mudgett
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-24astobj2.h comment tweaks.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356765 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-24astobj2.h documentation updates.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356734 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-12-31Constify tag argument in REF_DEBUG related code.Russell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@349409 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-24Fix ao2obj.h comment typos and add missing link/unlink nolock debug defines.Richard Mudgett
........ Merged revisions 342183 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@342184 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-07-29astobj2: Avoid using temporary objects + ao2_find() with OBJ_POINTER.Russell Bryant
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-02-03Asterisk media architecture conversion - no more format bitfieldsDavid Vossel
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-12-20New astobj2 flag for issuing a callback without locking the container.David Vossel
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@299135 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-09-08Merged revisions 285530 via svnmerge from Jason Parker
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r285530 | qwell | 2010-09-08 15:43:10 -0500 (Wed, 08 Sep 2010) | 9 lines Merged revisions 285529 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ........ r285529 | qwell | 2010-09-08 15:42:44 -0500 (Wed, 08 Sep 2010) | 1 line Follow coding guidelines in moh rescan fix. Also fix the documentation that got me in trouble. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@285531 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-06-08Fix some doxygen warnings.Leif Madsen
(closes issue #17336) Reported by: snuffy Patches: doxygen-fixes1.diff uploaded by snuffy (license 35) Tested by: russell git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@268969 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22Remove ABI differences that occured when compiling with DEBUG_THREADS.Jason Parker
"Bad Things" would happen if Asterisk was compiled with DEBUG_THREADS, but a loaded module was not (or vice versa). This also immensely simplifies the lock code, since there are no longer 2 separate versions of them. Review: https://reviewboard.asterisk.org/r/508/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-05fixes astobj2 unlinking of multiple objects when OBJ_MULTIPLE was disabledDavid Vossel
When OBJ_MULTIPLE was off but OBJ_UNLINK was on, all the items in a bucket were being unlinked instead of just the first match. This fixes that. Review: https://reviewboard.asterisk.org/r/490/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245147 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-03Fix multiple issues with musiconhold, which led to classes not getting ↵Tilghman Lesher
destroyed properly. * Classes are now tracked past removal from the core container, and module removal is actively prevented until all references are freed. * A hanging reference stored in the channel has been removed. This could have caused a mismatch and the music state not properly cleared, if two or more reloads occurred between MOH being stopped and MOH being restarted. * In certain circumstances, duplicate classes were possible. * A race existed at reload time between a process being killed and the thread responsible for reading from the related pipe respawning that process. * Several reference counts have also been corrected. At least one could have caused deleted classes to stick around forever, consuming resources. This originally manifested as MOH external processes that were not killed at reload time. (closes issue #16279, closes issue #16207) Reported by: parisioa, dcabot Patches: 20091202__issue16279__2.diff.txt uploaded by tilghman (license 14) Tested by: parisioa, tilghman git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@232660 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-21Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ↵Kevin P. Fleming
ast_channel_iterator to use it. This patch finishes the implementation of OBJ_MULTIPLE in astobj2 (the case where multiple results need to be returned; OBJ_NODATA mode already was supported). In addition, it converts ast_channel_iterators (only the targeted versions, not the ones that iterate over all channels) to use this method. During this work, I removed the 'ao2_flags' arguments to the ast_channel_iterator constructor functions; there were no uses of that argument yet, there is only one possible flag to pass, and it made the iterators less 'opaque'. If at some point in the future someone really needs an ast_channel_iterator that does not lock the container, we can provide constructor(s) for that purpose. Review: https://reviewboard.asterisk.org/r/379/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@225244 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-06Recorded merge of revisions 222152 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r222152 | kpfleming | 2009-10-05 20:16:36 -0500 (Mon, 05 Oct 2009) | 20 lines Fix ao2_iterator API to hold references to containers being iterated. See Mantis issue for details of what prompted this change. Additional notes: This patch changes the ao2_iterator API in two ways: F_AO2I_DONTLOCK has become an enum instead of a macro, with a name that fits our naming policy; also, it is now necessary to call ao2_iterator_destroy() on any iterator that has been created. Currently this only releases the reference to the container being iterated, but in the future this could also release other resources used by the iterator, if the iterator implementation changes to use additional resources. (closes issue #15987) Reported by: kpfleming Review: https://reviewboard.asterisk.org/r/383/ ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@222176 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-03Merge code associated with AST-2009-006David Vossel
(closes issue #12912) Reported by: rathaus Tested by: tilghman, russell, dvossel, dbrooks git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@215955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-05Properly account for memory allocated for channels and datastoresKevin P. Fleming
As in previous commits, when channels are allocated (with ast_channel_alloc) or datastores are allocated (with ast_datastore_alloc) properly account for the memory being owned by the caller, instead of the allocator function itself. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-04Ensure that astobj2 memory allocations are properly accounted for when ↵Kevin P. Fleming
MALLOC_DEBUG is used This commit ensures that all astobj2 allocated objects are properly accounted for in MALLOC_DEBUG mode by passing down the file/function/line information from the module/function that actually called the astobj2 allocation function. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192059 65c4cc65-6c06-0410-ace0-fbb531ad65f3