|
|
@ -73,15 +73,13 @@ typedef struct grpcsharp_batch_context { |
|
|
|
grpc_byte_buffer *send_message; |
|
|
|
grpc_byte_buffer *send_message; |
|
|
|
struct { |
|
|
|
struct { |
|
|
|
grpc_metadata_array trailing_metadata; |
|
|
|
grpc_metadata_array trailing_metadata; |
|
|
|
char *status_details; |
|
|
|
|
|
|
|
} send_status_from_server; |
|
|
|
} send_status_from_server; |
|
|
|
grpc_metadata_array recv_initial_metadata; |
|
|
|
grpc_metadata_array recv_initial_metadata; |
|
|
|
grpc_byte_buffer *recv_message; |
|
|
|
grpc_byte_buffer *recv_message; |
|
|
|
struct { |
|
|
|
struct { |
|
|
|
grpc_metadata_array trailing_metadata; |
|
|
|
grpc_metadata_array trailing_metadata; |
|
|
|
grpc_status_code status; |
|
|
|
grpc_status_code status; |
|
|
|
char *status_details; |
|
|
|
grpc_slice status_details; |
|
|
|
size_t status_details_capacity; |
|
|
|
|
|
|
|
} recv_status_on_client; |
|
|
|
} recv_status_on_client; |
|
|
|
int recv_close_on_server_cancelled; |
|
|
|
int recv_close_on_server_cancelled; |
|
|
|
} grpcsharp_batch_context; |
|
|
|
} grpcsharp_batch_context; |
|
|
@ -178,21 +176,17 @@ grpcsharp_metadata_array_count(grpc_metadata_array *array) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
grpcsharp_metadata_array_get_key(grpc_metadata_array *array, size_t index) { |
|
|
|
grpcsharp_metadata_array_get_key(grpc_metadata_array *array, size_t index, size_t *key_length) { |
|
|
|
GPR_ASSERT(index < array->count); |
|
|
|
GPR_ASSERT(index < array->count); |
|
|
|
return array->metadata[index].key; |
|
|
|
*key_length = GRPC_SLICE_LENGTH(array->metadata[index].key); |
|
|
|
|
|
|
|
return (char *)GRPC_SLICE_START_PTR(array->metadata[index].key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
grpcsharp_metadata_array_get_value(grpc_metadata_array *array, size_t index) { |
|
|
|
grpcsharp_metadata_array_get_value(grpc_metadata_array *array, size_t index, size_t *value_length) { |
|
|
|
GPR_ASSERT(index < array->count); |
|
|
|
GPR_ASSERT(index < array->count); |
|
|
|
return array->metadata[index].value; |
|
|
|
*value_length = GRPC_SLICE_LENGTH(array->metadata[index].value); |
|
|
|
} |
|
|
|
return (char *)GRPC_SLICE_START_PTR(array->metadata[index].value); |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_metadata_array_get_value_length( |
|
|
|
|
|
|
|
grpc_metadata_array *array, size_t index) { |
|
|
|
|
|
|
|
GPR_ASSERT(index < array->count); |
|
|
|
|
|
|
|
return (intptr_t)array->metadata[index].value_length; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Move contents of metadata array */ |
|
|
|
/* Move contents of metadata array */ |
|
|
@ -225,7 +219,6 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_destroy(grpcsharp_batch_con |
|
|
|
|
|
|
|
|
|
|
|
grpcsharp_metadata_array_destroy_metadata_including_entries( |
|
|
|
grpcsharp_metadata_array_destroy_metadata_including_entries( |
|
|
|
&(ctx->send_status_from_server.trailing_metadata)); |
|
|
|
&(ctx->send_status_from_server.trailing_metadata)); |
|
|
|
gpr_free(ctx->send_status_from_server.status_details); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grpcsharp_metadata_array_destroy_metadata_only(&(ctx->recv_initial_metadata)); |
|
|
|
grpcsharp_metadata_array_destroy_metadata_only(&(ctx->recv_initial_metadata)); |
|
|
|
|
|
|
|
|
|
|
@ -233,7 +226,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_destroy(grpcsharp_batch_con |
|
|
|
|
|
|
|
|
|
|
|
grpcsharp_metadata_array_destroy_metadata_only( |
|
|
|
grpcsharp_metadata_array_destroy_metadata_only( |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata)); |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata)); |
|
|
|
gpr_free((void *)ctx->recv_status_on_client.status_details); |
|
|
|
grpc_slice_unref(ctx->recv_status_on_client.status_details); |
|
|
|
|
|
|
|
|
|
|
|
gpr_free(ctx); |
|
|
|
gpr_free(ctx); |
|
|
|
} |
|
|
|
} |
|
|
@ -305,8 +298,9 @@ grpcsharp_batch_context_recv_status_on_client_status( |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
grpcsharp_batch_context_recv_status_on_client_details( |
|
|
|
grpcsharp_batch_context_recv_status_on_client_details( |
|
|
|
const grpcsharp_batch_context *ctx) { |
|
|
|
const grpcsharp_batch_context *ctx, size_t *details_length) { |
|
|
|
return ctx->recv_status_on_client.status_details; |
|
|
|
*details_length = GRPC_SLICE_LENGTH(ctx->recv_status_on_client.status_details); |
|
|
|
|
|
|
|
return (char *)GRPC_SLICE_START_PTR(ctx->recv_status_on_client.status_details); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT const grpc_metadata_array *GPR_CALLTYPE |
|
|
|
GPR_EXPORT const grpc_metadata_array *GPR_CALLTYPE |
|
|
@ -322,13 +316,15 @@ GPR_EXPORT grpc_call *GPR_CALLTYPE grpcsharp_request_call_context_call( |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE |
|
|
|
grpcsharp_request_call_context_method( |
|
|
|
grpcsharp_request_call_context_method( |
|
|
|
const grpcsharp_request_call_context *ctx) { |
|
|
|
const grpcsharp_request_call_context *ctx, size_t *method_length) { |
|
|
|
return ctx->call_details.method; |
|
|
|
*method_length = GRPC_SLICE_LENGTH(ctx->call_details.method); |
|
|
|
|
|
|
|
return (char *)GRPC_SLICE_START_PTR(ctx->call_details.method); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_request_call_context_host( |
|
|
|
GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_request_call_context_host( |
|
|
|
const grpcsharp_request_call_context *ctx) { |
|
|
|
const grpcsharp_request_call_context *ctx, size_t *host_length) { |
|
|
|
return ctx->call_details.host; |
|
|
|
*host_length = GRPC_SLICE_LENGTH(ctx->call_details.host); |
|
|
|
|
|
|
|
return (char *)GRPC_SLICE_START_PTR(ctx->call_details.host); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT gpr_timespec GPR_CALLTYPE |
|
|
|
GPR_EXPORT gpr_timespec GPR_CALLTYPE |
|
|
@ -403,9 +399,14 @@ grpcsharp_channel_create_call(grpc_channel *channel, grpc_call *parent_call, |
|
|
|
const char *method, const char *host, |
|
|
|
const char *method, const char *host, |
|
|
|
gpr_timespec deadline) { |
|
|
|
gpr_timespec deadline) { |
|
|
|
grpc_slice method_slice = grpc_slice_from_copied_string(method); |
|
|
|
grpc_slice method_slice = grpc_slice_from_copied_string(method); |
|
|
|
grpc_slice host_slice = host == NULL ? grpc_empty_string() : grpc_slice_from_copied_string(host); |
|
|
|
grpc_slice *host_slice_ptr = NULL; |
|
|
|
grpc_call *grpc_channel_create_call(channel, parent_call, propagation_mask, cq, |
|
|
|
grpc_slice host_slice; |
|
|
|
method_slice, host_slice, deadline, NULL); |
|
|
|
if (host != NULL) { |
|
|
|
|
|
|
|
host_slice = grpc_slice_from_copied_string(host); |
|
|
|
|
|
|
|
host_slice_ptr = &host_slice; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return grpc_channel_create_call(channel, parent_call, propagation_mask, cq, |
|
|
|
|
|
|
|
method_slice, host_slice_ptr, deadline, NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_EXPORT grpc_connectivity_state GPR_CALLTYPE |
|
|
|
GPR_EXPORT grpc_connectivity_state GPR_CALLTYPE |
|
|
@ -560,11 +561,8 @@ grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx, |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
ops[5].data.recv_status_on_client.status = |
|
|
|
ops[5].data.recv_status_on_client.status = |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
/* not using preallocation for status_details */ |
|
|
|
|
|
|
|
ops[5].data.recv_status_on_client.status_details = |
|
|
|
ops[5].data.recv_status_on_client.status_details = |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
ops[5].data.recv_status_on_client.status_details_capacity = |
|
|
|
|
|
|
|
&(ctx->recv_status_on_client.status_details_capacity); |
|
|
|
|
|
|
|
ops[5].flags = 0; |
|
|
|
ops[5].flags = 0; |
|
|
|
ops[5].reserved = NULL; |
|
|
|
ops[5].reserved = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -604,11 +602,8 @@ grpcsharp_call_start_client_streaming(grpc_call *call, |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
ops[3].data.recv_status_on_client.status = |
|
|
|
ops[3].data.recv_status_on_client.status = |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
/* not using preallocation for status_details */ |
|
|
|
|
|
|
|
ops[3].data.recv_status_on_client.status_details = |
|
|
|
ops[3].data.recv_status_on_client.status_details = |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
ops[3].data.recv_status_on_client.status_details_capacity = |
|
|
|
|
|
|
|
&(ctx->recv_status_on_client.status_details_capacity); |
|
|
|
|
|
|
|
ops[3].flags = 0; |
|
|
|
ops[3].flags = 0; |
|
|
|
ops[3].reserved = NULL; |
|
|
|
ops[3].reserved = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -647,11 +642,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
ops[3].data.recv_status_on_client.status = |
|
|
|
ops[3].data.recv_status_on_client.status = |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
/* not using preallocation for status_details */ |
|
|
|
|
|
|
|
ops[3].data.recv_status_on_client.status_details = |
|
|
|
ops[3].data.recv_status_on_client.status_details = |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
ops[3].data.recv_status_on_client.status_details_capacity = |
|
|
|
|
|
|
|
&(ctx->recv_status_on_client.status_details_capacity); |
|
|
|
|
|
|
|
ops[3].flags = 0; |
|
|
|
ops[3].flags = 0; |
|
|
|
ops[3].reserved = NULL; |
|
|
|
ops[3].reserved = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -681,11 +673,8 @@ grpcsharp_call_start_duplex_streaming(grpc_call *call, |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
&(ctx->recv_status_on_client.trailing_metadata); |
|
|
|
ops[1].data.recv_status_on_client.status = |
|
|
|
ops[1].data.recv_status_on_client.status = |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
&(ctx->recv_status_on_client.status); |
|
|
|
/* not using preallocation for status_details */ |
|
|
|
|
|
|
|
ops[1].data.recv_status_on_client.status_details = |
|
|
|
ops[1].data.recv_status_on_client.status_details = |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
&(ctx->recv_status_on_client.status_details); |
|
|
|
ops[1].data.recv_status_on_client.status_details_capacity = |
|
|
|
|
|
|
|
&(ctx->recv_status_on_client.status_details_capacity); |
|
|
|
|
|
|
|
ops[1].flags = 0; |
|
|
|
ops[1].flags = 0; |
|
|
|
ops[1].reserved = NULL; |
|
|
|
ops[1].reserved = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -749,10 +738,10 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( |
|
|
|
grpc_op ops[3]; |
|
|
|
grpc_op ops[3]; |
|
|
|
memset(ops, 0, sizeof(ops)); |
|
|
|
memset(ops, 0, sizeof(ops)); |
|
|
|
size_t nops = 1; |
|
|
|
size_t nops = 1; |
|
|
|
|
|
|
|
grpc_slice status_details_slice = grpc_slice_from_copied_string(status_details); |
|
|
|
ops[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER; |
|
|
|
ops[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER; |
|
|
|
ops[0].data.send_status_from_server.status = status_code; |
|
|
|
ops[0].data.send_status_from_server.status = status_code; |
|
|
|
ops[0].data.send_status_from_server.status_details = |
|
|
|
ops[0].data.send_status_from_server.status_details = &status_details_slice; |
|
|
|
gpr_strdup(status_details); |
|
|
|
|
|
|
|
grpcsharp_metadata_array_move( |
|
|
|
grpcsharp_metadata_array_move( |
|
|
|
&(ctx->send_status_from_server.trailing_metadata), trailing_metadata); |
|
|
|
&(ctx->send_status_from_server.trailing_metadata), trailing_metadata); |
|
|
|
ops[0].data.send_status_from_server.trailing_metadata_count = |
|
|
|
ops[0].data.send_status_from_server.trailing_metadata_count = |
|
|
|