summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2010-04-23 03:59:52 +0000
committerAndrew Stitcher <astitcher@apache.org>2010-04-23 03:59:52 +0000
commitfbbda16ce5d06ebebc7d6eabdbd0769a3d886cb8 (patch)
tree7243947a60c12915121bb3f6b21fc40c7d4af72c /cpp/src
parent0251793e6387b741424787ae4902994fd2f46e9f (diff)
downloadqpid-python-fbbda16ce5d06ebebc7d6eabdbd0769a3d886cb8.tar.gz
QPID-1904: Ensure that all timestamp uses are correctly relative to 1/1/1970 epoch.
- Removed the hacky way to access the internal time value in AbsTime now that there is a defined AbsTime value EPOCH. - Changed all the code to use Duration(EPOCH, abtime) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@937147 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qmf/engine/Agent.cpp4
-rw-r--r--cpp/src/qmf/engine/ObjectImpl.cpp4
-rw-r--r--cpp/src/qpid/acl/Acl.cpp2
-rw-r--r--cpp/src/qpid/agent/ManagementAgentImpl.cpp6
-rw-r--r--cpp/src/qpid/broker/SessionManager.cpp2
-rw-r--r--cpp/src/qpid/management/ManagementAgent.cpp14
-rw-r--r--cpp/src/qpid/management/ManagementAgent.h2
-rw-r--r--cpp/src/qpid/sys/posix/Time.cpp4
-rw-r--r--cpp/src/qpid/sys/windows/Time.cpp5
-rw-r--r--cpp/src/tests/echotest.cpp2
-rw-r--r--cpp/src/tests/latencytest.cpp4
11 files changed, 20 insertions, 29 deletions
diff --git a/cpp/src/qmf/engine/Agent.cpp b/cpp/src/qmf/engine/Agent.cpp
index fe9b84c565..7667213e5e 100644
--- a/cpp/src/qmf/engine/Agent.cpp
+++ b/cpp/src/qmf/engine/Agent.cpp
@@ -348,7 +348,7 @@ void AgentImpl::heartbeat()
Buffer buffer(outputBuffer, MA_BUFFER_SIZE);
Protocol::encodeHeader(buffer, Protocol::OP_HEARTBEAT_INDICATION);
- buffer.putLongLong(uint64_t(Duration(now())));
+ buffer.putLongLong(uint64_t(Duration(EPOCH, now())));
stringstream key;
key << "console.heartbeat." << assignedBrokerBank << "." << assignedAgentBank;
sendBufferLH(buffer, QMF_EXCHANGE, key.str());
@@ -484,7 +484,7 @@ void AgentImpl::raiseEvent(Event& event)
Protocol::encodeHeader(buffer, Protocol::OP_EVENT_INDICATION);
event.impl->encodeSchemaKey(buffer);
- buffer.putLongLong(uint64_t(Duration(now())));
+ buffer.putLongLong(uint64_t(Duration(EPOCH, now())));
event.impl->encode(buffer);
string key(event.impl->getRoutingKey(assignedBrokerBank, assignedAgentBank));
diff --git a/cpp/src/qmf/engine/ObjectImpl.cpp b/cpp/src/qmf/engine/ObjectImpl.cpp
index cae0e0da68..45925cb804 100644
--- a/cpp/src/qmf/engine/ObjectImpl.cpp
+++ b/cpp/src/qmf/engine/ObjectImpl.cpp
@@ -27,7 +27,7 @@ using namespace qmf::engine;
using namespace qpid::sys;
using qpid::framing::Buffer;
-ObjectImpl::ObjectImpl(const SchemaObjectClass* type) : objectClass(type), broker(0), createTime(uint64_t(Duration(now()))), destroyTime(0), lastUpdatedTime(createTime)
+ObjectImpl::ObjectImpl(const SchemaObjectClass* type) : objectClass(type), broker(0), createTime(uint64_t(Duration(EPOCH, now()))), destroyTime(0), lastUpdatedTime(createTime)
{
int propCount = objectClass->getPropertyCount();
int statCount = objectClass->getStatisticCount();
@@ -93,7 +93,7 @@ ObjectImpl::~ObjectImpl()
void ObjectImpl::destroy()
{
- destroyTime = uint64_t(Duration(now()));
+ destroyTime = uint64_t(Duration(EPOCH, now()));
// TODO - flag deletion
}
diff --git a/cpp/src/qpid/acl/Acl.cpp b/cpp/src/qpid/acl/Acl.cpp
index f826106dbe..67603015d7 100644
--- a/cpp/src/qpid/acl/Acl.cpp
+++ b/cpp/src/qpid/acl/Acl.cpp
@@ -157,7 +157,7 @@ Acl::Acl (AclValues& av, Broker& b): aclValues(av), broker(&b), transferAcl(fals
mgmtObject->set_transferAcl(transferAcl?1:0);
mgmtObject->set_policyFile(aclFile);
sys::AbsTime now = sys::AbsTime::now();
- int64_t ns = sys::Duration(now);
+ int64_t ns = sys::Duration(sys::EPOCH, now);
mgmtObject->set_lastAclLoad(ns);
agent->raiseEvent(_qmf::EventFileLoaded(""));
}
diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp
index 6bff91efd0..b0207582ee 100644
--- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp
+++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp
@@ -255,7 +255,7 @@ void ManagementAgentImpl::raiseEvent(const ManagementEvent& event, severity_t se
event.getMd5Sum());
event.mapEncode(values);
map_["_values"] = values;
- map_["_timestamp"] = uint64_t(Duration(now()));
+ map_["_timestamp"] = uint64_t(Duration(EPOCH, now()));
map_["_severity"] = sev;
headers["method"] = "indication";
@@ -372,7 +372,7 @@ void ManagementAgentImpl::sendHeartbeat()
headers["qmf.agent"] = name_address;
map["_values"] = attrMap;
- map["_values"].asMap()["timestamp"] = uint64_t(Duration(now()));
+ map["_values"].asMap()["timestamp"] = uint64_t(Duration(EPOCH, now()));
map["_values"].asMap()["heartbeat_interval"] = interval;
map["_values"].asMap()["epoch"] = bootSequence;
@@ -675,7 +675,7 @@ void ManagementAgentImpl::handleLocateRequest(const string&, const string& cid,
headers["qmf.agent"] = name_address;
map["_values"] = attrMap;
- map["_values"].asMap()["timestamp"] = uint64_t(Duration(now()));
+ map["_values"].asMap()["timestamp"] = uint64_t(Duration(EPOCH, now()));
map["_values"].asMap()["heartbeat_interval"] = interval;
map["_values"].asMap()["epoch"] = bootSequence;
diff --git a/cpp/src/qpid/broker/SessionManager.cpp b/cpp/src/qpid/broker/SessionManager.cpp
index 996a02f4c6..8cc58571af 100644
--- a/cpp/src/qpid/broker/SessionManager.cpp
+++ b/cpp/src/qpid/broker/SessionManager.cpp
@@ -72,7 +72,7 @@ void SessionManager::detach(std::auto_ptr<SessionState> session) {
if (session->getTimeout() > 0) {
session->expiry = AbsTime(now(),session->getTimeout()*TIME_SEC);
if (session->mgmtObject != 0)
- session->mgmtObject->set_expireTime ((uint64_t) Duration (session->expiry));
+ session->mgmtObject->set_expireTime ((uint64_t) Duration (EPOCH, session->expiry));
detached.push_back(session.release()); // In expiry order
eraseExpired();
}
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp
index c83b03afba..c4b670ca5f 100644
--- a/cpp/src/qpid/management/ManagementAgent.cpp
+++ b/cpp/src/qpid/management/ManagementAgent.cpp
@@ -80,7 +80,7 @@ ManagementAgent::RemoteAgent::~RemoteAgent ()
ManagementAgent::ManagementAgent (const bool qmfV1, const bool qmfV2) :
threadPoolSize(1), interval(10), broker(0), timer(0),
- startTime(uint64_t(sys::Duration(sys::now()))),
+ startTime(sys::now()),
suppressed(false),
qmf1Support(qmfV1), qmf2Support(qmfV2)
{
@@ -335,7 +335,7 @@ void ManagementAgent::raiseEvent(const ManagementEvent& event, severity_t severi
outBuffer.putShortString(event.getPackageName());
outBuffer.putShortString(event.getEventName());
outBuffer.putBin128(event.getMd5Sum());
- outBuffer.putLongLong(uint64_t(sys::Duration(sys::now())));
+ outBuffer.putLongLong(uint64_t(sys::Duration(sys::EPOCH, sys::now())));
outBuffer.putOctet(sev);
std::string sBuf;
event.encode(sBuf);
@@ -359,7 +359,7 @@ void ManagementAgent::raiseEvent(const ManagementEvent& event, severity_t severi
event.getMd5Sum());
event.mapEncode(values);
map_["_values"] = values;
- map_["_timestamp"] = uint64_t(sys::Duration(sys::now()));
+ map_["_timestamp"] = uint64_t(sys::Duration(sys::EPOCH, sys::now()));
map_["_severity"] = sev;
headers["method"] = "indication";
@@ -594,7 +594,7 @@ void ManagementAgent::periodicProcessing (void)
list<pair<ObjectId, ManagementObject*> > deleteList;
std::string sBuf;
- uint64_t uptime = uint64_t(sys::Duration(sys::now())) - startTime;
+ uint64_t uptime = sys::Duration(startTime, sys::now());
static_cast<_qmf::Broker*>(broker->GetManagementObject())->set_uptime(uptime);
moveNewObjectsLH();
@@ -797,7 +797,7 @@ void ManagementAgent::periodicProcessing (void)
char msgChars[BUFSIZE];
Buffer msgBuffer(msgChars, BUFSIZE);
encodeHeader(msgBuffer, 'h');
- msgBuffer.putLongLong(uint64_t(sys::Duration(sys::now())));
+ msgBuffer.putLongLong(uint64_t(sys::Duration(sys::EPOCH, sys::now())));
contentSize = BUFSIZE - msgBuffer.available ();
msgBuffer.reset ();
@@ -817,7 +817,7 @@ void ManagementAgent::periodicProcessing (void)
headers["qmf.agent"] = name_address;
map["_values"] = attrMap;
- map["_values"].asMap()["timestamp"] = uint64_t(sys::Duration(sys::now()));
+ map["_values"].asMap()["timestamp"] = uint64_t(sys::Duration(sys::EPOCH, sys::now()));
map["_values"].asMap()["heartbeat_interval"] = interval;
map["_values"].asMap()["epoch"] = bootSequence;
@@ -1720,7 +1720,7 @@ void ManagementAgent::handleLocateRequestLH(const string&, const string& replyTo
headers["qmf.agent"] = name_address;
map["_values"] = attrMap;
- map["_values"].asMap()["timestamp"] = uint64_t(sys::Duration(sys::now()));
+ map["_values"].asMap()["timestamp"] = uint64_t(sys::Duration(sys::EPOCH, sys::now()));
map["_values"].asMap()["heartbeat_interval"] = interval;
map["_values"].asMap()["epoch"] = bootSequence;
diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h
index 2366446fe0..ca3f742cb7 100644
--- a/cpp/src/qpid/management/ManagementAgent.h
+++ b/cpp/src/qpid/management/ManagementAgent.h
@@ -273,7 +273,7 @@ private:
uint32_t nextRemoteBank;
uint32_t nextRequestSequence;
bool clientWasAdded;
- const uint64_t startTime;
+ const qpid::sys::AbsTime startTime;
bool suppressed;
std::auto_ptr<IdAllocator> allocator;
diff --git a/cpp/src/qpid/sys/posix/Time.cpp b/cpp/src/qpid/sys/posix/Time.cpp
index 19c7ef20ba..b3858279b4 100644
--- a/cpp/src/qpid/sys/posix/Time.cpp
+++ b/cpp/src/qpid/sys/posix/Time.cpp
@@ -56,10 +56,6 @@ AbsTime AbsTime::now() {
return time_now;
}
-Duration::Duration(const AbsTime& time0) :
- nanosecs(time0.timepoint)
-{}
-
Duration::Duration(const AbsTime& start, const AbsTime& finish) :
nanosecs(finish.timepoint - start.timepoint)
{}
diff --git a/cpp/src/qpid/sys/windows/Time.cpp b/cpp/src/qpid/sys/windows/Time.cpp
index 8d34c937ef..16d09fcdc0 100644
--- a/cpp/src/qpid/sys/windows/Time.cpp
+++ b/cpp/src/qpid/sys/windows/Time.cpp
@@ -59,11 +59,6 @@ AbsTime AbsTime::now() {
return time_now;
}
-Duration::Duration(const AbsTime& time0) : nanosecs(0) {
- time_period p(ptime(min_date_time), time0.timepoint);
- nanosecs = p.length().total_nanoseconds();
-}
-
Duration::Duration(const AbsTime& start, const AbsTime& finish) {
time_duration d = finish.timepoint - start.timepoint;
nanosecs = d.total_nanoseconds();
diff --git a/cpp/src/tests/echotest.cpp b/cpp/src/tests/echotest.cpp
index dcb1869e4d..5114ab883d 100644
--- a/cpp/src/tests/echotest.cpp
+++ b/cpp/src/tests/echotest.cpp
@@ -64,7 +64,7 @@ struct Args : public qpid::Options,
uint64_t current_time()
{
- Duration t(now());
+ Duration t(EPOCH, now());
return t;
}
diff --git a/cpp/src/tests/latencytest.cpp b/cpp/src/tests/latencytest.cpp
index a205ef6c7c..20eb4568f3 100644
--- a/cpp/src/tests/latencytest.cpp
+++ b/cpp/src/tests/latencytest.cpp
@@ -97,7 +97,7 @@ Connection globalConnection;
uint64_t current_time()
{
- Duration t(now());
+ Duration t(EPOCH, now());
return t;
}
@@ -363,7 +363,7 @@ void Sender::sendByRate()
AbsTime start = now();
while (true) {
AbsTime sentAt=now();
- msg.getDeliveryProperties().setTimestamp(Duration(sentAt));
+ msg.getDeliveryProperties().setTimestamp(Duration(EPOCH, sentAt));
async(session).messageTransfer(arg::content=msg, arg::acceptMode=1);
if (opts.sync) session.sync();
++sent;