Skip to content
Snippets Groups Projects
Commit 95fcb58f authored by Mark D. Roth's avatar Mark D. Roth
Browse files

Remove redundant fields for endpoints.

parent 3beb6c52
No related branches found
No related tags found
No related merge requests found
...@@ -60,9 +60,6 @@ typedef struct { ...@@ -60,9 +60,6 @@ typedef struct {
gpr_refcount refs; gpr_refcount refs;
unsigned char *handshake_buffer; unsigned char *handshake_buffer;
size_t handshake_buffer_size; size_t handshake_buffer_size;
// FIXME: use args->endpoint instead
grpc_endpoint *wrapped_endpoint;
grpc_endpoint *secure_endpoint;
grpc_slice_buffer left_overs; grpc_slice_buffer left_overs;
grpc_slice_buffer outgoing; grpc_slice_buffer outgoing;
grpc_closure on_handshake_data_sent_to_peer; grpc_closure on_handshake_data_sent_to_peer;
...@@ -95,7 +92,6 @@ static void security_handshake_done_locked(grpc_exec_ctx *exec_ctx, ...@@ -95,7 +92,6 @@ static void security_handshake_done_locked(grpc_exec_ctx *exec_ctx,
security_handshaker *h, security_handshaker *h,
grpc_error *error) { grpc_error *error) {
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
h->args->endpoint = h->secure_endpoint;
grpc_arg auth_context_arg = grpc_auth_context_to_arg(h->auth_context); grpc_arg auth_context_arg = grpc_auth_context_to_arg(h->auth_context);
grpc_channel_args* tmp_args = h->args->args; grpc_channel_args* tmp_args = h->args->args;
h->args->args = h->args->args =
...@@ -105,16 +101,12 @@ static void security_handshake_done_locked(grpc_exec_ctx *exec_ctx, ...@@ -105,16 +101,12 @@ static void security_handshake_done_locked(grpc_exec_ctx *exec_ctx,
const char *msg = grpc_error_string(error); const char *msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "Security handshake failed: %s", msg); gpr_log(GPR_DEBUG, "Security handshake failed: %s", msg);
grpc_error_free_string(msg); grpc_error_free_string(msg);
if (h->secure_endpoint != NULL) { grpc_endpoint_shutdown(exec_ctx, h->args->endpoint);
grpc_endpoint_shutdown(exec_ctx, h->secure_endpoint);
// FIXME: clarify who should destroy... // FIXME: clarify who should destroy...
// grpc_endpoint_destroy(exec_ctx, h->secure_endpoint); //grpc_endpoint_destroy(exec_ctx, h->args->endpoint);
// } else {
// grpc_endpoint_destroy(exec_ctx, h->wrapped_endpoint);
}
} }
// Clear out the read buffer before it gets passed to the transport, // Clear out the read buffer before it gets passed to the transport,
// since any excess bytes were already moved to h->left_overs. // since any excess bytes were already copied to h->left_overs.
grpc_slice_buffer_reset_and_unref(h->args->read_buffer); grpc_slice_buffer_reset_and_unref(h->args->read_buffer);
h->args = NULL; h->args = NULL;
grpc_exec_ctx_sched(exec_ctx, h->on_handshake_done, error, NULL); grpc_exec_ctx_sched(exec_ctx, h->on_handshake_done, error, NULL);
...@@ -138,8 +130,8 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg, ...@@ -138,8 +130,8 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_ERROR_CREATE("Frame protector creation failed"), result); GRPC_ERROR_CREATE("Frame protector creation failed"), result);
goto done; goto done;
} }
h->secure_endpoint = h->args->endpoint =
grpc_secure_endpoint_create(protector, h->wrapped_endpoint, grpc_secure_endpoint_create(protector, h->args->endpoint,
h->left_overs.slices, h->left_overs.count); h->left_overs.slices, h->left_overs.count);
h->left_overs.count = 0; h->left_overs.count = 0;
h->left_overs.length = 0; h->left_overs.length = 0;
...@@ -187,7 +179,7 @@ static grpc_error* send_handshake_bytes_to_peer_locked(grpc_exec_ctx *exec_ctx, ...@@ -187,7 +179,7 @@ static grpc_error* send_handshake_bytes_to_peer_locked(grpc_exec_ctx *exec_ctx,
grpc_slice_from_copied_buffer((const char *)h->handshake_buffer, offset); grpc_slice_from_copied_buffer((const char *)h->handshake_buffer, offset);
grpc_slice_buffer_reset_and_unref(&h->outgoing); grpc_slice_buffer_reset_and_unref(&h->outgoing);
grpc_slice_buffer_add(&h->outgoing, to_send); grpc_slice_buffer_add(&h->outgoing, to_send);
grpc_endpoint_write(exec_ctx, h->wrapped_endpoint, &h->outgoing, grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing,
&h->on_handshake_data_sent_to_peer); &h->on_handshake_data_sent_to_peer);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
...@@ -219,7 +211,7 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx, ...@@ -219,7 +211,7 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
if (tsi_handshaker_is_in_progress(h->handshaker)) { if (tsi_handshaker_is_in_progress(h->handshaker)) {
/* We may need more data. */ /* We may need more data. */
if (result == TSI_INCOMPLETE_DATA) { if (result == TSI_INCOMPLETE_DATA) {
grpc_endpoint_read(exec_ctx, h->wrapped_endpoint, h->args->read_buffer, grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer); &h->on_handshake_data_received_from_peer);
goto done; goto done;
} else { } else {
...@@ -294,7 +286,7 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, ...@@ -294,7 +286,7 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx,
/* We may be done. */ /* We may be done. */
gpr_mu_lock(&h->mu); gpr_mu_lock(&h->mu);
if (tsi_handshaker_is_in_progress(h->handshaker)) { if (tsi_handshaker_is_in_progress(h->handshaker)) {
grpc_endpoint_read(exec_ctx, h->wrapped_endpoint, h->args->read_buffer, grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer); &h->on_handshake_data_received_from_peer);
} else { } else {
error = check_peer_locked(exec_ctx, h); error = check_peer_locked(exec_ctx, h);
...@@ -323,7 +315,7 @@ static void security_handshaker_shutdown(grpc_exec_ctx* exec_ctx, ...@@ -323,7 +315,7 @@ static void security_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
security_handshaker *h = (security_handshaker*)handshaker; security_handshaker *h = (security_handshaker*)handshaker;
gpr_mu_lock(&h->mu); gpr_mu_lock(&h->mu);
if (h->args != NULL) { if (h->args != NULL) {
grpc_endpoint_shutdown(exec_ctx, h->wrapped_endpoint); grpc_endpoint_shutdown(exec_ctx, h->args->endpoint);
} }
gpr_mu_unlock(&h->mu); gpr_mu_unlock(&h->mu);
} }
...@@ -336,7 +328,6 @@ static void security_handshaker_do_handshake( ...@@ -336,7 +328,6 @@ static void security_handshaker_do_handshake(
gpr_mu_lock(&h->mu); gpr_mu_lock(&h->mu);
h->args = args; h->args = args;
h->on_handshake_done = on_handshake_done; h->on_handshake_done = on_handshake_done;
h->wrapped_endpoint = args->endpoint; // FIXME: remove?
gpr_ref(&h->refs); gpr_ref(&h->refs);
grpc_error* error = send_handshake_bytes_to_peer_locked(exec_ctx, h); grpc_error* error = send_handshake_bytes_to_peer_locked(exec_ctx, h);
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment