summaryrefslogtreecommitdiff
path: root/include/asterisk/astobj2.h
AgeCommit message (Collapse)Author
2017-10-10astobj2: Add ao2_weakproxy_find function.Corey Farrell
This function finds a weak proxy in an ao2_container and returns the real object associated with it. Change-Id: I9da822049747275f5961b5c0a7f14e87157d65d8
2017-10-10astobj2: Run weakproxy callbacks outside of lock.Corey Farrell
Copy the list of weakproxy callbacks to temporary memory so they can be run without holding the weakproxy lock. Change-Id: Ib167622a8a0f873fd73938f7611b2a5914308047
2017-03-30astobj2: Prevent potential deadlocks with ao2_global_obj_releaseSean Bright
The ao2_global_obj_release() function holds an exclusive lock on the global object while it is being dereferenced. Any destructors that run during this time that call ao2_global_obj_ref() will deadlock because a read lock is required. Instead, we make the global object inaccessible inside of the write lock and only dereference it once we have released the lock. This allows the affected destructors to fail gracefully. While this doesn't completely solve the referenced issue (the error message about not being able to create an IQ continues to be shown) it does solve the backtrace spew that accompanied it. ASTERISK-21009 #close Reported by: Marcello Ceschia Change-Id: Idf40ae136b5070dba22cb576ea8414fbc9939385
2016-09-02astobj2: Support using a separate object for locking.Corey Farrell
Create ao2_alloc_with_lockobj function to support shared locking. Change-Id: Iba687eb9843922be7e481e23a32c0700ecf88a80
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
2015-07-31ARI: Channels added to Stasis application during WebSocket creation ...Ashley Sanders
Prior to ASTERISK-24988, the WebSocket handshake was resolved before Stasis applications were registered. This was done such that the WebSocket would be ready when an application is registered. However, by creating the WebSocket first, the client had the ability to make requests for the Stasis application it thought had been created with the initial handshake request. The inevitable conclusion of this scenario was the cart being put before the horse. ASTERISK-24988 resolved half of the problem by ensuring that the applications were created and registered with Stasis prior to completing the handshake with the client. While this meant that Stasis was ready when the client received the green-light from Asterisk, it also meant that the WebSocket was not yet ready for Stasis to dispatch messages. This patch introduces a message queuing mechanism for delaying messages from Stasis applications while the WebSocket is being constructed. When the ARI event processor receives the message from the WebSocket that it is being created, the event processor instantiates an event session which contains a message queue. It then tries to create and register the requested applications with Stasis. Messages that are dispatched from Stasis between this point and the point at which the event processor is notified the WebSocket is ready, are stashed in the queue. Once the WebSocket has been built, the queue's messages are dispatched in the order in which they were originally received and the queue is concurrently cleared. ASTERISK-25181 #close Reported By: Matt Jordan Change-Id: Iafef7b85a2e0bf78c114db4c87ffc3d16d671a17
2015-05-22Astobj2: Run weakproxy subscription callbacks in reverse order.Corey Farrell
Modify ao2_weakproxy_subscribe so each new subscription is added to the head of the list. This ensures that when other objects are allocated and use a subscription to the weakproxy for cleanup, cleanup will occur in the correct order. ASTERISK-25120 #close Change-Id: Ie0476f08ec21330de1b3f5a2dd3d9eb683df3d3d
2015-04-29Astobj2: Add ao2_weakproxy_ref_object function.Corey Farrell
This function allows code to run ao2_ref against the real object associated with a weakproxy. It is useful when all of the following conditions are true: * You have a pointer to weakproxy. * You do not have or need a pointer to the real object. * You need to ensure the real object exists and is not destroyed during a process. In this case it's wasteful to store a pointer to the real object just for the sake of releasing it later. Change-Id: I38a319b83314de75be74207a8771aab269bcca46
2015-04-27Astobj2: Allow reference debugging to be enabled/disabled by config.Corey Farrell
* The REF_DEBUG compiler flag no longer has any effect on code that uses Astobj2. It is used to determine if reference debugging is enabled by default. Reference debugging can be enabled or disabled in asterisk.conf. * Caller information is provided in logger errors for ao2 bad magic numbers. * Optimizes AO2 by merging internal functions with the public counterpart. This was possible now that we no longer require a dual ABI. ASTERISK-24974 #close Reported by: Corey Farrell Change-Id: Icf3552721fe999365ba8a8cf00a965aa6b897cc1
2015-04-13astobj2: Add support for weakproxy objects.Corey Farrell
This implements "weak" references. The weakproxy object is a real ao2 with normal reference counting of its own. When a weakproxy is pointed to a normal object they hold references to each other. The normal object is automatically freed when a single reference remains (the weakproxy). The weakproxy also supports subscriptions that will notify callbacks when it does not point to any real object. ASTERISK-24936 #close Reported by: Corey Farrell Change-Id: Ib9f73c02262488d314d9d9d62f58165b9ec43c67
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