summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/cluster/ClusterTimer.cpp6
-rw-r--r--cpp/src/qpid/sys/Timer.cpp32
-rw-r--r--cpp/src/qpid/sys/Timer.h4
3 files changed, 26 insertions, 16 deletions
diff --git a/cpp/src/qpid/cluster/ClusterTimer.cpp b/cpp/src/qpid/cluster/ClusterTimer.cpp
index 612758152f..4068a4783c 100644
--- a/cpp/src/qpid/cluster/ClusterTimer.cpp
+++ b/cpp/src/qpid/cluster/ClusterTimer.cpp
@@ -34,7 +34,11 @@ using sys::Timer;
using sys::TimerTask;
-ClusterTimer::ClusterTimer(Cluster& c) : cluster(c) {}
+ClusterTimer::ClusterTimer(Cluster& c) : cluster(c) {
+ // Allow more generous overrun threshold with cluster as we
+ // have to do a CPG round trip before executing the task.
+ overran = 10*sys::TIME_MSEC;
+}
ClusterTimer::~ClusterTimer() {}
diff --git a/cpp/src/qpid/sys/Timer.cpp b/cpp/src/qpid/sys/Timer.cpp
index fcd58b187f..ffd1921b46 100644
--- a/cpp/src/qpid/sys/Timer.cpp
+++ b/cpp/src/qpid/sys/Timer.cpp
@@ -76,7 +76,10 @@ void TimerTask::cancel() {
}
Timer::Timer() :
- active(false)
+ active(false),
+ late(50 * TIME_MSEC),
+ overran(2 * TIME_MSEC),
+ lateCancel(500 * TIME_MSEC)
{
start();
}
@@ -105,7 +108,7 @@ void Timer::run()
ScopedLock<Mutex> l(t->callbackLock);
if (t->cancelled) {
drop(t);
- if (delay > 500 * TIME_MSEC) {
+ if (delay > lateCancel) {
QPID_LOG(debug, "cancelled Timer woken up " << delay / TIME_MSEC
<< "ms late");
}
@@ -116,20 +119,19 @@ void Timer::run()
// Warn on callback overrun
AbsTime end(AbsTime::now());
Duration overrun(tasks.top()->nextFireTime, end);
- bool late = delay > 50 * TIME_MSEC;
- bool overran = overrun > 2 * TIME_MSEC;
- if (late)
- if (overran) {
+ if (delay > late) {
+ if (overrun > overran) {
+ QPID_LOG(warning,
+ "Timer woken up " << delay / TIME_MSEC << "ms late, "
+ "overrunning by " << overrun / TIME_MSEC << "ms [taking "
+ << Duration(start, end) << "]");
+ } else {
+ QPID_LOG(warning, "Timer woken up " << delay / TIME_MSEC << "ms late");
+ }
+ } else if (overrun > overran) {
QPID_LOG(warning,
- "Timer woken up " << delay / TIME_MSEC << "ms late, "
- "overrunning by " << overrun / TIME_MSEC << "ms [taking "
- << Duration(start, end) << "]");
- } else {
- QPID_LOG(warning, "Timer woken up " << delay / TIME_MSEC << "ms late");
- } else if (overran) {
- QPID_LOG(warning,
- "Timer callback overran by " << overrun / TIME_MSEC << "ms [taking "
- << Duration(start, end) << "]");
+ "Timer callback overran by " << overrun / TIME_MSEC <<
+ "ms [taking " << Duration(start, end) << "]");
}
continue;
} else {
diff --git a/cpp/src/qpid/sys/Timer.h b/cpp/src/qpid/sys/Timer.h
index 4a579fe032..1e0599e347 100644
--- a/cpp/src/qpid/sys/Timer.h
+++ b/cpp/src/qpid/sys/Timer.h
@@ -92,6 +92,10 @@ class Timer : private Runnable {
protected:
QPID_COMMON_EXTERN virtual void fire(boost::intrusive_ptr<TimerTask> task);
QPID_COMMON_EXTERN virtual void drop(boost::intrusive_ptr<TimerTask> task);
+ // Allow derived classes to change the late/overran thresholds.
+ Duration late;
+ Duration overran;
+ Duration lateCancel;
};