aboutsummaryrefslogtreecommitdiffstats
path: root/main/astobj2.c
AgeCommit message (Collapse)AuthorFilesLines
2009-10-26Correct broken logic from revision 225405.kpfleming1-1/+10
The code committed in revision 225405 was broken; instead of removing the unreference code, the logic used to decide when to do it should have been reversed. This patch corrects the situation, and makes reference counting work properly again. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@225955 f38db490-d61c-443f-a65b-d21fe96a405b
2009-10-22Fix a refcount error introduced by yesterday's OBJ_MULTIPLE commit.kpfleming1-7/+1
When an object is being unlinked from its container *and* being returned to the caller, we do not want to decrement the reference count after unlinking it from the container, as the reference that the container held is what we are returning to the caller... and if it was the only remaining reference to the object, that could result in the object being destroyed. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@225405 f38db490-d61c-443f-a65b-d21fe96a405b
2009-10-21Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ↵kpfleming1-35/+74
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: http://svn.digium.com/svn/asterisk/trunk@225244 f38db490-d61c-443f-a65b-d21fe96a405b
2009-10-06Recorded merge of revisions 222152 via svnmerge from kpfleming1-3/+14
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: http://svn.digium.com/svn/asterisk/trunk@222176 f38db490-d61c-443f-a65b-d21fe96a405b
2009-10-02Merged revisions 221970 via svnmerge from tilghman1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r221970 | tilghman | 2009-10-02 11:58:03 -0500 (Fri, 02 Oct 2009) | 2 lines Ensure the result of the hash function is positive. Negative array offsets suck. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@221971 f38db490-d61c-443f-a65b-d21fe96a405b
2009-09-04make sure 'start' is always initialized.mvanbaak1-1/+1
Makes asterisk compile with --enable-dev-mode git-svn-id: http://svn.digium.com/svn/asterisk/trunk@216222 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/trunk@215955 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-28Eliminate several needless checks and fix a few memory leakstilghman1-4/+4
(closes issue #14833) Reported by: contactmayankjain Patches: all_changes.patch uploaded by contactmayankjain (license 740) slightly modified by me git-svn-id: http://svn.digium.com/svn/asterisk/trunk@197616 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-21Const-ify the world (or at least a good part of it)kpfleming1-4/+4
This patch adds 'const' tags to a number of Asterisk APIs where they are appropriate (where the API already demanded that the function argument not be modified, but the compiler was not informed of that fact). The list includes: - CLI command handlers - CLI command handler arguments - AGI command handlers - AGI command handler arguments - Dialplan application handler arguments - Speech engine API function arguments In addition, various file-scope and function-scope constant arrays got 'const' and/or 'static' qualifiers where they were missing. Review: https://reviewboard.asterisk.org/r/251/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@196072 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-05Correct some flaws in the memory accounting code for stringfields and ao2 ↵kpfleming1-1/+1
objects Under some conditions, the memory allocation for stringfields and ao2 objects would not have supplied valid file/function names for MALLOC_DEBUG tracking, so this commit corrects that. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@192357 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-05Properly account for memory allocated for channels and datastoreskpfleming1-5/+7
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: http://svn.digium.com/svn/asterisk/trunk@192318 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-04Ensure that astobj2 memory allocations are properly accounted for when ↵kpfleming1-4/+7
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: http://svn.digium.com/svn/asterisk/trunk@192059 f38db490-d61c-443f-a65b-d21fe96a405b
2009-04-23Support HTTP digest authentication for the http manager interface.tilghman1-6/+8
(closes issue #10961) Reported by: ys Patches: digest_auth_r148468_v5.diff uploaded by ys (license 281) SVN branch http://svn.digium.com/svn/asterisk/team/group/manager_http_auth Tested by: ys, twilson, tilghman Review: http://reviewboard.digium.com/r/223/ Reviewed by: tilghman,russellb,mmichelson git-svn-id: http://svn.digium.com/svn/asterisk/trunk@190349 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18Merged revisions 182808 via svnmerge from kpfleming1-83/+82
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r182808 | kpfleming | 2009-03-17 20:55:22 -0500 (Tue, 17 Mar 2009) | 5 lines Improve the build system to *properly* remove unnecessary symbols from the 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/trunk@182826 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-11Add MALLOC_DEBUG to various utility APIs, so that memory leaks can be ↵tilghman1-7/+7
tracked back to their source. (related to issue #14636) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@181028 f38db490-d61c-443f-a65b-d21fe96a405b
2009-02-12Make lock information for ao2_trylock be more useful and gnarlymmichelson1-1/+10
Core show locks information involving an ao2_trylock did not show the function that called ao2_trylock, but would instead show ao2_trylock as the source of the lock. This is not useful when trying to debug locking issues. One bizarre note is that this logic is already in 1.4 but somehow did not get merged to trunk or the 1.6.X branches. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@175121 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-22Remove some error messages. This is the default handler that is valid to use.russell1-2/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@166342 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-05Merged revisions 161426 via svnmerge from seanbright1-3/+3
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r161426 | seanbright | 2008-12-05 16:02:20 -0500 (Fri, 05 Dec 2008) | 15 lines Merged revisions 161421 via svnmerge from 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/trunk@161427 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-25This is basically a complete rollback of r155401, as it was determined thatseanbright1-26/+76
it would be best to maintain API compatibility. Instead, this commit introduces ao2_callback_data() which is functionally identical to ao2_callback() except that it allows you to pass arbitrary data to the callback. Reviewed by Mark Michelson via ReviewBoard: http://reviewboard.digium.com/r/64 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@158959 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-21Merged revisions 158539 via svnmerge from russell1-0/+16
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r158539 | russell | 2008-11-21 16:05:55 -0600 (Fri, 21 Nov 2008) | 2 lines When compiling with DEBUG_THREADS, report the real file/func/line for ao2_lock/ao2_unlock ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@158540 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-07Add ability to pass arbitrary data to the ao2_callback_fn (called fromseanbright1-22/+22
ao2_callback and ao2_find). Currently, passing OBJ_POINTER to either of these mandates that the passed 'arg' is a hashable object, making searching for an ao2 object based on outside criteria difficult. Reviewed by Russell and Mark M. via ReviewBoard: http://reviewboard.digium.com/r/36/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@155401 f38db490-d61c-443f-a65b-d21fe96a405b
2008-10-09(closes issue #13557)murf1-1/+1
Reported by: nickpeirson Patches: pbx.c.patch uploaded by nickpeirson (license 579) replace_bzero+bcopy.patch uploaded by nickpeirson (license 579) Tested by: nickpeirson, murf 1. replaced all refs to bzero and bcopy to memset and memmove instead. 2. added a note to the CODING-GUIDELINES 3. add two macros to asterisk.h to prevent bzero, bcopy from creeping back into the source 4. removed bzero from configure, configure.ac, autoconfig.h.in git-svn-id: http://svn.digium.com/svn/asterisk/trunk@147807 f38db490-d61c-443f-a65b-d21fe96a405b
2008-09-28Merge the cli_cleanup branch.mvanbaak1-3/+3
This work is done by lmadsen, junky and mvanbaak during AstriDevCon. This is the second audit the CLI got, and this time lmadsen made sure he had _ALL_ modules loaded that have CLI commands in them. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@145121 f38db490-d61c-443f-a65b-d21fe96a405b
2008-08-10Another big chunk of changes from the RSW branch. Bunch of stuff from main/seanbright1-6/+6
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@137082 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17Revert a previous regression in astobj2.c from merging a branch.bbryant1-0/+6
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@123575 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17Updates all usages of ast_tcptls_session_instance to be managed by reference ↵bbryant1-6/+0
counts so that they only get destroyed when all threads are done using them, and memory does not get free'd causing strange issues with SIP. This code was originally written by russellb in the team/group/issue_11972/ branch. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@123546 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17Put quotes around "test"mmichelson1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@123541 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17_ys pointed out in #asterisk-bugs that he was experiencingmmichelson1-0/+6
a memory leak when running the astobj2 test CLI command. After searching, it appears the leak was in the command handler itself. Each object was allocated (recount = 1) and then linked into a container (refounct = 2). Then at the end of the function, the container was unreffed, causing all the objects to have their refcount decremented by one, leaving the refcount for all objects allocated in that function at 1. I've now added an extra unref to the mix so that the refcount equals zero when the container is unreffed. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@123526 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17Add the same fix from revision 123271 to container_destruct_debug.mmichelson1-0/+9
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@123456 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-17Merged revisions 123271 via svnmerge from russell1-0/+9
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r123271 | russell | 2008-06-17 10:48:31 -0500 (Tue, 17 Jun 2008) | 4 lines Fix a memory leak in astobj2 that was pointed out by seanbright. When a 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/trunk@123272 f38db490-d61c-443f-a65b-d21fe96a405b
2008-04-16Introducing various astobj2 enhancements, chief being a refcount tracing ↵murf1-39/+269
feature, and various documentation updates in astobj2.h, and the addition of standalone utility, refcounter, that will filter the trace output for unbalanced, unfreed objects. This comes from the team/murf/bug11210 branch. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114175 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-04Whitespace changes onlytilghman1-11/+11
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@105840 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-30Merged revisions 90348 via svnmerge from russell1-0/+1
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r90348 | russell | 2007-11-30 13:26:04 -0600 (Fri, 30 Nov 2007) | 8 lines Change the behavior of ao2_link(). Previously, in inherited a reference. 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/trunk@90351 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-20move internal function declarations to include/asterisk/_private.hrizzo1-0/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89465 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-08improve linked-list macros in two ways:kpfleming1-2/+2
- 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: http://svn.digium.com/svn/asterisk/trunk@89106 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-22Switch from AST_CLI (formerly NEW_CLI) to AST_CLI_DEFINE, since the former ↵qwell1-2/+2
didn't make much sense git-svn-id: http://svn.digium.com/svn/asterisk/trunk@86820 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-19Convert NEW_CLI to AST_CLI.qwell1-2/+2
Closes issue #11039, as suggested by seanbright. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@86536 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-11Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :)russell1-28/+52
(closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-13Merged revisions 82339 via svnmerge from russell1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r82339 | russell | 2007-09-13 13:57:08 -0500 (Thu, 13 Sep 2007) | 1 line resolve a warning when not building under dev mode ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82341 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-13Merged revisions 82337 via svnmerge from russell1-5/+33
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r82337 | russell | 2007-09-13 13:45:59 -0500 (Thu, 13 Sep 2007) | 4 lines Only compile in tracking astobj2 statistics if dev-mode is enabled. Also, when 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/trunk@82338 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-10Changes applied from marta's team/marta/astobj2 branch to solve a race conditionmurf1-2/+4
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82124 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-06various changes to the documentation, and redefinition ofrizzo1-15/+6
ao2_hash_fn and ao2_callback_fn typedefs, in preparation to more cleanup of the _search_flags Please do not merge this change to 1.4 yet - there are no functional changes anyways. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81712 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-04Merged revisions 81448 via svnmerge from russell1-15/+15
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r81448 | russell | 2007-09-04 13:37:44 -0500 (Tue, 04 Sep 2007) | 4 lines Remove the typedefs on ao2_container and ao2_iterator. This is simply because 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/trunk@81449 f38db490-d61c-443f-a65b-d21fe96a405b
2007-09-01Merged revisions 81426 via svnmerge from mmichelson1-2/+2
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r81426 | mmichelson | 2007-09-01 01:02:06 -0500 (Sat, 01 Sep 2007) | 4 lines Making match_by_addr into ao2_match_by_addr and making it available everywhere since it could be a handy callback to have ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81427 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-22Merged revisions 80424 via svnmerge from russell1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r80424 | russell | 2007-08-22 17:40:27 -0500 (Wed, 22 Aug 2007) | 10 lines When converting this code to use the list macros, I changed it so objects are 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/trunk@80425 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-22Merged revisions 80362 via svnmerge from russell1-0/+685
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r80362 | russell | 2007-08-22 15:21:36 -0500 (Wed, 22 Aug 2007) | 34 lines Merge changes from team/russell/iax_refcount. 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/trunk@80387 f38db490-d61c-443f-a65b-d21fe96a405b