diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2009-07-30 14:06:49 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2009-07-30 14:06:49 +0000 |
| commit | 9c095c4cd694287151cc1fabcc274fd435944dee (patch) | |
| tree | aea55b408f4461f86cc2087629e71c21247ab392 /cpp/src/qpid/broker/Connection.cpp | |
| parent | 20dfc1f76b845a7d6826f9a27923827fd60ea0e9 (diff) | |
| download | qpid-python-9c095c4cd694287151cc1fabcc274fd435944dee.tar.gz | |
Change all broker users of broker::Timer to use sys::Timer
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@799273 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/Connection.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/Connection.cpp | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index 91c95289ac..a1a3c6ada7 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -49,35 +49,25 @@ namespace _qmf = qmf::org::apache::qpid::broker; namespace qpid { namespace broker { -struct ConnectionTimeoutTask : public TimerTask { - Timer& timer; +struct ConnectionTimeoutTask : public sys::TimerTask { + sys::Timer& timer; Connection& connection; - AbsTime expires; - ConnectionTimeoutTask(uint16_t hb, Timer& t, Connection& c) : + ConnectionTimeoutTask(uint16_t hb, sys::Timer& t, Connection& c) : TimerTask(Duration(hb*2*TIME_SEC)), timer(t), - connection(c), - expires(AbsTime::now(), duration) + connection(c) {} - void touch() - { - expires = AbsTime(AbsTime::now(), duration); + void touch() { + restart(); } void fire() { - // This is the best we can currently do to avoid a destruction/fire race - if (isCancelled()) return; - if (expires < AbsTime::now()) { - // If we get here then we've not received any traffic in the timeout period - // Schedule closing the connection for the io thread - QPID_LOG(error, "Connection timed out: closing"); - connection.abort(); - } else { - reset(); - timer.add(this); - } + // If we get here then we've not received any traffic in the timeout period + // Schedule closing the connection for the io thread + QPID_LOG(error, "Connection timed out: closing"); + connection.abort(); } }; @@ -338,25 +328,22 @@ void Connection::setSecureConnection(SecureConnection* s) adapter.setSecureConnection(s); } -struct ConnectionHeartbeatTask : public TimerTask { - Timer& timer; +struct ConnectionHeartbeatTask : public sys::TimerTask { + sys::Timer& timer; Connection& connection; - ConnectionHeartbeatTask(uint16_t hb, Timer& t, Connection& c) : + ConnectionHeartbeatTask(uint16_t hb, sys::Timer& t, Connection& c) : TimerTask(Duration(hb*TIME_SEC)), timer(t), connection(c) {} void fire() { - // This is the best we can currently do to avoid a destruction/fire race - if (!isCancelled()) { - // Setup next firing - reset(); - timer.add(this); - - // Send Heartbeat - connection.sendHeartbeat(); - } + // Setup next firing + setupNextFire(); + timer.add(this); + + // Send Heartbeat + connection.sendHeartbeat(); } }; |
