You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ar...@apache.org on 2018/07/09 15:13:38 UTC

mesos git commit: Fixed unproperly guarded future.

Repository: mesos
Updated Branches:
  refs/heads/master b4e08210d -> 81a7b5f68


Fixed unproperly guarded future.

This patch fixes a bug where the code path could cause a crash because
of calling `Fture<T>::get()` on a future which is failed.

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


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

Branch: refs/heads/master
Commit: 81a7b5f687e0fc4b742cf484400e43c5fb56c58c
Parents: b4e0821
Author: Alexander Rojas <al...@mesosphere.io>
Authored: Mon Jun 25 19:53:53 2018 +0200
Committer: Alexander Rojas <al...@mesosphere.io>
Committed: Mon Jul 9 17:13:24 2018 +0200

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/81a7b5f6/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index ddc8df0..0c0d6ca 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -9791,18 +9791,19 @@ void Master::_authenticate(
     const UPID& pid,
     const Future<Option<string>>& future)
 {
-  if (!future.isReady() || future->isNone()) {
-    const string& error = future.isReady()
-        ? "Refused authentication"
-        : (future.isFailed() ? future.failure() : "future discarded");
-
-    LOG(WARNING) << "Failed to authenticate " << pid
-                 << ": " << error;
-  } else {
+  if (future.isReady() && future->isSome()) {
     LOG(INFO) << "Successfully authenticated principal '" << future->get()
               << "' at " << pid;
 
     authenticated.put(pid, future->get());
+  } else if (future.isReady() && future->isNone()) {
+    LOG(INFO) << "Authentication of " << pid << " was unsuccessful:"
+              << " Invalid credentials";
+  } else if (future.isFailed()) {
+    LOG(WARNING) << "An error ocurred while attempting to authenticate " << pid
+                 << ": " << future.failure();
+  } else {
+    LOG(INFO) << "Authentication of " << pid << " was discarded";
   }
 
   CHECK(authenticating.contains(pid));