diff options
author | 2017-03-21 13:08:53 -0700 | |
---|---|---|
committer | 2017-03-21 13:08:53 -0700 | |
commit | 14ef5d83e2e7d5b37179e3517e7da5bbd71ca30f (patch) | |
tree | 9dd4d288d15ae09f4f80b5aa6350755c3cc59443 /src/core/ext | |
parent | d86d7424a0844e90bd4748b428e988443545051d (diff) | |
parent | e50c7bdcc83638544eed01f20c19b89648d78fe9 (diff) |
Merge remote-tracking branch 'upstream/master' into remove_initial_connect_string
Diffstat (limited to 'src/core/ext')
-rw-r--r-- | src/core/ext/transport/chttp2/transport/hpack_parser.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c index 40f5120308..1865b997b7 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.c +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c @@ -1620,13 +1620,18 @@ void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx, grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, grpc_slice slice) { - /* TODO(ctiller): limit the distance of end from beg, and perform multiple - steps in the event of a large chunk of data to limit - stack space usage when no tail call optimization is - available */ +/* max number of bytes to parse at a time... limits call stack depth on + * compilers without TCO */ +#define MAX_PARSE_LENGTH 1024 p->current_slice_refcount = slice.refcount; - grpc_error *error = p->state(exec_ctx, p, GRPC_SLICE_START_PTR(slice), - GRPC_SLICE_END_PTR(slice)); + uint8_t *start = GRPC_SLICE_START_PTR(slice); + uint8_t *end = GRPC_SLICE_END_PTR(slice); + grpc_error *error = GRPC_ERROR_NONE; + while (start != end && error == GRPC_ERROR_NONE) { + uint8_t *target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start); + error = p->state(exec_ctx, p, start, target); + start = target; + } p->current_slice_refcount = NULL; return error; } |