You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2015/03/02 19:58:08 UTC
mesos git commit: Replaced gmtime() with gmtime_r().
Repository: mesos
Updated Branches:
refs/heads/master d55a7239c -> cc4ace3d3
Replaced gmtime() with gmtime_r().
Review: https://reviews.apache.org/r/31518
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cc4ace3d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cc4ace3d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cc4ace3d
Branch: refs/heads/master
Commit: cc4ace3d34f250492ad01498fc977da8d543fde6
Parents: d55a723
Author: Vinod Kone <vi...@gmail.com>
Authored: Thu Feb 26 17:09:50 2015 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Mar 2 10:57:15 2015 -0800
----------------------------------------------------------------------
3rdparty/libprocess/include/process/time.hpp | 10 ++++++----
3rdparty/libprocess/src/encoder.hpp | 7 ++++++-
2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/cc4ace3d/3rdparty/libprocess/include/process/time.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/time.hpp b/3rdparty/libprocess/include/process/time.hpp
index 0803dc5..116f34d 100644
--- a/3rdparty/libprocess/include/process/time.hpp
+++ b/3rdparty/libprocess/include/process/time.hpp
@@ -1,6 +1,8 @@
#ifndef __PROCESS_TIME_HPP__
#define __PROCESS_TIME_HPP__
+#include <time.h>
+
#include <iomanip>
#include <glog/logging.h>
@@ -87,14 +89,14 @@ inline std::ostream& operator << (std::ostream& stream, const Time& time)
char date[64];
// The RFC 3339 Format.
- tm* tm_ = gmtime(&secs);
- if (tm_ == NULL) {
- LOG(ERROR) << "Cannot convert the 'time' to a tm struct using gmtime(): "
+ tm tm_;
+ if (gmtime_r(&secs, &tm_) == NULL) {
+ LOG(ERROR) << "Cannot convert the 'time' to a tm struct using gmtime_r(): "
<< errno;
return stream;
}
- strftime(date, 64, "%Y-%m-%d %H:%M:%S", tm_);
+ strftime(date, 64, "%Y-%m-%d %H:%M:%S", &tm_);
stream << date;
// Append the fraction part in nanoseconds.
http://git-wip-us.apache.org/repos/asf/mesos/blob/cc4ace3d/3rdparty/libprocess/src/encoder.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/encoder.hpp b/3rdparty/libprocess/src/encoder.hpp
index 52dfd7f..e8487b4 100644
--- a/3rdparty/libprocess/src/encoder.hpp
+++ b/3rdparty/libprocess/src/encoder.hpp
@@ -2,6 +2,7 @@
#define __ENCODER_HPP__
#include <stdint.h>
+#include <time.h>
#include <map>
#include <sstream>
@@ -178,8 +179,12 @@ public:
char date[256];
+ tm tm_;
+ PCHECK(gmtime_r(&rawtime, &tm_) != NULL)
+ << "Cannot convert the current time to a tm struct using gmtime_r()";
+
// TODO(benh): Check return code of strftime!
- strftime(date, 256, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&rawtime));
+ strftime(date, 256, "%a, %d %b %Y %H:%M:%S GMT", &tm_);
headers["Date"] = date;