You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/12/12 02:10:22 UTC
qpid-proton git commit: PROTON-1981: [cpp] timestamp::now returns
wrong value.
Repository: qpid-proton
Updated Branches:
refs/heads/master 3fba028e9 -> 6745a5059
PROTON-1981: [cpp] timestamp::now returns wrong value.
Was returning pn_proactor_now() which is monotonic time, fixed to return
wall-clock time.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6745a505
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6745a505
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6745a505
Branch: refs/heads/master
Commit: 6745a5059264d32f27953a448da60eed8dcd740c
Parents: 3fba028
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 11 20:28:24 2018 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 11 20:28:24 2018 -0500
----------------------------------------------------------------------
cpp/src/timestamp.cpp | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6745a505/cpp/src/timestamp.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/timestamp.cpp b/cpp/src/timestamp.cpp
index 437276e..0e1cc96 100644
--- a/cpp/src/timestamp.cpp
+++ b/cpp/src/timestamp.cpp
@@ -20,17 +20,45 @@
#include "proton/timestamp.hpp"
#include "proton/internal/config.hpp"
+#include <proton/error.hpp>
#include <proton/proactor.h>
#include <proton/types.h>
#include <iostream>
+// Can't use std::chrono since we still support C++03, sigh.
+
+#ifdef WIN32
+#include <windows.h>
+
+#else
+#include <sys/time.h>
+#endif
+
namespace proton {
+#ifdef WIN32
+
timestamp timestamp::now() {
- return timestamp( pn_proactor_now() );
+ FILETIME now;
+ GetSystemTimeAsFileTime(&now);
+ ULARGE_INTEGER t;
+ t.u.HighPart = now.dwHighDateTime;
+ t.u.LowPart = now.dwLowDateTime;
+ // Convert to milliseconds and adjust base epoch
+ return timestamp(t.QuadPart / 10000 - 11644473600000);
}
+#else
+
+timestamp timestamp::now() {
+ struct timeval now;
+ if (::gettimeofday(&now, NULL)) throw proton::error("gettimeofday failed");
+ return timestamp(int64_t(now.tv_sec) * 1000 + (now.tv_usec / 1000));
+}
+
+#endif
+
std::ostream& operator<<(std::ostream& o, timestamp ts) { return o << ts.milliseconds(); }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org