You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2017/04/04 17:49:45 UTC

[1/3] mesos git commit: Fixed 'CombinedAuthenticator' to avoid an extra copy.

Repository: mesos
Updated Branches:
  refs/heads/master 2903c0f0e -> 61fe4732d


Fixed 'CombinedAuthenticator' to avoid an extra copy.

This patch adds a missing call to `std::move` in the constructor
for `CombinedAuthenticatorProcess` to avoid an unnecessary copy.

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


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

Branch: refs/heads/master
Commit: 6fc22d1cc8d0e4bca263fe4df7ea09274de02f01
Parents: 2903c0f
Author: Greg Mann <gr...@mesosphere.io>
Authored: Tue Apr 4 10:40:21 2017 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Tue Apr 4 10:41:53 2017 -0700

----------------------------------------------------------------------
 src/authentication/http/combined_authenticator.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6fc22d1c/src/authentication/http/combined_authenticator.cpp
----------------------------------------------------------------------
diff --git a/src/authentication/http/combined_authenticator.cpp b/src/authentication/http/combined_authenticator.cpp
index c734e76..2ab6081 100644
--- a/src/authentication/http/combined_authenticator.cpp
+++ b/src/authentication/http/combined_authenticator.cpp
@@ -100,7 +100,7 @@ CombinedAuthenticatorProcess::CombinedAuthenticatorProcess(
     const string& _realm,
     vector<Owned<Authenticator>>&& _authenticators)
   : ProcessBase(process::ID::generate("__combined_authenticator__")),
-    authenticators(_authenticators),
+    authenticators(std::move(_authenticators)),
     realm(_realm) {}
 
 


[2/3] mesos git commit: Fixed the signatures of some test helpers.

Posted by an...@apache.org.
Fixed the signatures of some test helpers.

This patch fixes some test helpers for
'CombinedAuthenticatorTest.MultipleAuthenticators' to
accept their parameters as const ref.

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


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

Branch: refs/heads/master
Commit: c2ce0cc3f2c41e0c57ba30c8be06c1faaa324a2e
Parents: 6fc22d1
Author: Greg Mann <gr...@mesosphere.io>
Authored: Tue Apr 4 10:43:04 2017 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Tue Apr 4 10:48:54 2017 -0700

----------------------------------------------------------------------
 src/tests/http_authentication_tests.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c2ce0cc3/src/tests/http_authentication_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/http_authentication_tests.cpp b/src/tests/http_authentication_tests.cpp
index 36d2b73..99bc257 100644
--- a/src/tests/http_authentication_tests.cpp
+++ b/src/tests/http_authentication_tests.cpp
@@ -278,7 +278,7 @@ private:
 };
 
 
-AuthenticationResult createUnauthorized(MockAuthenticator& authenticator)
+AuthenticationResult createUnauthorized(const MockAuthenticator& authenticator)
 {
   AuthenticationResult result;
   result.unauthorized = Unauthorized(
@@ -299,7 +299,7 @@ AuthenticationResult createForbidden(MockAuthenticator& authenticator)
 
 
 AuthenticationResult createCombinedUnauthorized(
-    vector<MockAuthenticator> authenticators)
+    const vector<MockAuthenticator>& authenticators)
 {
   AuthenticationResult result;
   vector<string> headers;
@@ -321,7 +321,7 @@ AuthenticationResult createCombinedUnauthorized(
 
 
 AuthenticationResult createCombinedForbidden(
-    vector<MockAuthenticator> authenticators)
+    const vector<MockAuthenticator>& authenticators)
 {
   AuthenticationResult result;
   vector<string> bodies;


[3/3] mesos git commit: Fixed an iterator bug in 'CombinedAuthenticator::authenticate()'.

Posted by an...@apache.org.
Fixed an iterator bug in 'CombinedAuthenticator::authenticate()'.

This patch updates the `loop()` logic within
`CombinedAuthenticatorProcess::authenticate()` to fix a bug
in which an iterator is incremented past the end of its vector.

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


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

Branch: refs/heads/master
Commit: 61fe4732d3d8eeaf9ee10c15314c91ebc4cf333f
Parents: c2ce0cc
Author: Greg Mann <gr...@mesosphere.io>
Authored: Tue Apr 4 10:43:10 2017 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Tue Apr 4 10:49:00 2017 -0700

----------------------------------------------------------------------
 .../http/combined_authenticator.cpp             | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/61fe4732/src/authentication/http/combined_authenticator.cpp
----------------------------------------------------------------------
diff --git a/src/authentication/http/combined_authenticator.cpp b/src/authentication/http/combined_authenticator.cpp
index 2ab6081..51ec882 100644
--- a/src/authentication/http/combined_authenticator.cpp
+++ b/src/authentication/http/combined_authenticator.cpp
@@ -265,7 +265,7 @@ Future<AuthenticationResult> CombinedAuthenticatorProcess::authenticate(
     const Request& request)
 {
   // Variables to hold the state of the authentication loop.
-  auto authenticator = authenticators.begin();
+  auto iter = authenticators.begin();
   auto end = authenticators.end();
   // Each pair contains a string representing the scheme of the authenticator
   // and a `Try<AuthenticationResult>` which is used to capture failure messages
@@ -277,18 +277,18 @@ Future<AuthenticationResult> CombinedAuthenticatorProcess::authenticate(
   // Loop over all installed authenticators.
   return loop(
       self(),
-      [authenticator]() mutable {
-        return authenticator++;
+      [iter, end]() mutable {
+        return iter == end ? Option<Owned<Authenticator>>::none() : *(iter++);
       },
-      [request, results, end, self_](
-          vector<Owned<Authenticator>>::const_iterator authenticator) mutable
+      [request, results, self_](
+          const Option<Owned<Authenticator>>& authenticator) mutable
               -> Future<ControlFlow<AuthenticationResult>> {
         // All authentication attempts have failed. Combine them and return.
-        if (authenticator == end) {
+        if (authenticator.isNone()) {
           return combineFailed(results);
         }
 
-        return authenticator->get()->authenticate(request)
+        return authenticator.get()->authenticate(request)
           .then(defer(
               self_,
               [&results, authenticator](const AuthenticationResult& result)
@@ -301,7 +301,7 @@ Future<AuthenticationResult> CombinedAuthenticatorProcess::authenticate(
 
                 if (count != 1) {
                   LOG(WARNING) << "HTTP authenticator for scheme '"
-                               << authenticator->get()->scheme()
+                               << authenticator.get()->scheme()
                                << "' returned a result with " << count
                                << " members set, which is an error";
                   return Continue();
@@ -314,7 +314,7 @@ Future<AuthenticationResult> CombinedAuthenticatorProcess::authenticate(
 
                 // Authentication unsuccessful; append the result and continue.
                 results.push_back(make_pair(
-                    authenticator->get()->scheme(),
+                    authenticator.get()->scheme(),
                     result));
                 return Continue();
               }))
@@ -322,7 +322,7 @@ Future<AuthenticationResult> CombinedAuthenticatorProcess::authenticate(
               const Future<ControlFlow<AuthenticationResult>>& failedResult)
                   -> ControlFlow<AuthenticationResult> {
             results.push_back(make_pair(
-                authenticator->get()->scheme(),
+                authenticator.get()->scheme(),
                 Error(failedResult.failure())));
             return Continue();
           });