diff options
author | Gordon Sim <gsim@apache.org> | 2007-05-22 09:50:45 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2007-05-22 09:50:45 +0000 |
commit | 13a373d975a60d45b2dd6de4c3cc821296330e16 (patch) | |
tree | 2ae3d0c69b5032e595281b283aeb2b254eea2d8b /cpp/lib/common/sys/apr/LFSessionContext.cpp | |
parent | 89d3aef1e2888d415f11b1c47450a5cf5ad32b3e (diff) | |
download | qpid-python-13a373d975a60d45b2dd6de4c3cc821296330e16.tar.gz |
Patch submitted to qpid-dev by ksmith@redhat.com. Fixes concurrency issues arising from previous move to use singleton apr pool.
"My patch does three things:
1) Modifies the APRPool class to use alloc/free semantics for APR memory pools. Each time a caller calls APRPool::get() they'll their own pool reference. I've fixed up all the call sites I can find to also call APRPool::free() at the appropriate time.
2) Caches freed APR memory pools in a STL stack. This cuts down on the number of memory pools created overall.
3) As a result of doing #1 and #2 I've introduced a guard mutex around APRPool::get() and APRPool::free(). This is to prevent concurrent access to the memory pool cache. If it's too heavyweight, the mutex along with the caching mechanism could be removed entirely."
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@540511 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/common/sys/apr/LFSessionContext.cpp')
-rw-r--r-- | cpp/lib/common/sys/apr/LFSessionContext.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cpp/lib/common/sys/apr/LFSessionContext.cpp b/cpp/lib/common/sys/apr/LFSessionContext.cpp index 9b12747a97..a06b7537ee 100644 --- a/cpp/lib/common/sys/apr/LFSessionContext.cpp +++ b/cpp/lib/common/sys/apr/LFSessionContext.cpp @@ -20,6 +20,7 @@ */ #include "LFSessionContext.h" #include "APRBase.h" +#include "APRPool.h" #include <QpidError.h> #include <assert.h> @@ -27,7 +28,7 @@ using namespace qpid::sys; using namespace qpid::sys; using namespace qpid::framing; -LFSessionContext::LFSessionContext(apr_pool_t* _pool, apr_socket_t* _socket, +LFSessionContext::LFSessionContext(apr_socket_t* _socket, LFProcessor* const _processor, bool _debug) : debug(_debug), @@ -40,7 +41,7 @@ LFSessionContext::LFSessionContext(apr_pool_t* _pool, apr_socket_t* _socket, closing(false) { - fd.p = _pool; + fd.p = APRPool::get(); fd.desc_type = APR_POLL_SOCKET; fd.reqevents = APR_POLLIN; fd.client_data = this; @@ -156,6 +157,7 @@ void LFSessionContext::close(){ void LFSessionContext::handleClose(){ handler->closed(); + APRPool::free(fd.p); std::cout << "Session closed [" << &socket << "]" << std::endl; delete handler; delete this; |