aboutsummaryrefslogtreecommitdiffstats
path: root/main/astobj2.c
AgeCommit message (Collapse)AuthorFilesLines
2009-10-06Fix ao2_iterator API to hold references to containers being iterated.kpfleming1-2/+13
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: http://svn.digium.com/svn/asterisk/branches/1.4@222152 f38db490-d61c-443f-a65b-d21fe96a405b
2009-10-02Ensure the result of the hash function is positive. Negative array offsets ↵tilghman1-1/+1
suck. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@221970 f38db490-d61c-443f-a65b-d21fe96a405b
2009-09-04Make sure 'start' is always initialized.mvanbaak1-1/+1
This is the same as rev 216222 in trunk but 1.4 is affected as well git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@216369 f38db490-d61c-443f-a65b-d21fe96a405b
2009-09-03Merge code associated with AST-2009-006dvossel1-3/+16
(closes issue #12912) Reported by: rathaus Tested by: tilghman, russell, dvossel, dbrooks git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@216000 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18Improve the build system to *properly* remove unnecessary symbols from the ↵kpfleming1-3/+3
runtime global namespace. Along the way, change the prefixes on some internal-only API calls to use a common prefix. With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example). git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@182808 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18revert commit that included extranous changeskpfleming1-3/+3
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@182807 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18Improve the build system to *properly* remove unnecessary symbols from the ↵kpfleming1-3/+3
runtime global namespace. Along the way, change the prefixes on some internal-only API calls to use a common prefix. With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example). git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@182802 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-05Merged revisions 161421 via svnmerge from seanbright1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r161421 | seanbright | 2008-12-05 15:50:23 -0500 (Fri, 05 Dec 2008) | 8 lines Fix build errors on FreeBSD (uint -> unsigned int). (closes issue #14006) Reported by: alphaque Patches: astobj2.h-patch uploaded by alphaque (license 259) (Slightly modified by seanbright) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@161426 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-25Add ao2_trylock() to go along with ao2_lock() and ao2_unlock()russell1-0/+27
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@159158 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-21When compiling with DEBUG_THREADS, report the real file/func/line for ↵russell1-0/+16
ao2_lock/ao2_unlock git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@158539 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17Fix a memory leak in astobj2 that was pointed out by seanbright. When a ↵russell1-0/+9
container got destroyed, the underlying bucket list entry for each object that was in the container at that time did not get free'd. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@123271 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-30Change the behavior of ao2_link(). Previously, in inherited a reference.russell1-0/+1
Now, it automatically increases the reference count to reflect the reference that is now held by the container. This was done to be more consistent with ao2_unlink(), which automatically releases the reference held by the container. It also makes it so it is no longer possible for a pointer to be invalid after ao2_link() returns. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@90348 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-13resolve a warning when not building under dev moderussell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@82339 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-13Only compile in tracking astobj2 statistics if dev-mode is enabled. Also, whenrussell1-5/+33
dev mode is enabled, register the CLI command that can be used to run the astobj2 test and print out statistics. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@82337 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-10backport astobj2 race condition fix. This function is the exact same as trunkrussell1-2/+4
so it applies here as well. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@82198 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-04Remove the typedefs on ao2_container and ao2_iterator. This is simply becauserussell1-15/+15
we don't typedef objects anywhere else in Asterisk, so we might as well make this follow the same convention. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@81448 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-01Making match_by_addr into ao2_match_by_addr and making it availablemmichelson1-2/+2
everywhere since it could be a handy callback to have git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@81426 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-23This is a hack to maintain old behavior of chan_iax2. This ensures that ifrussell1-2/+5
the peers and users are being stored in a linked list, that they go in the list in the same order that the older code used. This is necessary to maintain the behavior of which peers and users get matched when traversing the container. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@80497 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-22When converting this code to use the list macros, I changed it so objects arerussell1-1/+1
added to the head of a bucket instead of the tail. However, while looking over code with mmichelson, we noticed that the algorithm used in ao2_iterator_next requires that items are added to the tail. This wouldn't have caused any huge problem, but it wasn't correct. It meant that if an object was added to a container while you were iterating it, and it was added to the same bucket that the current element is in, then the new object would be returned by ao2_iterator_next, and any other objects in the bucket would be bypassed in the traversal. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@80424 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-22Merge changes from team/russell/iax_refcount.russell1-0/+685
This set of changes fixes problems with the handling of iax2_user and iax2_peer objects. It was very possible for a thread to still hold a reference to one of these objects while a reload operation tries to delete them. The fix here is to ensure that all references to these objects are tracked so that they can't go away while still in use. To accomplish this, I used the astobj2 reference counted object model. This code has been in one of Luigi Rizzo's branches for a long time and was primarily developed by one of his students, Marta Carbone. I wanted to go ahead and bring this in to 1.4 because there are other problems similar to the ones fixed by these changes, so we might as well go ahead and use the new astobj if we're going to go through all of the work necessary to fix the problems. As a nice side benefit of these changes, peer and user handling got more efficient. Using astobj2 lets us not hold the container lock for peers or users nearly as long while iterating. Also, by changing a define at the top of chan_iax2.c, the objects will be distributed in a hash table, drastically increasing lookup speed in these containers, which will have a very big impact on systems that have a large number of users or peers. The use of the hash table will be made the default in trunk. It is not the default in 1.4 because it changes the behavior slightly. Previously, since peers and users were stored in memory in the same order they were specified in the configuration file, you could influence peer and user matching order based on the order they are specified in the configuration. The hash table does not guarantee any order in the container, so this behavior will be going away. It just means that you have to be a little more careful ensuring that peers and users are matched explicitly and not forcing chan_iax2 to have to guess which user is the right one based on secret, host, and access list settings, instead of simply using the username. If you have any questions, feel free to ask on the asterisk-dev list. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@80362 f38db490-d61c-443f-a65b-d21fe96a405b