summaryrefslogtreecommitdiff
path: root/include/asterisk/threadstorage.h
AgeCommit message (Collapse)Author
2015-04-17Fix issue with AST_THREADSTORAGE_RAW when DEBUG_THREADLOCALS is enabled.Corey Farrell
When DEBUG_THREADLOCALS is enabled it causes the threadlocal cleanup to be called as a function. This causes a compile error with raw threadstorage as it uses NULL for cleanup. This fix uses a macro that provides NULL when DEBUG_THREADLOCALS is disabled, and replaces the call to "c_cleanup(data);" with "{};" when DEBUG_THREADLOCALS is enabled. ASTERISK-24975 #close Reported by: Ashley Sanders Change-Id: I3ef7428ee402816d9fcefa1b3b95830c00d5c402
2015-03-27Improved and portable ast_log recursion avoidanceCorey Farrell
This introduces a new logger routine ast_log_safe. This routine should be used for all error messages in code that can be run as a result of ast_log. ast_log_safe does nothing if run recursively. All error logging in astobj2.c, strings.c and utils.h have been switched to ast_log_safe. This required adding support for raw threadstorage. This provides direct access to the void* pointer in threadstorage. In ast_log_safe, NULL is used to signify that this thread is not already running ast_log_safe, (void*)1 when it is already running. This was done since it's critical that ast_log_safe do nothing that could log during recursion checking. ASTERISK-24155 #close Reported by: Timo Teräs Review: https://reviewboard.asterisk.org/r/4502/ ........ Merged revisions 433522 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433523 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433524 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-28Match use of ast_free() with ast_calloc() and add some curly braces.Richard Mudgett
........ Merged revisions 397856 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397857 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
2009-12-28Merged revisions 236585 via svnmerge from Sean Bright
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r236585 | seanbright | 2009-12-28 10:12:08 -0500 (Mon, 28 Dec 2009) | 7 lines Try a test compile to see if PTHREAD_ONCE_INIT requires extra braces. There was conditional code (based on build platform) to optioinally wrap PTHREAD_ONCE_INIT in braces that was removed since it is fixed in newer versions of Solaris/OpenSolaris, but I am still running into it on Solaris 10 x86 so add a configure-time check for it. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@236613 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-20Merged revisions 177701 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r177701 | tilghman | 2009-02-20 15:15:01 -0600 (Fri, 20 Feb 2009) | 3 lines This exception does not appear to still be true for Solaris 10, and OpenSolaris definitely needs it to be removed. Fixed for snuff-home on -dev channel. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@177732 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-16Merged revisions 164736 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r164736 | russell | 2008-12-16 11:06:29 -0600 (Tue, 16 Dec 2008) | 14 lines Fix memory leak and invalid reporting issues with DEBUG_THREADLOCALS. One issue was that the ast_mutex_* API was being used within the context of the thread local data destructors. We would go off and allocate more thread local data while the pthread lib was in the middle of destroying it all. This led to a memory leak. Another issue was an invalid argument being provided to the the object_add API call. (closes issue #13678) Reported by: ys Tested by: Russell ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@164737 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-13Merge ast_str_opaque branch (discontinue usage of ast_str internals)Tilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@163991 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-10-06Update documentation; AST_THREADSTORAGE() in trunk only takes a singleTilghman Lesher
argument. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@146928 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-22Merged revisions 139553 via svnmerge from Mark Michelson
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r139553 | mmichelson | 2008-08-22 14:45:19 -0500 (Fri, 22 Aug 2008) | 8 lines Fix compilation when DEBUG_THREAD_LOCALS is selected (closes issue #13298) Reported by: snuffy Patches: bug13298_20080822.diff uploaded by snuffy (license 35) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@139554 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-06Merged revisions 135899 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r135899 | tilghman | 2008-08-05 22:02:59 -0500 (Tue, 05 Aug 2008) | 4 lines 1) Bugfix for debugging code 2) Reduce compiler warnings for another section of debugging code (Closes issue #13237) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@135900 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-02Fix a bunch of places where \arg was used instead of \param. Using \argRussell Bryant
to document arguments seems logical, and does work, but is not the best thing to use. \arg in doxygen is simply for creating non-nested unordered lists. \param is the correct tag to use to document function parameters, and will come out better in the generated documentation. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@127401 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-18minor cleanupsKevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@93493 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-09-18Make sure that libpthread doesn't try to call free() directly when MALLOC_DEBUGRussell Bryant
is enabled. If it does, Asterisk will crash as the address isn't the real beginning of the allocation. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-01Merged revisions 77869 via svnmerge from Joshua Colp
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r77869 | file | 2007-08-01 14:56:59 -0300 (Wed, 01 Aug 2007) | 2 lines Add some fixes for building on Solaris. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77870 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-04yeah... so... compiling before committing seems like it might be a good ideaKevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-04Merged revisions 49553 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49553 | kpfleming | 2007-01-04 16:51:01 -0600 (Thu, 04 Jan 2007) | 2 lines add support for tracking thread-local-storage objects that exist via 'threadstorage' CLI commands ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-15move the dynamic string support in a better place i.e. string.hLuigi Rizzo
While doing this, add a bit of documentation, and slightly extend the functionality as follows: + a max_len of -1 means that we take whatever the current size is, and never try to extend the buffer; + add support for alloca()-ted dynamic strings, which is very useful for all cases where we do an ast_build_string() now. Next step is to simplify the interface by using shorter names (e.g. ast_str as a prefix) and removing the _thread variant of the functions by saving the threadstorage reference into the struct ast_str. This can be done by overloading the 'type' field. Finally, I will do my best to remove the convoluted interface that results from trying to support platforms without va_copy(). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48509 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-15small documentation improvements.Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48495 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-01Tiny doxygen improvementOlle Johansson
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48175 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-29- Fix a few spelling mistakes.Russell Bryant
- Add some more documentation for the ast_dynamic_str_............() function to document the behavior of the function in the case of a partial write. Also, document the return value and note that the function should never need to be called directly. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48110 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-27Doxygen updatesOlle Johansson
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48033 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-26- Add some comments on thread storage with a brief explanation of what it isRussell Bryant
as well as what the motivation is for using it. - Add a comment by the declaration of ast_inet_ntoa() noting that this function is not reentrant, and the result of a previous call to the function is no longer valid after calling it again. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48019 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19restore freeing of threadstorage objects without custom cleanup functionsKevin P. Fleming
allow custom threadstorage init functions to return failure use a custom init function for chan_sip's temp_pvt, to improve performance a bit git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45634 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19Extend the thread storage API such that a custom initialization function canRussell Bryant
be called for each thread specific object after they are allocated. Note that there was already the ability to define a custom cleanup function. Also, if the custom cleanup function is used, it *MUST* call free on the thread specific object at the end. There is no way to have this magically done that I can think of because the cleanup function registered with the pthread implementation will only call the function back with a pointer to the thread specific object, not the parent ast_threadstorage object. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-22compatibility fix:Luigi Rizzo
use "attribute_XXX" instead of *__attribute__ ((XXX)) so we can handle compiler/os dependencies in our compiler.h git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43480 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-08Merge team/russell/ast_verbose_threadstorageRussell Bryant
- instead of defining a free() wrapper in a bunch of files, define it as ast_free() in utils.h and remove the copies from all the files. - centralize and abstract the code used for doing thread storage. The code lives in threadstorage.h, with one function being implemented in utils.c. This new API includes generic thread storage as well as special functions for handling thread local dynamic length string buffers. - update ast_inet_ntoa() to use the new threadstorage API - update ast_state2str() to use the new threadstorage API - update ast_cli() to use the new threadstorage API - Modify manager_event() to use thread storage. Instead of using a buffer of 4096 characters as the workspace for building the manager event, use a thread local dynamic string. Now there is no length limitation on the length of the body of a manager event. - Significantly simplify the handling of ast_verbose() ... - Instead of using a static char buffer and a lock to make sure only one thread can be using ast_verbose() at a time, use a thread local dynamic string as the workspace for preparing the verbose message. Instead of locking around the entire function, the only locking done now is when the message has been built and is being deliviered to the list of registered verbose message handlers. - This function was doing a strdup() on every message passed to it and keeping a queue of the last 200 messages in memory. This has been completely removed. The only place this was used was that if there were any messages in the verbose queue when a verbose handler was registered, all of the messages in the queue would be fed to it. So, I just made sure that the console verbose handler and the network verbose handler (for remote asterisk consoles) were registered before any verbose messages. pbx_gtkconsole and pbx_kdeconsole will now lose a few verbose messages at startup, but I didn't feel the performance hit of this message queue was worth saving the initial verbose output for these very rarely used modules. - I have removed the last three arguments to the verbose handlers, leaving only the string itself because they aren't needed anymore. For example, ast_verbose had some logic for telling the verbose handler to add a newline if the buffer was completely full. Now that the buffer can grow as needed, this doesn't matter anymore. - remove unused function, ast_verbose_dmesg() which was to dispatch the message queue - Convert the list of verbose handlers to use the linked list macros. - add missing newline characters to a few ast_verbose() calls - convert the list of log channels to use the linked list macros in logger.c - fix close_logger() to close all of the files it opened for logging - update ast_log() to use a thread local dynamic string for its workspace for preparing log messages instead of a buffer of size BUFSIZ (8kB on my system) allocated on the stack. The dynamic string in this case is limited to only growing to a maximum size of BUFSIZ. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39272 65c4cc65-6c06-0410-ace0-fbb531ad65f3