Repository: mesos
Updated Branches:
  refs/heads/master f33eea2e1 -> 53d354156


Cleaned up TaskID validation in the Master.

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


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

Branch: refs/heads/master
Commit: 53d3541566770860d2ab1969cc4958dd5fdf49dd
Parents: f33eea2
Author: Dominic Hamon <[email protected]>
Authored: Thu Mar 6 12:23:32 2014 -0800
Committer: Benjamin Mahler <[email protected]>
Committed: Thu Mar 6 12:23:32 2014 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/53d35415/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 3c7f59a..2a40333 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -18,6 +18,8 @@
 
 #include <stdint.h>
 
+#include <algorithm>
+#include <cctype>
 #include <fstream>
 #include <iomanip>
 #include <list>
@@ -1158,20 +1160,16 @@ struct TaskIDChecker : TaskInfoVisitor
       const Framework& framework,
       const Slave& slave)
   {
-    const std::string& id = task.task_id().value();
+    const string& id = task.task_id().value();
 
-    if (id.size() > PATH_MAX) {
-      return "Task ID '" + id + "' is too long";
-    }
-
-    if (std::count_if(id.begin(), id.end(), isInvalid) != 0) {
-      return "Task ID '" + id + "' contains invalid characters.";
+    if (std::count_if(id.begin(), id.end(), invalid) > 0) {
+      return "TaskID '" + id + "' contains invalid characters";
     }
 
     return None();
   }
 
-  static bool isInvalid(int c)
+  static bool invalid(char c)
   {
     return iscntrl(c) || c == '/' || c == '\\';
   }

Reply via email to