qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cliffjan...@apache.org
Subject qpid-cpp git commit: QPID-7373: force all EpollPoller threads to periodically clean DeletionManager resources
Date Thu, 04 Aug 2016 19:13:46 GMT
Repository: qpid-cpp
Updated Branches:
  refs/heads/master f3270ef39 -> 54cd0842d


QPID-7373: force all EpollPoller threads to periodically clean DeletionManager resources


Project: http://git-wip-us.apache.org/repos/asf/qpid-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-cpp/commit/54cd0842
Tree: http://git-wip-us.apache.org/repos/asf/qpid-cpp/tree/54cd0842
Diff: http://git-wip-us.apache.org/repos/asf/qpid-cpp/diff/54cd0842

Branch: refs/heads/master
Commit: 54cd0842d4273e69644c0fd25fadefee408a1019
Parents: f3270ef
Author: Cliff Jansen <cliffjansen@apache.org>
Authored: Thu Aug 4 12:13:14 2016 -0700
Committer: Cliff Jansen <cliffjansen@apache.org>
Committed: Thu Aug 4 12:13:14 2016 -0700

----------------------------------------------------------------------
 src/qpid/sys/epoll/EpollPoller.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-cpp/blob/54cd0842/src/qpid/sys/epoll/EpollPoller.cpp
----------------------------------------------------------------------
diff --git a/src/qpid/sys/epoll/EpollPoller.cpp b/src/qpid/sys/epoll/EpollPoller.cpp
index 6fdf996..7562085 100644
--- a/src/qpid/sys/epoll/EpollPoller.cpp
+++ b/src/qpid/sys/epoll/EpollPoller.cpp
@@ -548,8 +548,9 @@ bool Poller::hasShutdown()
 
 Poller::Event Poller::wait(Duration timeout) {
     static __thread PollerHandlePrivate* lastReturnedHandle = 0;
+    // Make sure lighly used threads regularly purge DeletionManager memory.
+    static const Duration maxEpollWait = 60 * TIME_SEC;
     epoll_event epe;
-    int timeoutMs = (timeout == TIME_INFINITE) ? -1 : timeout / TIME_MSEC;
     AbsTime targetTimeout = 
         (timeout == TIME_INFINITE) ?
             FAR_FUTURE :
@@ -563,6 +564,18 @@ Poller::Event Poller::wait(Duration timeout) {
     // Repeat until we weren't interrupted by signal
     do {
         PollerHandleDeletionManager.markAllUnusedInThisThread();
+        int timeoutMs;
+        AbsTime now_(now());
+        if (timeout == TIME_INFINITE) {
+            timeoutMs = maxEpollWait / TIME_MSEC;
+        } else if (now_ > targetTimeout || now_ == targetTimeout) {
+                timeoutMs = 0;
+        } else {
+            // Account for truncation when converting to millisecs.
+            Duration remaining(now_, AbsTime(targetTimeout, TIME_MSEC - 1));
+            timeoutMs = std::min(remaining, maxEpollWait) / TIME_MSEC;
+        }
+
         int rc = ::epoll_wait(impl->epollFd, &epe, 1, timeoutMs);
         if (rc ==-1 && errno != EINTR) {
             QPID_POSIX_CHECK(rc);
@@ -655,7 +668,7 @@ Poller::Event Poller::wait(Duration timeout) {
         // be indefinite then we should never return with a time out so we go again.
         // If the wait wasn't indefinite, we check whether we are after the target wait
         // time or not
-        if (timeoutMs == -1) {
+        if (timeout == TIME_INFINITE) {
             continue;
         }
         if (rc == 0 && now() > targetTimeout) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message