You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/01/30 03:05:24 UTC

[3/6] git commit: Fixed the use of a raw unix time in the Slave.

Fixed the use of a raw unix time in the Slave.

This updates the slave to use Time::create to ensure the modification
time matches the current time frame in libprocess.

Review: https://reviews.apache.org/r/17481


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0697d97a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0697d97a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0697d97a

Branch: refs/heads/master
Commit: 0697d97a687e9832e5a47a84d11bce236f9b8799
Parents: 84b86ff
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Tue Jan 28 18:51:34 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Jan 29 17:12:28 2014 -0800

----------------------------------------------------------------------
 src/slave/slave.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0697d97a/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 2d21e16..a97b1d5 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -31,6 +31,7 @@
 #include <process/delay.hpp>
 #include <process/dispatch.hpp>
 #include <process/id.hpp>
+#include <process/time.hpp>
 
 #include <stout/bytes.hpp>
 #include <stout/check.hpp>
@@ -2858,9 +2859,14 @@ Future<Nothing> Slave::garbageCollect(const string& path)
     return Failure(mtime.error());
   }
 
+  // It is unsafe for testing to use unix time directly, we must use
+  // Time::create to convert into a Time object that reflects the
+  // possibly advanced state state of the libprocess Clock.
+  Try<Time> time = Time::create(mtime.get());
+  CHECK_SOME(time);
+
   // GC based on the modification time.
-  Duration delay =
-    flags.gc_delay - (Clock::now().duration() - Seconds(mtime.get()));
+  Duration delay = flags.gc_delay - (Clock::now() - time.get());
 
   return gc.schedule(delay, path);
 }