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 2013/07/02 21:41:20 UTC

[2/2] git commit: Fixed a crash due to invalid utime / stime values coming from /proc/pid/stat.

Fixed a crash due to invalid utime / stime values coming from /proc/pid/stat.

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


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

Branch: refs/heads/master
Commit: d46f3e20acf29ae088fefeb9f1444fd8377414a7
Parents: 8106fa3
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Mon Jul 1 19:43:07 2013 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Tue Jul 2 12:10:59 2013 -0700

----------------------------------------------------------------------
 src/slave/process_isolator.cpp | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/d46f3e20/src/slave/process_isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/process_isolator.cpp b/src/slave/process_isolator.cpp
index e5496f3..4b65b35 100644
--- a/src/slave/process_isolator.cpp
+++ b/src/slave/process_isolator.cpp
@@ -388,9 +388,17 @@ Future<ResourceStatistics> ProcessIsolator::usage(
   }
 
   result.set_timestamp(Clock::now().secs());
-  result.set_mem_rss_bytes(process.get().rss.bytes());
-  result.set_cpus_user_time_secs(process.get().utime.secs());
-  result.set_cpus_system_time_secs(process.get().stime.secs());
+
+  if (process.get().rss.isSome()) {
+    result.set_mem_rss_bytes(process.get().rss.get().bytes());
+  }
+
+  // We only show utime and stime when both are available, otherwise
+  // we're exposing a partial view of the CPU times.
+  if (process.get().utime.isSome() && process.get().stime.isSome()) {
+    result.set_cpus_user_time_secs(process.get().utime.get().secs());
+    result.set_cpus_system_time_secs(process.get().stime.get().secs());
+  }
 
   // Now aggregate all descendant process usage statistics.
   const Try<set<pid_t> >& children = os::children(info->pid.get(), true);
@@ -417,12 +425,19 @@ Future<ResourceStatistics> ProcessIsolator::usage(
       continue;
     }
 
-    result.set_mem_rss_bytes(
-        result.mem_rss_bytes() + process.get().rss.bytes());
-    result.set_cpus_user_time_secs(
-        result.cpus_user_time_secs() + process.get().utime.secs());
-    result.set_cpus_system_time_secs(
-        result.cpus_system_time_secs() + process.get().stime.secs());
+    if (process.get().rss.isSome()) {
+      result.set_mem_rss_bytes(
+          result.mem_rss_bytes() + process.get().rss.get().bytes());
+    }
+
+    // We only show utime and stime when both are available, otherwise
+    // we're exposing a partial view of the CPU times.
+    if (process.get().utime.isSome() && process.get().stime.isSome()) {
+      result.set_cpus_user_time_secs(
+          result.cpus_user_time_secs() + process.get().utime.get().secs());
+      result.set_cpus_system_time_secs(
+          result.cpus_system_time_secs() + process.get().stime.get().secs());
+    }
   }
 
   return result;