diff options
Diffstat (limited to 'src/core/lib/channel')
-rw-r--r-- | src/core/lib/channel/channel_stack.c | 39 | ||||
-rw-r--r-- | src/core/lib/channel/channel_stack.h | 15 | ||||
-rw-r--r-- | src/core/lib/channel/deadline_filter.c | 9 | ||||
-rw-r--r-- | src/core/lib/channel/message_size_filter.c | 7 |
4 files changed, 12 insertions, 58 deletions
diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.c index fe2e50e71a..22bdb2952a 100644 --- a/src/core/lib/channel/channel_stack.c +++ b/src/core/lib/channel/channel_stack.c @@ -287,42 +287,3 @@ grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) { return (grpc_call_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE( sizeof(grpc_call_stack))); } - -static void destroy_op(grpc_exec_ctx *exec_ctx, void *op, grpc_error *error) { - gpr_free(op); -} - -void grpc_call_element_send_cancel(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem) { - grpc_transport_stream_op *op = gpr_malloc(sizeof(*op)); - memset(op, 0, sizeof(*op)); - op->cancel_error = GRPC_ERROR_CANCELLED; - op->on_complete = - grpc_closure_create(destroy_op, op, grpc_schedule_on_exec_ctx); - elem->filter->start_transport_stream_op(exec_ctx, elem, op); -} - -void grpc_call_element_send_cancel_with_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_status_code status, - grpc_slice *optional_message) { - grpc_transport_stream_op *op = gpr_malloc(sizeof(*op)); - memset(op, 0, sizeof(*op)); - op->on_complete = - grpc_closure_create(destroy_op, op, grpc_schedule_on_exec_ctx); - grpc_transport_stream_op_add_cancellation_with_message(exec_ctx, op, status, - optional_message); - elem->filter->start_transport_stream_op(exec_ctx, elem, op); -} - -void grpc_call_element_send_close_with_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_status_code status, - grpc_slice *optional_message) { - grpc_transport_stream_op *op = gpr_malloc(sizeof(*op)); - memset(op, 0, sizeof(*op)); - op->on_complete = - grpc_closure_create(destroy_op, op, grpc_schedule_on_exec_ctx); - grpc_transport_stream_op_add_close(exec_ctx, op, status, optional_message); - elem->filter->start_transport_stream_op(exec_ctx, elem, op); -} diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index f420583a8d..1cf07d43c2 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -299,18 +299,9 @@ grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem); void grpc_call_log_op(char *file, int line, gpr_log_severity severity, grpc_call_element *elem, grpc_transport_stream_op *op); -void grpc_call_element_send_cancel(grpc_exec_ctx *exec_ctx, - grpc_call_element *cur_elem); - -void grpc_call_element_send_cancel_with_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *cur_elem, - grpc_status_code status, - grpc_slice *optional_message); - -void grpc_call_element_send_close_with_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *cur_elem, - grpc_status_code status, - grpc_slice *optional_message); +void grpc_call_element_signal_error(grpc_exec_ctx *exec_ctx, + grpc_call_element *cur_elem, + grpc_error *error); extern int grpc_trace_channel; diff --git a/src/core/lib/channel/deadline_filter.c b/src/core/lib/channel/deadline_filter.c index a45a4d4b82..4e140c10f1 100644 --- a/src/core/lib/channel/deadline_filter.c +++ b/src/core/lib/channel/deadline_filter.c @@ -56,10 +56,11 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, deadline_state->timer_pending = false; gpr_mu_unlock(&deadline_state->timer_mu); if (error != GRPC_ERROR_CANCELLED) { - grpc_slice msg = grpc_slice_from_static_string("Deadline Exceeded"); - grpc_call_element_send_cancel_with_message( - exec_ctx, elem, GRPC_STATUS_DEADLINE_EXCEEDED, &msg); - grpc_slice_unref_internal(exec_ctx, msg); + grpc_call_element_signal_error( + exec_ctx, elem, + grpc_error_set_int(GRPC_ERROR_CREATE("Deadline Exceeded"), + GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_DEADLINE_EXCEEDED)); } GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer"); } diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index f8cdf62540..3578f20827 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -142,10 +142,11 @@ static void start_transport_stream_op(grpc_exec_ctx* exec_ctx, char* message_string; gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)", op->send_message->length, calld->max_send_size); - grpc_slice message = grpc_slice_from_copied_string(message_string); + grpc_transport_stream_op_finish_with_failure( + exec_ctx, op, grpc_error_set_int(GRPC_ERROR_CREATE(message_string), + GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_INVALID_ARGUMENT)); gpr_free(message_string); - grpc_call_element_send_close_with_message( - exec_ctx, elem, GRPC_STATUS_INVALID_ARGUMENT, &message); } // Inject callback for receiving a message. if (op->recv_message_ready != NULL) { |