summaryrefslogtreecommitdiff
path: root/main/threadpool.c
AgeCommit message (Collapse)Author
2012-12-10Improve shutdown procedure.Mark Michelson
This helps tests to pass more often than before. They are far less likely to queue extra processes into the control taskprocessor since they are prevented once the threadpool begins to shut down. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10Add safeguards to ensure we don't improperly access a destroyed taskprocessor.Mark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377556 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-09Remove unnecessary debugging and add some useful debugging.Mark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377476 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-09Create longer thread destruction test.Mark Michelson
This one involves shrinking the threadpool in such a way that both idle and active threads are affected. This test made me re-realize why the zombie state exists, so I re-added it. We don't want to clog up the control taskprocessor by waiting on active threads to complete what they are doing. Instead, we mark them as zombies so that when they are done, they can clean themselves up properly. Without the zombie state available, the new test actually will deadlock. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377474 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07Fix infinite looping and crash problem.Mark Michelson
MALLOC_DEBUG is complaining about corrupted memory on taskprocessor listeners, but I'm not seeing it, nor is valgrind. Not sure what's up there. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377377 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07Add new threadpool test and fix some taskprocessor bugs.Mark Michelson
The new thread creation test fails because Asterisk locks up while trying to lock a taskprocessor. While trying to debug that, I found a race condition during taskprocessor creation where a default taskprocessor listener could try to operate on a partially started taskprocessor. This was fixed by adding a new callback to taskprocessor listeners. Then while testing that change, I found some bugs in the taskprocessor tests where I was not properly unlocking when done with a lock. Scoped locks have spoiled me a bit. I still have not figured out why the threadpool thread creation test is locking up. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377368 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-06It helps if we actually assign the listener to the pool.Mark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377352 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-06Add initial simple threadpool test.Mark Michelson
This one simply pushes a task into the threadpool and ensures that the listener gets the callbacks expected. It currently crashes, so I need to figure out what's wrong. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377351 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-04Simplify threadpool refcounting a bit.Mark Michelson
Since threadpool shutdown is very strictly controlled, there is no need to be so precise with reference counts in queued operations. Since the threadpool shuts down its own control taskprocessor before doing anything else destructive, it can be guaranteed that all queued tasks will have a valid pointer to the pool. This meant that some destructor functions for helper structs could be removed entirely. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377210 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-03Fix a few miscellaneous thingsMark Michelson
* Renamed some taskprocessor listener callbacks * Fixed what would become a refcounting issue for pools * Removed some XXX comments from allocation failure points git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377061 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-30Some more progress.Mark Michelson
Still does not compile. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376898 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