summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/epoll/EpollPoller.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2009-12-07 15:42:14 +0000
committerAndrew Stitcher <astitcher@apache.org>2009-12-07 15:42:14 +0000
commit7bbd0fdd577b167127633a7b52fe7ea487b1f267 (patch)
tree5752af0626dad35879b91c96d09d802595f779d8 /cpp/src/qpid/sys/epoll/EpollPoller.cpp
parent6a667d2a64bb124c585ef165821dfd60e3f5de04 (diff)
downloadqpid-python-7bbd0fdd577b167127633a7b52fe7ea487b1f267.tar.gz
QPID-2214: Opening and closing client connections causes memory use to grow unboundedly
- Clean up the DeletionManager state for each thread when the thread exits git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@887956 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/epoll/EpollPoller.cpp')
-rw-r--r--cpp/src/qpid/sys/epoll/EpollPoller.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/cpp/src/qpid/sys/epoll/EpollPoller.cpp b/cpp/src/qpid/sys/epoll/EpollPoller.cpp
index fd9a4b3468..d7f64f3b4c 100644
--- a/cpp/src/qpid/sys/epoll/EpollPoller.cpp
+++ b/cpp/src/qpid/sys/epoll/EpollPoller.cpp
@@ -25,6 +25,7 @@
#include "qpid/sys/DeletionManager.h"
#include "qpid/sys/posix/check.h"
#include "qpid/sys/posix/PrivatePosix.h"
+#include "qpid/log/Statement.h"
#include <sys/epoll.h>
#include <errno.h>
@@ -467,28 +468,35 @@ bool Poller::interrupt(PollerHandle& handle) {
}
void Poller::run() {
- // Make sure we can't be interrupted by signals at a bad time
- ::sigset_t ss;
- ::sigfillset(&ss);
- ::pthread_sigmask(SIG_SETMASK, &ss, 0);
-
- do {
- Event event = wait();
-
- // If can read/write then dispatch appropriate callbacks
- if (event.handle) {
- event.process();
- } else {
- // Handle shutdown
- switch (event.type) {
- case SHUTDOWN:
- return;
- default:
- // This should be impossible
- assert(false);
+ // Ensure that we exit thread responsibly under all circumstances
+ try {
+ // Make sure we can't be interrupted by signals at a bad time
+ ::sigset_t ss;
+ ::sigfillset(&ss);
+ ::pthread_sigmask(SIG_SETMASK, &ss, 0);
+
+ do {
+ Event event = wait();
+
+ // If can read/write then dispatch appropriate callbacks
+ if (event.handle) {
+ event.process();
+ } else {
+ // Handle shutdown
+ switch (event.type) {
+ case SHUTDOWN:
+ PollerHandleDeletionManager.destroyThreadState();
+ return;
+ default:
+ // This should be impossible
+ assert(false);
+ }
}
- }
- } while (true);
+ } while (true);
+ } catch (const std::exception& e) {
+ QPID_LOG(error, "IO worker thread exiting with unhandled exception: " << e.what());
+ }
+ PollerHandleDeletionManager.destroyThreadState();
}
Poller::Event Poller::wait(Duration timeout) {