Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8CAAC200B5A for ; Thu, 4 Aug 2016 21:13:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8B3CC160AAB; Thu, 4 Aug 2016 19:13:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D2593160A6A for ; Thu, 4 Aug 2016 21:13:47 +0200 (CEST) Received: (qmail 72292 invoked by uid 500); 4 Aug 2016 19:13:47 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 72279 invoked by uid 99); 4 Aug 2016 19:13:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2016 19:13:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ECA75E0A7D; Thu, 4 Aug 2016 19:13:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cliffjansen@apache.org To: commits@qpid.apache.org Message-Id: <12b2f28e77de4be9955909972e7c57c7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: qpid-cpp git commit: QPID-7373: force all EpollPoller threads to periodically clean DeletionManager resources Date: Thu, 4 Aug 2016 19:13:46 +0000 (UTC) archived-at: Thu, 04 Aug 2016 19:13:48 -0000 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 Authored: Thu Aug 4 12:13:14 2016 -0700 Committer: Cliff Jansen 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