aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-07-22 09:02:15 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-07-22 09:02:15 -0700
commita228e5f23104ef370e1434a848b61a3574e07e55 (patch)
treeeef7d494267561862fdaa8a53436c75a809fffae /src/core/lib
parentb16b1f29c3aa7238814cd70a4abcee0f35dc6b9f (diff)
Add grpc_error parameter to handshaker callback.
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/channel/handshaker.c16
-rw-r--r--src/core/lib/channel/handshaker.h9
2 files changed, 16 insertions, 9 deletions
diff --git a/src/core/lib/channel/handshaker.c b/src/core/lib/channel/handshaker.c
index b3ee0ed6f9..f9ecaf8856 100644
--- a/src/core/lib/channel/handshaker.c
+++ b/src/core/lib/channel/handshaker.c
@@ -130,8 +130,6 @@ void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
grpc_handshake_manager* mgr) {
- // FIXME: maybe check which handshaker is currently in progress, and
- // only shut down that one?
for (size_t i = 0; i < mgr->count; ++i) {
grpc_handshaker_shutdown(exec_ctx, mgr->handshakers[i]);
}
@@ -145,10 +143,18 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
// handshakers together.
static void call_next_handshaker(grpc_exec_ctx* exec_ctx,
grpc_endpoint* endpoint,
- grpc_channel_args* args, void* user_data) {
+ grpc_channel_args* args, void* user_data,
+ grpc_error* error) {
grpc_handshake_manager* mgr = user_data;
GPR_ASSERT(mgr->state != NULL);
GPR_ASSERT(mgr->state->index < mgr->count);
+ // If we got an error, skip all remaining handshakers and invoke the
+ // caller-supplied callback immediately.
+ if (error != GRPC_ERROR_NONE) {
+ mgr->state->final_cb(exec_ctx, endpoint, args, mgr->state->final_user_data,
+ error);
+ return;
+ }
grpc_handshaker_done_cb cb = call_next_handshaker;
// If this is the last handshaker, use the caller-supplied callback
// and user_data instead of chaining back to this function again.
@@ -177,7 +183,7 @@ void grpc_handshake_manager_do_handshake(
if (mgr->count == 0) {
// No handshakers registered, so we just immediately call the done
// callback with the passed-in endpoint.
- cb(exec_ctx, endpoint, args_copy, user_data);
+ cb(exec_ctx, endpoint, args_copy, user_data, GRPC_ERROR_NONE);
} else {
GPR_ASSERT(mgr->state == NULL);
mgr->state = gpr_malloc(sizeof(struct grpc_handshaker_state));
@@ -186,6 +192,6 @@ void grpc_handshake_manager_do_handshake(
mgr->state->acceptor = acceptor;
mgr->state->final_cb = cb;
mgr->state->final_user_data = user_data;
- call_next_handshaker(exec_ctx, endpoint, args_copy, mgr);
+ call_next_handshaker(exec_ctx, endpoint, args_copy, mgr, GRPC_ERROR_NONE);
}
}
diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h
index b1e91dba4f..0a71b1c33c 100644
--- a/src/core/lib/channel/handshaker.h
+++ b/src/core/lib/channel/handshaker.h
@@ -60,7 +60,8 @@ typedef struct grpc_handshaker grpc_handshaker;
typedef void (*grpc_handshaker_done_cb)(grpc_exec_ctx* exec_ctx,
grpc_endpoint* endpoint,
grpc_channel_args* args,
- void* user_data);
+ void* user_data,
+ grpc_error* error);
struct grpc_handshaker_vtable {
/// Destroys the handshaker.
@@ -115,7 +116,7 @@ typedef struct grpc_handshake_manager grpc_handshake_manager;
grpc_handshake_manager* grpc_handshake_manager_create();
/// Adds a handshaker to the handshake manager.
-/// Takes ownership of \a mgr.
+/// Takes ownership of \a handshaker.
void grpc_handshake_manager_add(grpc_handshaker* handshaker,
grpc_handshake_manager* mgr);
@@ -134,8 +135,8 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
/// Does NOT take ownership of \a args. Instead, makes a copy before
/// invoking the first handshaker.
/// \a acceptor will be NULL for client-side handshakers.
-/// If successful, invokes \a cb with \a user_data after all handshakers
-/// have completed.
+/// Invokes \a cb with \a user_data after either a handshaker fails or
+/// all handshakers have completed successfully.
void grpc_handshake_manager_do_handshake(
grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
grpc_endpoint* endpoint, const grpc_channel_args* args,