summaryrefslogtreecommitdiff
path: root/include/asterisk/threadstorage.h
AgeCommit message (Collapse)Author
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