static void test_handshaker_invalid_state(void) {
  tsi_handshaker *h = tsi_create_fake_handshaker(0);
  tsi_peer peer;
  tsi_frame_protector *p;
  GPR_ASSERT(tsi_handshaker_extract_peer(h, &peer) == TSI_FAILED_PRECONDITION);
  GPR_ASSERT(tsi_handshaker_create_frame_protector(h, NULL, &p) ==
             TSI_FAILED_PRECONDITION);
  tsi_handshaker_destroy(h);
}
Exemplo n.º 2
0
static void unref_handshake(grpc_security_handshake *h) {
    if (gpr_unref(&h->refs)) {
        if (h->handshaker != NULL) tsi_handshaker_destroy(h->handshaker);
        if (h->handshake_buffer != NULL) gpr_free(h->handshake_buffer);
        gpr_slice_buffer_destroy(&h->left_overs);
        gpr_slice_buffer_destroy(&h->outgoing);
        gpr_slice_buffer_destroy(&h->incoming);
        GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake");
        GRPC_SECURITY_CONNECTOR_UNREF(h->connector, "handshake");
        gpr_free(h);
    }
}
Exemplo n.º 3
0
static void secure_transport_setup_done(grpc_secure_transport_setup *s,
                                        int is_success) {
  if (is_success) {
    s->cb(s->user_data, GRPC_SECURITY_OK, s->endpoint);
  } else {
    if (s->endpoint != NULL) {
      grpc_endpoint_shutdown(s->endpoint);
      grpc_endpoint_destroy(s->endpoint);
    }
    s->cb(s->user_data, GRPC_SECURITY_ERROR, NULL);
  }
  if (s->handshaker != NULL) tsi_handshaker_destroy(s->handshaker);
  if (s->handshake_buffer != NULL) gpr_free(s->handshake_buffer);
  gpr_slice_buffer_destroy(&s->left_overs);
  grpc_security_connector_unref(s->connector);
  gpr_free(s);
}
Exemplo n.º 4
0
static void security_handshaker_unref(grpc_exec_ctx *exec_ctx,
                                      security_handshaker *h) {
  if (gpr_unref(&h->refs)) {
    gpr_mu_destroy(&h->mu);
    tsi_handshaker_destroy(h->handshaker);
    tsi_handshaker_result_destroy(h->handshaker_result);
    if (h->endpoint_to_destroy != NULL) {
      grpc_endpoint_destroy(exec_ctx, h->endpoint_to_destroy);
    }
    if (h->read_buffer_to_destroy != NULL) {
      grpc_slice_buffer_destroy_internal(exec_ctx, h->read_buffer_to_destroy);
      gpr_free(h->read_buffer_to_destroy);
    }
    gpr_free(h->handshake_buffer);
    grpc_slice_buffer_destroy_internal(exec_ctx, &h->outgoing);
    GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake");
    GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, h->connector, "handshake");
    gpr_free(h);
  }
}