diff options
author | Craig Tiller <ctiller@google.com> | 2016-07-06 19:40:12 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-07-06 19:40:12 -0700 |
commit | 81ea6375281e0d1674888c51244300ed8ae99bce (patch) | |
tree | 23ae982323c1edb0a2436d53fb068aeecae84519 /src/core | |
parent | 42ac6dbe2052913727b29f92d5415c4a5c4b845f (diff) | |
parent | 183574787744f42491398cb0dafba6209c355cae (diff) |
Merge github.com:grpc/grpc into delayed-write
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ext/resolver/zookeeper/README.md | 1 | ||||
-rw-r--r-- | src/core/lib/channel/channel_stack.c | 11 | ||||
-rw-r--r-- | src/core/lib/channel/channel_stack.h | 5 | ||||
-rw-r--r-- | src/core/lib/channel/http_client_filter.c | 8 | ||||
-rw-r--r-- | src/core/lib/surface/call.c | 6 | ||||
-rw-r--r-- | src/core/lib/transport/transport.c | 24 | ||||
-rw-r--r-- | src/core/lib/transport/transport.h | 4 |
7 files changed, 54 insertions, 5 deletions
diff --git a/src/core/ext/resolver/zookeeper/README.md b/src/core/ext/resolver/zookeeper/README.md deleted file mode 100644 index ce6f39683b..0000000000 --- a/src/core/ext/resolver/zookeeper/README.md +++ /dev/null @@ -1 +0,0 @@ -Zookeeper based name resolver: WIP diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.c index 42075b127b..87175d7943 100644 --- a/src/core/lib/channel/channel_stack.c +++ b/src/core/lib/channel/channel_stack.c @@ -266,3 +266,14 @@ void grpc_call_element_send_cancel(grpc_exec_ctx *exec_ctx, op.cancel_error = GRPC_ERROR_CANCELLED; grpc_call_next_op(exec_ctx, cur_elem, &op); } + +void grpc_call_element_send_cancel_with_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *cur_elem, + grpc_status_code status, + gpr_slice *optional_message) { + grpc_transport_stream_op op; + memset(&op, 0, sizeof(op)); + grpc_transport_stream_op_add_cancellation_with_message(&op, status, + optional_message); + grpc_call_next_op(exec_ctx, cur_elem, &op); +} diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index 41dd4a0d8a..d72c015b67 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -273,6 +273,11 @@ void grpc_call_log_op(char *file, int line, gpr_log_severity severity, 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, + gpr_slice *optional_message); + extern int grpc_trace_channel; #define GRPC_CALL_LOG_OP(sev, elem, op) \ diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index ab6c6c9ef0..8057e251f0 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -76,7 +76,13 @@ static grpc_mdelem *client_recv_filter(void *user_data, grpc_mdelem *md) { if (md == GRPC_MDELEM_STATUS_200) { return NULL; } else if (md->key == GRPC_MDSTR_STATUS) { - grpc_call_element_send_cancel(a->exec_ctx, a->elem); + char *message_string; + gpr_asprintf(&message_string, "Received http2 header with status: %s", + grpc_mdstr_as_c_string(md->value)); + gpr_slice message = gpr_slice_from_copied_string(message_string); + gpr_free(message_string); + grpc_call_element_send_cancel_with_message(a->exec_ctx, a->elem, + GRPC_STATUS_CANCELLED, &message); return NULL; } else if (md == GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC) { return NULL; diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 708ea3502a..e5668be47f 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -1206,7 +1206,7 @@ static void validate_filtered_metadata(grpc_exec_ctx *exec_ctx, } else if (grpc_compression_options_is_algorithm_enabled( &compression_options, algo) == 0) { /* check if algorithm is supported by current channel config */ - char *algo_name; + char *algo_name = NULL; grpc_compression_algorithm_name(algo, &algo_name); gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.", algo_name); @@ -1225,7 +1225,7 @@ static void validate_filtered_metadata(grpc_exec_ctx *exec_ctx, call->incoming_compression_algorithm)) { extern int grpc_compression_trace; if (grpc_compression_trace) { - char *algo_name; + char *algo_name = NULL; grpc_compression_algorithm_name(call->incoming_compression_algorithm, &algo_name); gpr_log(GPR_ERROR, @@ -1426,7 +1426,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, const grpc_compression_algorithm calgo = compression_algorithm_for_level_locked( call, effective_compression_level); - char *calgo_name; + char *calgo_name = NULL; grpc_compression_algorithm_name(calgo, &calgo_name); // the following will be picked up by the compress filter and used as // the call's compression algorithm. diff --git a/src/core/lib/transport/transport.c b/src/core/lib/transport/transport.c index f8ddf5774a..857c3909d2 100644 --- a/src/core/lib/transport/transport.c +++ b/src/core/lib/transport/transport.c @@ -199,6 +199,30 @@ void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, } } +void grpc_transport_stream_op_add_cancellation_with_message( + grpc_transport_stream_op *op, grpc_status_code status, + gpr_slice *optional_message) { + GPR_ASSERT(status != GRPC_STATUS_OK); + if (op->cancel_error != GRPC_ERROR_NONE) { + if (optional_message) { + gpr_slice_unref(*optional_message); + } + return; + } + grpc_error *error; + if (optional_message != NULL) { + char *msg = gpr_dump_slice(*optional_message, GPR_DUMP_ASCII); + error = grpc_error_set_str(GRPC_ERROR_CREATE(msg), + GRPC_ERROR_STR_GRPC_MESSAGE, msg); + gpr_free(msg); + gpr_slice_unref(*optional_message); + } else { + error = GRPC_ERROR_CREATE("Call cancelled"); + } + error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, status); + add_error(op, &op->close_error, error); +} + void grpc_transport_stream_op_add_close(grpc_transport_stream_op *op, grpc_status_code status, gpr_slice *optional_message) { diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index d2f6344ee3..08c0a237c9 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -221,6 +221,10 @@ void grpc_transport_stream_op_finish_with_failure(grpc_exec_ctx *exec_ctx, void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, grpc_status_code status); +void grpc_transport_stream_op_add_cancellation_with_message( + grpc_transport_stream_op *op, grpc_status_code status, + gpr_slice *optional_message); + void grpc_transport_stream_op_add_close(grpc_transport_stream_op *op, grpc_status_code status, gpr_slice *optional_message); |