diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-19 17:02:49 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-19 17:02:49 -0700 |
commit | 36cce53680f5c0a3d68ce2f3d04cef8eeac3b36d (patch) | |
tree | c8a35fcf67d5b570de4b28c926a00e47d4993f0e /test | |
parent | 33fd9fa09973f5c5c6865097d810f18bc54c62a8 (diff) |
Delete calls
Diffstat (limited to 'test')
-rw-r--r-- | test/core/end2end/fuzzers/api_fuzzer.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 0d069347f3..32abca60fe 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -381,6 +381,33 @@ static call_state *new_call(call_state *sibling, call_state_type type) { return c; } +static call_state *maybe_delete_call_state(call_state **active, call_state *call) { + call_state *next = call->next; + + if (call->call != NULL) return next; + + if (call == *active) { + *active = call->next; + GPR_ASSERT(call != *active); + } + + call->prev->next = call->next; + call->next->prev = call->prev; + grpc_metadata_array_destroy(&call->recv_initial_metadata); + grpc_metadata_array_destroy(&call->recv_trailing_metadata); + gpr_free(call->recv_status_details); + grpc_call_details_destroy(&call->call_details); + gpr_free(call); + + return next; +} + +static call_state *destroy_call(call_state **active, call_state *call) { + grpc_call_destroy(call->call); + call->call = NULL; + return maybe_delete_call_state(active, call); +} + int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_test_only_set_metadata_hash_seed(0); if (squelch) gpr_set_log_function(dont_log); @@ -422,6 +449,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_server = NULL; } } + call_state *s = active_call; + do { + if (s->type != PENDING_SERVER && s->call != NULL) { + s = destroy_call(&active_call, s); + } + } while (s != active_call); g_now = gpr_time_add(g_now, gpr_time_from_seconds(1, GPR_TIMESPAN)); } @@ -791,6 +824,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { } break; } + // destroy a call + case 20: { + if (active_call->type != ROOT && active_call->type != PENDING_SERVER && + active_call->call != NULL) { + destroy_call(&active_call, active_call); + } else { + end(&inp); + } + break; + } } } |