aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.c1
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.c19
-rw-r--r--src/core/lib/iomgr/error.c9
-rw-r--r--src/core/lib/iomgr/error.h2
-rw-r--r--src/core/lib/support/avl.c9
5 files changed, 28 insertions, 12 deletions
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
index 41d983cb70..1b1dcabe71 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
@@ -866,6 +866,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
grpc_error *error) {
grpc_closure *closure = *pclosure;
if (closure == NULL) {
+ GRPC_ERROR_UNREF(error);
return;
}
closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT;
diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c
index 24b7de0f79..128e22ae42 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.c
+++ b/src/core/ext/transport/chttp2/transport/parsing.c
@@ -225,14 +225,15 @@ void grpc_chttp2_publish_reads(
}
if (stream_parsing->forced_close_error != GRPC_ERROR_NONE) {
- const intptr_t *reason = grpc_error_get_int(
- stream_parsing->forced_close_error, GRPC_ERROR_INT_HTTP2_ERROR);
- if (reason == NULL || *reason != GRPC_CHTTP2_NO_ERROR) {
+ intptr_t reason;
+ bool has_reason = grpc_error_get_int(stream_parsing->forced_close_error,
+ GRPC_ERROR_INT_HTTP2_ERROR, &reason);
+ if (has_reason || reason != GRPC_CHTTP2_NO_ERROR) {
grpc_status_code status_code =
- reason == NULL ? GRPC_STATUS_INTERNAL
- : grpc_chttp2_http2_error_to_grpc_status(
- (grpc_chttp2_error_code)
- stream_parsing->rst_stream_reason);
+ has_reason
+ ? grpc_chttp2_http2_error_to_grpc_status(
+ (grpc_chttp2_error_code)stream_parsing->rst_stream_reason)
+ : GRPC_STATUS_INTERNAL;
const char *status_details =
grpc_error_string(stream_parsing->forced_close_error);
gpr_slice slice_details = gpr_slice_from_copied_string(status_details);
@@ -609,7 +610,7 @@ static grpc_error *init_data_frame_parser(
transport_parsing->parser = grpc_chttp2_data_parser_parse;
transport_parsing->parser_data = &stream_parsing->data_parser;
return GRPC_ERROR_NONE;
- } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID)) {
+ } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
/* handle stream errors by closing the stream */
stream_parsing->received_close = 1;
stream_parsing->forced_close_error = err;
@@ -907,7 +908,7 @@ static grpc_error *parse_frame_slice(
stream_parsing);
}
return GRPC_ERROR_NONE;
- } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID) != NULL) {
+ } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
if (grpc_http_trace) {
const char *msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.c
index d67eb6e425..6d16a54d57 100644
--- a/src/core/lib/iomgr/error.c
+++ b/src/core/lib/iomgr/error.c
@@ -240,8 +240,13 @@ grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
return new;
}
-const intptr_t *grpc_error_get_int(grpc_error *err, grpc_error_ints which) {
- return gpr_avl_get(err->ints, (void *)(uintptr_t)which);
+bool grpc_error_get_int(grpc_error *err, grpc_error_ints which, intptr_t *p) {
+ void *pp;
+ if (gpr_avl_maybe_get(err->ints, (void *)(uintptr_t)which, &pp)) {
+ if (p != NULL) *p = (intptr_t)pp;
+ return true;
+ }
+ return false;
}
grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h
index 266a621704..2b9b9f00c0 100644
--- a/src/core/lib/iomgr/error.h
+++ b/src/core/lib/iomgr/error.h
@@ -107,7 +107,7 @@ void grpc_error_unref(grpc_error *err, const char *file, int line,
grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
intptr_t value);
-const intptr_t *grpc_error_get_int(grpc_error *error, grpc_error_ints which);
+bool grpc_error_get_int(grpc_error *error, grpc_error_ints which, intptr_t *p);
grpc_error *grpc_error_set_time(grpc_error *src, grpc_error_times which,
gpr_timespec value);
grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
diff --git a/src/core/lib/support/avl.c b/src/core/lib/support/avl.c
index ceded9d266..acf8fd5a55 100644
--- a/src/core/lib/support/avl.c
+++ b/src/core/lib/support/avl.c
@@ -124,6 +124,15 @@ void *gpr_avl_get(gpr_avl avl, void *key) {
return node ? node->value : NULL;
}
+int gpr_avl_maybe_get(gpr_avl avl, void *key, void **value) {
+ gpr_avl_node *node = get(avl.vtable, avl.root, key);
+ if (node != NULL) {
+ *value = node->value;
+ return 1;
+ }
+ return 0;
+}
+
static gpr_avl_node *rotate_left(const gpr_avl_vtable *vtable, void *key,
void *value, gpr_avl_node *left,
gpr_avl_node *right) {