You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2018/03/20 08:02:20 UTC
[1/4] qpid-proton git commit: PROTON-1589: Fix reconnect API error
Repository: qpid-proton
Updated Branches:
refs/heads/master 035b4cb6e -> 95776152d
PROTON-1589: Fix reconnect API error
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0737e42d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0737e42d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0737e42d
Branch: refs/heads/master
Commit: 0737e42dfa3670702fc5c8af1f26f0729f622d38
Parents: 035b4cb
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri Mar 16 18:15:57 2018 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Mar 19 13:44:48 2018 -0400
----------------------------------------------------------------------
proton-c/bindings/cpp/include/proton/connection_options.hpp | 2 +-
proton-c/bindings/cpp/src/connection_options.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0737e42d/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index ac6a90a..2583a16 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -152,7 +152,7 @@ class connection_options {
PN_CPP_EXTERN connection_options& sasl_config_path(const std::string&);
/// **Unsettled API** - Set reconnect and failover options.
- PN_CPP_EXTERN connection_options& reconnect(reconnect_options &);
+ PN_CPP_EXTERN connection_options& reconnect(const reconnect_options &);
/// Update option values from values set in other.
PN_CPP_EXTERN connection_options& update(const connection_options& other);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0737e42d/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index a531452..362d1cf 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -192,7 +192,7 @@ connection_options& connection_options::container_id(const std::string &id) { im
connection_options& connection_options::virtual_host(const std::string &id) { impl_->virtual_host = id; return *this; }
connection_options& connection_options::user(const std::string &user) { impl_->user = user; return *this; }
connection_options& connection_options::password(const std::string &password) { impl_->password = password; return *this; }
-connection_options& connection_options::reconnect(reconnect_options &r) { impl_->reconnect = r; return *this; }
+connection_options& connection_options::reconnect(const reconnect_options &r) { impl_->reconnect = r; return *this; }
connection_options& connection_options::ssl_client_options(const class ssl_client_options &c) { impl_->ssl_client_options = c; return *this; }
connection_options& connection_options::ssl_server_options(const class ssl_server_options &c) { impl_->ssl_server_options = c; return *this; }
connection_options& connection_options::sasl_enabled(bool b) { impl_->sasl_enabled = b; return *this; }
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/4] qpid-proton git commit: PROTON-1589: [C++ binding] Stop
reconnect attempts on authorization failure
Posted by as...@apache.org.
PROTON-1589: [C++ binding] Stop reconnect attempts on authorization failure
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/95776152
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/95776152
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/95776152
Branch: refs/heads/master
Commit: 95776152d50e856ed75f093c560b8e09006e7262
Parents: dfa23e3
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri Mar 16 18:19:42 2018 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Mar 20 03:29:58 2018 -0400
----------------------------------------------------------------------
.../bindings/cpp/src/proactor_container_impl.cpp | 8 ++++++--
proton-c/src/sasl/cyrus_sasl.c | 18 ++++++++++++++----
2 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/95776152/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index c5f46ed..f865a16 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -310,10 +310,14 @@ bool container::impl::setup_reconnect(pn_connection_t* pnc) {
const reconnect_options::impl& roi = *rc->reconnect_options_->impl_;
+ pn_transport_t* t = pn_connection_transport(pnc);
+ pn_condition_t* condition = pn_transport_condition(t);
+
+ // If we failed to authenticate then don't reconnect any more and just fail
+ if ( !strcmp(pn_condition_get_name(condition), "amqp:unauthorized-access") ) return false;
+
// If too many reconnect attempts just fail
if ( roi.max_attempts != 0 && rc->retries_ >= roi.max_attempts) {
- pn_transport_t* t = pn_connection_transport(pnc);
- pn_condition_t* condition = pn_transport_condition(t);
pn_condition_format(condition, "proton:io", "Too many reconnect attempts (%d)", rc->retries_);
return false;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/95776152/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index ab6eba6..c589fab 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -92,18 +92,28 @@ const pnx_sasl_implementation * const cyrus_sasl_impl = &sasl_impl;
static const char *amqp_service = "amqp";
-static bool pni_check_sasl_result(sasl_conn_t *conn, int r, pn_transport_t *logger)
+static inline bool pni_check_result(sasl_conn_t *conn, int r, pn_transport_t *logger, const char* condition_name)
{
if (r==SASL_OK) return true;
const char* err = conn ? sasl_errdetail(conn) : sasl_errstring(r, NULL, NULL);
pnx_sasl_logf(logger, "sasl error: %s", err);
pn_condition_t* c = pn_transport_condition(logger);
- pn_condition_set_name(c, "proton:io:sasl_error");
+ pn_condition_set_name(c, condition_name);
pn_condition_set_description(c, err);
return false;
}
+static bool pni_check_io_result(sasl_conn_t *conn, int r, pn_transport_t *logger)
+{
+ return pni_check_result(conn, r, logger, "proton:io:sasl_error");
+}
+
+static bool pni_check_sasl_result(sasl_conn_t *conn, int r, pn_transport_t *logger)
+{
+ return pni_check_result(conn, r, logger, "amqp:unauthorized-access");
+}
+
// Cyrus wrappers
static void pni_cyrus_interact(pn_transport_t *transport, sasl_interact_t *interact)
{
@@ -565,7 +575,7 @@ ssize_t cyrus_sasl_encode(pn_transport_t *transport, pn_bytes_t in, pn_bytes_t *
unsigned int outlen;
int r = sasl_encode(cyrus_conn, in.start, in.size, &output, &outlen);
if (outlen==0) return 0;
- if ( pni_check_sasl_result(cyrus_conn, r, transport) ) {
+ if ( pni_check_io_result(cyrus_conn, r, transport) ) {
*out = pn_bytes(outlen, output);
return outlen;
}
@@ -580,7 +590,7 @@ ssize_t cyrus_sasl_decode(pn_transport_t *transport, pn_bytes_t in, pn_bytes_t *
unsigned int outlen;
int r = sasl_decode(cyrus_conn, in.start, in.size, &output, &outlen);
if (outlen==0) return 0;
- if ( pni_check_sasl_result(cyrus_conn, r, transport) ) {
+ if ( pni_check_io_result(cyrus_conn, r, transport) ) {
*out = pn_bytes(outlen, output);
return outlen;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/4] qpid-proton git commit: PROTON-1589: [C++ binding] Add
reconnect option to simple_connect example - This example now sports nearly
every type of connection option: It'll soon be time to stop calling it
"simple"!
Posted by as...@apache.org.
PROTON-1589: [C++ binding] Add reconnect option to simple_connect example
- This example now sports nearly every type of connection option:
It'll soon be time to stop calling it "simple"!
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/dfa23e3e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/dfa23e3e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/dfa23e3e
Branch: refs/heads/master
Commit: dfa23e3e185c74adf71930005481f2edafb4308f
Parents: 9c43d2f
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri Mar 16 18:18:07 2018 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Mar 20 03:29:58 2018 -0400
----------------------------------------------------------------------
examples/cpp/simple_connect.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dfa23e3e/examples/cpp/simple_connect.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_connect.cpp b/examples/cpp/simple_connect.cpp
index b0d51c2..74a8c87 100644
--- a/examples/cpp/simple_connect.cpp
+++ b/examples/cpp/simple_connect.cpp
@@ -25,6 +25,7 @@
#include <proton/connection_options.hpp>
#include <proton/container.hpp>
#include <proton/messaging_handler.hpp>
+#include <proton/reconnect_options.hpp>
#include <iostream>
@@ -35,19 +36,23 @@ class simple_connect : public proton::messaging_handler {
std::string url;
std::string user;
std::string password;
+ bool reconnect;
bool sasl;
std::string mechs;
bool insecure;
proton::connection connection;
public:
- simple_connect(const std::string &a, const std::string &u, const std::string &p, bool s, const std::string& ms, bool in) :
- url(a), user(u), password(p), sasl(s), mechs(ms), insecure(in) {}
+ simple_connect(const std::string &a, const std::string &u, const std::string &p,
+ bool r, bool s, const std::string& ms, bool in) :
+ url(a), user(u), password(p),
+ reconnect(r), sasl(s), mechs(ms), insecure(in) {}
void on_container_start(proton::container &c) OVERRIDE {
proton::connection_options co;
if (!user.empty()) co.user(user);
if (!password.empty()) co.password(password);
+ if (reconnect) co.reconnect(proton::reconnect_options());
if (sasl) co.sasl_enabled(true);
//
// NB: We only set sasl options if they are not default to avoid
@@ -75,14 +80,16 @@ int main(int argc, char **argv) {
std::string address("127.0.0.1:5672/examples");
std::string user;
std::string password;
- std::string mechs;
+ bool reconnect = false;
bool sasl = false;
+ std::string mechs;
bool insecure = false;
example::options opts(argc, argv);
opts.add_value(address, 'a', "address", "connect and send to URL", "URL");
opts.add_value(user, 'u', "user", "authenticate as USER", "USER");
opts.add_value(password, 'p', "password", "authenticate with PASSWORD", "PASSWORD");
+ opts.add_flag(reconnect, 'r', "reconnect", "reconnect on connection failure");
opts.add_flag(sasl,'s', "sasl", "force SASL authentication with no user specified (Use for Kerberos/GSSAPI)");
opts.add_value(mechs, 'm', "mechs", "allowed SASL mechanisms", "MECHS");
opts.add_flag(insecure, 'i', "insecure", "allow clear-text passwords");
@@ -90,7 +97,7 @@ int main(int argc, char **argv) {
try {
opts.parse();
- simple_connect connect(address, user, password, sasl, mechs, insecure);
+ simple_connect connect(address, user, password, reconnect, sasl, mechs, insecure);
proton::container(connect).run();
return 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/4] qpid-proton git commit: PROTON-1589: [C++ binding] Test no
reconnect on authentication failure
Posted by as...@apache.org.
PROTON-1589: [C++ binding] Test no reconnect on authentication failure
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9c43d2f3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9c43d2f3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9c43d2f3
Branch: refs/heads/master
Commit: 9c43d2f36bf999e59a369e903e704bcb7c952203
Parents: 0737e42
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Mar 20 03:27:42 2018 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Mar 20 03:29:48 2018 -0400
----------------------------------------------------------------------
proton-c/bindings/cpp/src/reconnect_test.cpp | 50 +++++++++++++++++++++++
1 file changed, 50 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c43d2f3/proton-c/bindings/cpp/src/reconnect_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_test.cpp b/proton-c/bindings/cpp/src/reconnect_test.cpp
index 23acc73..f29cd53 100644
--- a/proton-c/bindings/cpp/src/reconnect_test.cpp
+++ b/proton-c/bindings/cpp/src/reconnect_test.cpp
@@ -115,6 +115,12 @@ class server_connection_handler : public proton::messaging_handler {
void on_connection_close(proton::connection & c) PN_CPP_OVERRIDE {
done_ = true;
}
+
+ void on_transport_error(proton::transport & ) PN_CPP_OVERRIDE {
+ // If we get an error then (try to) stop the listener
+ // - this will stop the listener if we didn't already accept a connection
+ listener_.stop();
+ }
};
class tester : public proton::messaging_handler, public waiter {
@@ -201,10 +207,54 @@ int test_stop_reconnect() {
return 0;
}
+class authfail_reconnect_tester : public proton::messaging_handler, public waiter {
+ public:
+ authfail_reconnect_tester() :
+ waiter(1), container_(*this, "authfail_reconnect_tester"), errored_(false)
+ {}
+
+ void deferred_stop() {
+ container_.stop();
+ }
+
+ void on_container_start(proton::container& c) PN_CPP_OVERRIDE {
+ // This server won't fail in this test
+ s1.reset(new server_connection_handler(c, 100, *this));
+ c.schedule(proton::duration::SECOND, proton::make_work(&authfail_reconnect_tester::deferred_stop, this));
+ }
+
+ void on_transport_error(proton::transport& t) PN_CPP_OVERRIDE {
+ errored_ = true;
+ }
+
+ void ready() PN_CPP_OVERRIDE {
+ proton::connection_options co;
+ co.sasl_allowed_mechs("PLAIN");
+ co.reconnect(proton::reconnect_options());
+ container_.connect(s1->url(), co);
+ }
+
+ void run() {
+ container_.run();
+ ASSERT(errored_);
+ }
+
+ private:
+ proton::container container_;
+ proton::internal::pn_unique_ptr<server_connection_handler> s1;
+ bool errored_;
+};
+
+int test_auth_fail_reconnect() {
+ authfail_reconnect_tester().run();
+ return 0;
+}
+
int main(int argc, char** argv) {
int failed = 0;
RUN_ARGV_TEST(failed, test_failover_simple());
RUN_ARGV_TEST(failed, test_stop_reconnect());
+ RUN_ARGV_TEST(failed, test_auth_fail_reconnect());
return failed;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org