diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2009-07-30 14:06:39 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2009-07-30 14:06:39 +0000 |
| commit | ee3b47f258adb3acf2935b21ac9474c2c3632c11 (patch) | |
| tree | a04d95dcdab91caa169377a1c203890862c0746d /qpid/cpp/src | |
| parent | a1b1ab88d5de7ef6753eb8173c691d1a3e568ddd (diff) | |
| download | qpid-python-ee3b47f258adb3acf2935b21ac9474c2c3632c11.tar.gz | |
Added diagnostics to tell if timer callbacks overrun their allowed time
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@799272 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/sys/Timer.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpid/sys/Timer.cpp b/qpid/cpp/src/qpid/sys/Timer.cpp index 12bc8498ad..5ed117db93 100644 --- a/qpid/cpp/src/qpid/sys/Timer.cpp +++ b/qpid/cpp/src/qpid/sys/Timer.cpp @@ -20,7 +20,8 @@ */ #include "qpid/sys/Timer.h" #include "qpid/sys/Mutex.h" -#include <iostream> +#include "qpid/log/Statement.h" + #include <numeric> using boost::intrusive_ptr; @@ -58,6 +59,8 @@ void TimerTask::setupNextFire() { if (period && readyToFire()) { nextFireTime = AbsTime(nextFireTime, period); cancelled = false; + } else { + QPID_LOG(error, "Couldn't setup next timer firing: " << Duration(nextFireTime, AbsTime::now()) << "[" << period << "]"); } } @@ -91,19 +94,34 @@ void Timer::run() } else { intrusive_ptr<TimerTask> t = tasks.top(); tasks.pop(); + assert(!(t->nextFireTime < t->sortTime)); + + // warn on extreme lateness + AbsTime start(AbsTime::now()); + Duration late(t->sortTime, start); + if (late > 500 * TIME_MSEC) { + QPID_LOG(warning, "Timer delayed by " << late / TIME_MSEC << "ms"); + } { ScopedLock<Mutex> l(t->callbackLock); if (t->cancelled) { continue; - } else if(t->readyToFire()) { + } else if(Duration(t->nextFireTime, start) >= 0) { Monitor::ScopedUnlock u(monitor); t->fireTask(); + // Warn on callback overrun + AbsTime end(AbsTime::now()); + Duration overrun(tasks.top()->nextFireTime, end); + if (overrun > 1 * TIME_MSEC) { + QPID_LOG(warning, + "Timer callback overran by " << overrun / TIME_MSEC << "ms [taking " + << Duration(start, end) << "]"); + } continue; } else { // If the timer was adjusted into the future it might no longer // be the next event, so push and then get top to make sure // You can only push events into the future - assert(!(t->nextFireTime < t->sortTime)); t->sortTime = t->nextFireTime; tasks.push(t); } |
