aboutsummaryrefslogtreecommitdiffstats
path: root/main/astobj2.c
AgeCommit message (Collapse)AuthorFilesLines
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