Beispiel #1
0
static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint,
                              grpc_channel_args *args,
                              gpr_slice_buffer *read_buffer, void *user_data,
                              grpc_error *error) {
  server_secure_connect *state = user_data;
  if (error != GRPC_ERROR_NONE) {
    const char *error_str = grpc_error_string(error);
    gpr_log(GPR_ERROR, "Handshaking failed: %s", error_str);
    grpc_error_free_string(error_str);
    GRPC_ERROR_UNREF(error);
    grpc_channel_args_destroy(args);
    gpr_free(read_buffer);
    grpc_handshake_manager_shutdown(exec_ctx, state->handshake_mgr);
    grpc_handshake_manager_destroy(exec_ctx, state->handshake_mgr);
    state_unref(state->state);
    gpr_free(state);
    return;
  }
  grpc_handshake_manager_destroy(exec_ctx, state->handshake_mgr);
  state->handshake_mgr = NULL;
  // TODO(roth, jboeuf): Convert security connector handshaking to use new
  // handshake API, and then move the code from on_secure_handshake_done()
  // into this function.
  state->args = args;
  grpc_server_security_connector_do_handshake(
      exec_ctx, state->state->sc, state->acceptor, endpoint, read_buffer,
      state->deadline, on_secure_handshake_done, state);
}
Beispiel #2
0
static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
                                      grpc_connector *con) {
  chttp2_connector *c = (chttp2_connector *)con;
  gpr_mu_lock(&c->mu);
  c->shutdown = true;
  if (c->handshake_mgr != NULL) {
    grpc_handshake_manager_shutdown(exec_ctx, c->handshake_mgr);
  }
  // If handshaking is not yet in progress, shutdown the endpoint.
  // Otherwise, the handshaker will do this for us.
  if (!c->connecting && c->endpoint != NULL) {
    grpc_endpoint_shutdown(exec_ctx, c->endpoint);
  }
  gpr_mu_unlock(&c->mu);
}