You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2019/02/20 18:02:59 UTC
[qpid-dispatch] branch master updated: DISPATCH-1269: improvements
to remote sasl plugin
This is an automated email from the ASF dual-hosted git repository.
gsim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new 8e4bd11 DISPATCH-1269: improvements to remote sasl plugin
8e4bd11 is described below
commit 8e4bd11915963354e106e654a48891c468dbbf27
Author: Gordon Sim <gs...@redhat.com>
AuthorDate: Wed Feb 20 16:23:36 2019 +0000
DISPATCH-1269: improvements to remote sasl plugin
* explicitly handle partial close of downstream socket
* close downstream connection if upstream is closed
---
src/remote_sasl.c | 75 +++++++++++++++++++++++++++++++------------------------
1 file changed, 43 insertions(+), 32 deletions(-)
diff --git a/src/remote_sasl.c b/src/remote_sasl.c
index a291b64..6d79191 100644
--- a/src/remote_sasl.c
+++ b/src/remote_sasl.c
@@ -46,6 +46,7 @@ const int8_t DOWNSTREAM_MECHANISMS_RECEIVED = 3;
const int8_t DOWNSTREAM_CHALLENGE_RECEIVED = 4;
const int8_t DOWNSTREAM_OUTCOME_RECEIVED = 5;
const int8_t DOWNSTREAM_CLOSED = 6;
+const int8_t UPSTREAM_CLOSED = 7;
typedef struct {
size_t used;
@@ -232,6 +233,39 @@ static bool remote_sasl_init_client(pn_transport_t* transport)
}
}
+
+static void connection_wake(pn_connection_t* conn)
+{
+ qd_connection_t *ctx = pn_connection_get_context(conn);
+ if (ctx) {
+ ctx->wake(ctx);
+ } else {
+ pn_connection_wake(conn);
+ }
+}
+
+static bool notify_upstream(qdr_sasl_relay_t* impl, uint8_t state)
+{
+ if (!impl->upstream_released) {
+ impl->upstream_state = state;
+ connection_wake(impl->upstream);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+static bool notify_downstream(qdr_sasl_relay_t* impl, uint8_t state)
+{
+ if (!impl->downstream_released && impl->downstream) {
+ impl->downstream_state = state;
+ connection_wake(impl->downstream);
+ return true;
+ } else {
+ return false;
+ }
+}
+
static void remote_sasl_free(pn_transport_t *transport)
{
qdr_sasl_relay_t* impl = (qdr_sasl_relay_t*) pnx_sasl_get_context(transport);
@@ -245,6 +279,8 @@ static void remote_sasl_free(pn_transport_t *transport)
impl->upstream_released = true;
if (impl->downstream_released || impl->downstream == 0) {
delete_qdr_sasl_relay_t(impl);
+ } else {
+ notify_downstream(impl, UPSTREAM_CLOSED);
}
}
}
@@ -281,6 +317,9 @@ static void remote_sasl_prepare(pn_transport_t *transport)
} else if (impl->downstream_state == UPSTREAM_RESPONSE_RECEIVED) {
pnx_sasl_set_bytes_out(transport, pn_bytes(impl->response.size, impl->response.start));
pnx_sasl_set_desired_state(transport, SASL_POSTED_RESPONSE);
+ } else if (impl->downstream_state == UPSTREAM_CLOSED) {
+ impl->downstream_state = 0;
+ pn_transport_close_head(transport);
}
impl->downstream_state = 0;
} else {
@@ -308,38 +347,6 @@ static void remote_sasl_prepare(pn_transport_t *transport)
}
}
-static void connection_wake(pn_connection_t* conn)
-{
- qd_connection_t *ctx = pn_connection_get_context(conn);
- if (ctx) {
- ctx->wake(ctx);
- } else {
- pn_connection_wake(conn);
- }
-}
-
-static bool notify_upstream(qdr_sasl_relay_t* impl, uint8_t state)
-{
- if (!impl->upstream_released) {
- impl->upstream_state = state;
- connection_wake(impl->upstream);
- return true;
- } else {
- return false;
- }
-}
-
-static bool notify_downstream(qdr_sasl_relay_t* impl, uint8_t state)
-{
- if (!impl->downstream_released && impl->downstream) {
- impl->downstream_state = state;
- connection_wake(impl->downstream);
- return true;
- } else {
- return false;
- }
-}
-
// Client / Downstream
static bool remote_sasl_process_mechanisms(pn_transport_t *transport, const char *mechs)
{
@@ -668,6 +675,10 @@ void qdr_handle_authentication_service_connection_event(pn_event_t *e)
qd_log(auth_service_log, QD_LOG_DEBUG, "authentication service closed connection");
pn_connection_close(conn);
pn_transport_close_head(transport);
+ } else if (pn_event_type(e) == PN_TRANSPORT_HEAD_CLOSED) {
+ pn_transport_close_tail(transport);
+ } else if (pn_event_type(e) == PN_TRANSPORT_TAIL_CLOSED) {
+ pn_transport_close_head(transport);
} else if (pn_event_type(e) == PN_TRANSPORT_CLOSED) {
qd_log(auth_service_log, QD_LOG_DEBUG, "disconnected from authentication service");
qdr_sasl_relay_t* impl = (qdr_sasl_relay_t*) pnx_sasl_get_context(transport);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org