diff options
author | Gordon Sim <gsim@apache.org> | 2006-12-01 17:18:54 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2006-12-01 17:18:54 +0000 |
commit | a1cb80446649bc3401bcb638d5ce53548bf6719e (patch) | |
tree | b33036b6d761aac78aa2a668bbcb2b873dd55a23 /cpp/lib/common/sys | |
parent | 111d887f846865c2af8c93b4b834ce2ca7ca1c60 (diff) | |
download | qpid-python-a1cb80446649bc3401bcb638d5ce53548bf6719e.tar.gz |
Re-enable signal handling. Make APRAcceptor::shutdown() threadsafe.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@481305 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/common/sys')
-rw-r--r-- | cpp/lib/common/sys/apr/APRAcceptor.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/cpp/lib/common/sys/apr/APRAcceptor.cpp b/cpp/lib/common/sys/apr/APRAcceptor.cpp index c998b33625..6853833797 100644 --- a/cpp/lib/common/sys/apr/APRAcceptor.cpp +++ b/cpp/lib/common/sys/apr/APRAcceptor.cpp @@ -37,11 +37,15 @@ class APRAcceptor : public Acceptor virtual void shutdown(); private: + void shutdownImpl(); + + private: int16_t port; bool trace; LFProcessor processor; apr_socket_t* socket; volatile bool running; + Mutex shutdownLock; }; // Define generic Acceptor::create() to return APRAcceptor. @@ -88,23 +92,30 @@ void APRAcceptor::run(SessionHandlerFactory* factory) { LFSessionContext* session = new LFSessionContext(APRPool::get(), client, &processor, trace); session->init(factory->create(session)); }else{ - running = false; - if(status != APR_EINTR){ - std::cout << "ERROR: " << get_desc(status) << std::endl; + Mutex::ScopedLock locker(shutdownLock); + if(running) { + if(status != APR_EINTR){ + std::cout << "ERROR: " << get_desc(status) << std::endl; + } + shutdownImpl(); } } } - shutdown(); } void APRAcceptor::shutdown() { - // TODO aconway 2006-10-12: Cleanup, this is not thread safe. + Mutex::ScopedLock locker(shutdownLock); if (running) { - running = false; - processor.stop(); - CHECK_APR_SUCCESS(apr_socket_close(socket)); + shutdownImpl(); } } +void APRAcceptor::shutdownImpl() { + Mutex::ScopedLock locker(shutdownLock); + running = false; + processor.stop(); + CHECK_APR_SUCCESS(apr_socket_close(socket)); +} + }} |