-
Notifications
You must be signed in to change notification settings - Fork 46
Make output bucket brigades thread safe #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add its own allocator, as well as its own bucket brigade allocator.
Ensure it has its own allocator as well as its own pool.
|
Please also pull this one: It would appear to need its own allocator as well as its own bucketbrigade allocator. |
|
I modified the code according to your first pull-request, but in a way that compiles under MSVC. As for the other "improve thread protection" changes, would you explain why you need another allocator and an allocator mutex? |
|
Sure: You need another allocator (and pool) because the allocators themselves are not thread safe. Essentially they maintain a linked list of used and free memory, and there is no protection on the modification of that list. The default action on creating a pool is that the new pool inherits the allocator of its parent. This problematic when creating a new pool for a thread. The bucket brigade allocator is not really a new allocator (in the sense of a new thread safe allocator) because it gets its memory from the pool allocator attached to the pool you pass in. So to make allocation in the bucket brigade thread safe (which is what we need as the output bucket brigade is run in the created thread) we need to create a new pool with a different pool allocator (hence I am not entirely sure why you need another allocator mutex, but the bug takes four or five hours to reproduce here, and that is what the apache-dev mailing list advised doing. For the sake of one line, and one call at set up time only, I put this in too. Note the other change was to make the main thread mutex non-nested (rather than Alex Bligh |
Please pull commit 04b57a6 from my fork. This fixes a bug whereby the output bucket brigade is created using the same pool and bucket allocator as the input thread is using, which causes a (very occasional) SEGV.
Diff is at:
abligh@04b57a6