summaryrefslogtreecommitdiff
path: root/include/asterisk/threadpool.h
AgeCommit message (Collapse)Author
2015-11-12res_pjsip: Deny requests when threadpool queue is backed up.Mark Michelson
We have observed situations where the SIP threadpool may become deadlocked. However, because incoming traffic is still arriving, the SIP threadpool's queue can continue to grow, eventually running the system out of memory. This change makes it so that incoming traffic gets rejected with a 503 response if the queue is backed up too much. Change-Id: I4e736d48a2ba79fd1f8056c0dcd330e38e6a3816
2015-06-25threadpool, res_pjsip: Add serializer group shutdown API calls.Richard Mudgett
A module trying to unload needs to wait for all serializers it creates and uses to complete processing before unloading. ASTERISK-24907 Reported by: Kevin Harwell Change-Id: I8c80b90f2f82754e8dbb02ddf3c9121e5e966059
2015-06-10DNS: Need to use the same serializer for a pjproject SIP transaction.Richard Mudgett
All send/receive processing for a SIP transaction needs to be done under the same threadpool serializer to prevent reentrancy problems inside pjproject when using an external DNS resolver to process messages for the transaction. * Add threadpool API call to get the current serializer associated with the worker thread. * Pick a serializer from a pool of default serializers if the caller of res_pjsip.c:ast_sip_push_task() does not provide one. This is a simple way to ensure that all outgoing SIP request messages are processed under a serializer. Otherwise, any place where a pushed task is done that would result in an outgoing out-of-dialog request would need to be modified to supply a serializer. Serializers from the default serializer pool are picked in a round robin sequence for simplicity. A side effect is that the default serializer pool will limit the growth of the thread pool from random tasks. This is not necessarily a bad thing. * Made pjsip_resolver.c use the requesting thread's serializer to execute the async callback. * Made pjsip_distributor.c save the thread's serializer name on the outgoing request tdata struct so the response can be processed under the same serializer. ASTERISK-25115 #close Reported by: John Bigelow Change-Id: Iea71c16ce1132017b5791635e198b8c27973f40a
2013-04-25Merge the pimp_my_sip branch into trunk.Mark Michelson
The pimp_my_sip branch is being merged at this point because it offers basic functionality, and from an API standpoint, things are complete. SIP work is *not* feature-complete; however, with the completion of the SUBSCRIBE/NOTIFY API, all APIs (except a PUBLISH API) have been created, and thus it is possible for developers to attempt to create new SIP work. API documentation can be found in the doxygen in the code, but usability documentation is still lacking. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-28threadpool: Whitespace and comment corrections.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382294 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-12Add a serializer interface to the threadpoolDavid M. Lee
This patch adds the ability to create a serializer from a thread pool. A serializer is a ast_taskprocessor with the same contract as a default taskprocessor (tasks execute serially) except instead of executing out of a dedicated thread, execution occurs in a thread from a ast_threadpool. Think of it as a lightweight thread. While it guarantees that each task will complete before executing the next, there is no guarantee as to which thread from the pool individual tasks will execute. This normally only matters if your code relys on thread specific information, such as thread locals. This patch also fixes a bug in how the 'was_empty' parameter is computed for the push callback, and gets rid of the unused 'shutting_down' field. Review: https://reviewboard.asterisk.org/r/2323/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381326 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-17Address David's latest feedback on reviewboard:Mark Michelson
* Add a max_size option for threadpools. Also added a test for this option. * Fixed comments to be more accurate and have fewer typos. * Updated copyright dates on new files. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379375 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15Add doxygen to accessors and increase refcount of taskprocessor before ↵Mark Michelson
returning. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379127 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15Make the threadpool listener opaque.Mark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379126 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15Address further review feedback from David Lee.Mark Michelson
* Clarify some documentation * Change copyright date of taskprocessor files * Address potential issue of creating taskprocessor with listener if taskprocessor with that name exists already git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15Make the initial size of the threadpool part of the options passed in.Mark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379123 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-15Remove threadpool listener alloc and destroy callbacks.Mark Michelson
This replaces the destroy callback with a shutdown callback instead. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379122 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-07Address review board feedback from Matt and RichardMark Michelson
* Remove extraneous whitespace * Bump up debug levels of messages and add identifying info to messages. * Account for potential failures of ao2_link() * Add additional test and some more test data * Add some comments in places where they could be useful * Make threadpool listeners and their callbacks optional git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378652 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-11Some general cleanup, plus we now send state changes when threads activate.Mark Michelson
This is now ready for review board, imo! git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377805 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-11Add auto-increment option and accompanying test.Mark Michelson
This allows for the threadpool to automatically grow if tasks are pushed to it and no idle threads are currently available. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377803 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10Solve the issue about the "CHANGE THIS" and "XXX CHANGE THIS XXX" ↵Mark Michelson
taskprocessor names. Unfortunately, this required a taskprocessor listener change that makes listener allocation utterly silly. I'm going to change the scheme so that allocation of taskprocessor listeners is done internally within taskprocessor code. This will make it parallel with threadpool code, which is a good thing. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377687 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10Add threadpool options and accompanying test.Mark Michelson
The only test added so far is an idle thread timeout option. This will greatly aid threadpool users who wish to maintain a threadpool by allowing for idle threads to die out as necessary. Test passes. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-04Add better listener support.Mark Michelson
Add some parameters to listener callbacks. Add alloc and destroy callbacks for listeners. Add public function for allocating a listener. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377226 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-04Remove zombie state from threadpool altogether.Mark Michelson
After giving it some consideration, there's no real use for zombie threads. Listeners can't really use the current number of zombie threads as a way of gauging activity, zombifying threads is just an extra step before they die that really serves no purpose, and since there's no way to re-animate zombies, the operation does not need to be around. I also fixed up some miscellaneous compilation errors that were lingering from some past revisions. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377211 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-04Add some doxygen and rearrange code.Mark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377209 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-03This now compiles.Mark Michelson
That's a milestone, of sorts. Things really need arranging/documenting, and there's no function to be able to push tasks to a threadpool. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377036 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-29Commit some progress towards threadpools.Mark Michelson
Does this compile? Not even close. But I figure I don't want to lose this all in the case of some catastrophe. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376833 65c4cc65-6c06-0410-ace0-fbb531ad65f3