Fix api_fuzzer found bug (#28113)

pull/28123/head
Craig Tiller 3 years ago committed by GitHub
parent 98276d8b46
commit e762aded3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/core/lib/resource_quota/api.cc

@ -39,14 +39,19 @@ grpc_arg MakeArg(ResourceQuota* quota) {
grpc_channel_args* EnsureResourceQuotaInChannelArgs(
const grpc_channel_args* args) {
if (grpc_channel_args_find(args, GRPC_ARG_RESOURCE_QUOTA) != nullptr) {
const grpc_arg* existing =
grpc_channel_args_find(args, GRPC_ARG_RESOURCE_QUOTA);
if (existing != nullptr && existing->type == GRPC_ARG_POINTER &&
existing->value.pointer.p == nullptr) {
return grpc_channel_args_copy(args);
}
// If there's no existing quota, add it to the default one - shared between
// all channel args declared thusly. This prevents us from accidentally not
// sharing subchannels due to their channel args not specifying a quota.
const char* remove[] = {GRPC_ARG_RESOURCE_QUOTA};
auto new_arg = MakeArg(ResourceQuota::Default().get());
return grpc_channel_args_copy_and_add(args, &new_arg, 1);
return grpc_channel_args_copy_and_add_and_remove(args, remove, 1, &new_arg,
1);
}
grpc_channel_args* ChannelArgsWrappingResourceQuota(

Loading…
Cancel
Save