aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/bad_client/bad_client.c6
-rw-r--r--test/core/end2end/end2end_nosec_tests.c16
-rw-r--r--test/core/end2end/end2end_tests.c16
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.c6
-rw-r--r--test/core/end2end/fixtures/h2_sockpair.c6
-rw-r--r--test/core/end2end/fixtures/h2_sockpair_1byte.c6
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c10
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.c6
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.c6
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py2
-rw-r--r--test/core/end2end/tests/buffer_pool_server.c17
-rw-r--r--test/core/end2end/tests/resource_quota_server.c352
-rw-r--r--test/core/http/httpcli_test.c12
-rw-r--r--test/core/http/httpscli_test.c12
-rw-r--r--test/core/internal_api_canaries/iomgr.c2
-rw-r--r--test/core/iomgr/endpoint_pair_test.c6
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.c8
-rw-r--r--test/core/iomgr/resource_quota_test.c (renamed from test/core/iomgr/buffer_pool_test.c)382
-rw-r--r--test/core/iomgr/tcp_posix_test.c37
-rw-r--r--test/core/security/secure_endpoint_test.c8
-rw-r--r--test/core/util/mock_endpoint.c18
-rw-r--r--test/core/util/mock_endpoint.h2
-rw-r--r--test/core/util/passthru_endpoint.c20
-rw-r--r--test/core/util/passthru_endpoint.h2
-rw-r--r--test/core/util/port_server_client.c24
-rw-r--r--test/cpp/end2end/end2end_test.cc15
-rw-r--r--test/cpp/qps/server_async.cc8
-rw-r--r--test/cpp/qps/server_sync.cc8
28 files changed, 689 insertions, 324 deletions
diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c
index 60f0ab2106..8a4a17ea93 100644
--- a/test/core/bad_client/bad_client.c
+++ b/test/core/bad_client/bad_client.c
@@ -114,9 +114,9 @@ void grpc_run_bad_client_test(
grpc_init();
/* Create endpoints */
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("bad_client_test");
- sfd = grpc_iomgr_create_endpoint_pair("fixture", buffer_pool, 65536);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("bad_client_test");
+ sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
/* Create server, completion events */
a.server = grpc_server_create(NULL, NULL);
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c
index 1c9332acc1..caaa97c215 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.c
@@ -47,8 +47,6 @@ extern void bad_hostname(grpc_end2end_test_config config);
extern void bad_hostname_pre_init(void);
extern void binary_metadata(grpc_end2end_test_config config);
extern void binary_metadata_pre_init(void);
-extern void buffer_pool_server(grpc_end2end_test_config config);
-extern void buffer_pool_server_pre_init(void);
extern void cancel_after_accept(grpc_end2end_test_config config);
extern void cancel_after_accept_pre_init(void);
extern void cancel_after_client_done(grpc_end2end_test_config config);
@@ -113,6 +111,8 @@ extern void request_with_flags(grpc_end2end_test_config config);
extern void request_with_flags_pre_init(void);
extern void request_with_payload(grpc_end2end_test_config config);
extern void request_with_payload_pre_init(void);
+extern void resource_quota_server(grpc_end2end_test_config config);
+extern void resource_quota_server_pre_init(void);
extern void server_finishes_request(grpc_end2end_test_config config);
extern void server_finishes_request_pre_init(void);
extern void shutdown_finishes_calls(grpc_end2end_test_config config);
@@ -137,7 +137,6 @@ void grpc_end2end_tests_pre_init(void) {
g_pre_init_called = true;
bad_hostname_pre_init();
binary_metadata_pre_init();
- buffer_pool_server_pre_init();
cancel_after_accept_pre_init();
cancel_after_client_done_pre_init();
cancel_after_invoke_pre_init();
@@ -170,6 +169,7 @@ void grpc_end2end_tests_pre_init(void) {
registered_call_pre_init();
request_with_flags_pre_init();
request_with_payload_pre_init();
+ resource_quota_server_pre_init();
server_finishes_request_pre_init();
shutdown_finishes_calls_pre_init();
shutdown_finishes_tags_pre_init();
@@ -190,7 +190,6 @@ void grpc_end2end_tests(int argc, char **argv,
if (argc <= 1) {
bad_hostname(config);
binary_metadata(config);
- buffer_pool_server(config);
cancel_after_accept(config);
cancel_after_client_done(config);
cancel_after_invoke(config);
@@ -223,6 +222,7 @@ void grpc_end2end_tests(int argc, char **argv,
registered_call(config);
request_with_flags(config);
request_with_payload(config);
+ resource_quota_server(config);
server_finishes_request(config);
shutdown_finishes_calls(config);
shutdown_finishes_tags(config);
@@ -244,10 +244,6 @@ void grpc_end2end_tests(int argc, char **argv,
binary_metadata(config);
continue;
}
- if (0 == strcmp("buffer_pool_server", argv[i])) {
- buffer_pool_server(config);
- continue;
- }
if (0 == strcmp("cancel_after_accept", argv[i])) {
cancel_after_accept(config);
continue;
@@ -376,6 +372,10 @@ void grpc_end2end_tests(int argc, char **argv,
request_with_payload(config);
continue;
}
+ if (0 == strcmp("resource_quota_server", argv[i])) {
+ resource_quota_server(config);
+ continue;
+ }
if (0 == strcmp("server_finishes_request", argv[i])) {
server_finishes_request(config);
continue;
diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c
index cf0e4c8316..6d17e686e6 100644
--- a/test/core/end2end/end2end_tests.c
+++ b/test/core/end2end/end2end_tests.c
@@ -47,8 +47,6 @@ extern void bad_hostname(grpc_end2end_test_config config);
extern void bad_hostname_pre_init(void);
extern void binary_metadata(grpc_end2end_test_config config);
extern void binary_metadata_pre_init(void);
-extern void buffer_pool_server(grpc_end2end_test_config config);
-extern void buffer_pool_server_pre_init(void);
extern void call_creds(grpc_end2end_test_config config);
extern void call_creds_pre_init(void);
extern void cancel_after_accept(grpc_end2end_test_config config);
@@ -115,6 +113,8 @@ extern void request_with_flags(grpc_end2end_test_config config);
extern void request_with_flags_pre_init(void);
extern void request_with_payload(grpc_end2end_test_config config);
extern void request_with_payload_pre_init(void);
+extern void resource_quota_server(grpc_end2end_test_config config);
+extern void resource_quota_server_pre_init(void);
extern void server_finishes_request(grpc_end2end_test_config config);
extern void server_finishes_request_pre_init(void);
extern void shutdown_finishes_calls(grpc_end2end_test_config config);
@@ -139,7 +139,6 @@ void grpc_end2end_tests_pre_init(void) {
g_pre_init_called = true;
bad_hostname_pre_init();
binary_metadata_pre_init();
- buffer_pool_server_pre_init();
call_creds_pre_init();
cancel_after_accept_pre_init();
cancel_after_client_done_pre_init();
@@ -173,6 +172,7 @@ void grpc_end2end_tests_pre_init(void) {
registered_call_pre_init();
request_with_flags_pre_init();
request_with_payload_pre_init();
+ resource_quota_server_pre_init();
server_finishes_request_pre_init();
shutdown_finishes_calls_pre_init();
shutdown_finishes_tags_pre_init();
@@ -193,7 +193,6 @@ void grpc_end2end_tests(int argc, char **argv,
if (argc <= 1) {
bad_hostname(config);
binary_metadata(config);
- buffer_pool_server(config);
call_creds(config);
cancel_after_accept(config);
cancel_after_client_done(config);
@@ -227,6 +226,7 @@ void grpc_end2end_tests(int argc, char **argv,
registered_call(config);
request_with_flags(config);
request_with_payload(config);
+ resource_quota_server(config);
server_finishes_request(config);
shutdown_finishes_calls(config);
shutdown_finishes_tags(config);
@@ -248,10 +248,6 @@ void grpc_end2end_tests(int argc, char **argv,
binary_metadata(config);
continue;
}
- if (0 == strcmp("buffer_pool_server", argv[i])) {
- buffer_pool_server(config);
- continue;
- }
if (0 == strcmp("call_creds", argv[i])) {
call_creds(config);
continue;
@@ -384,6 +380,10 @@ void grpc_end2end_tests(int argc, char **argv,
request_with_payload(config);
continue;
}
+ if (0 == strcmp("resource_quota_server", argv[i])) {
+ resource_quota_server(config);
+ continue;
+ }
if (0 == strcmp("server_finishes_request", argv[i])) {
server_finishes_request(config);
continue;
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c
index 4a546e710e..f7dbfdf2e3 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.c
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.c
@@ -91,9 +91,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
f.fixture_data = sfd;
f.cq = grpc_completion_queue_create(NULL);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("fixture");
- *sfd = grpc_iomgr_create_endpoint_pair("fixture", buffer_pool, 65536);
- grpc_buffer_pool_unref(buffer_pool);
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture");
+ *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536);
+ grpc_resource_quota_unref(resource_quota);
return f;
}
diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c
index f528f0b0b2..c571b12e4a 100644
--- a/test/core/end2end/fixtures/h2_sockpair.c
+++ b/test/core/end2end/fixtures/h2_sockpair.c
@@ -90,9 +90,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
f.fixture_data = sfd;
f.cq = grpc_completion_queue_create(NULL);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("fixture");
- *sfd = grpc_iomgr_create_endpoint_pair("fixture", buffer_pool, 65536);
- grpc_buffer_pool_unref(buffer_pool);
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture");
+ *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536);
+ grpc_resource_quota_unref(resource_quota);
return f;
}
diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c
index 293cdf278e..c3d2d5decc 100644
--- a/test/core/end2end/fixtures/h2_sockpair_1byte.c
+++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c
@@ -90,9 +90,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
f.fixture_data = sfd;
f.cq = grpc_completion_queue_create(NULL);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("fixture");
- *sfd = grpc_iomgr_create_endpoint_pair("fixture", buffer_pool, 1);
- grpc_buffer_pool_unref(buffer_pool);
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture");
+ *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 1);
+ grpc_resource_quota_unref(resource_quota);
return f;
}
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index f39a79ca19..945cc960e9 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -173,7 +173,7 @@ static bool is_eof(input_stream *inp) { return inp->cur == inp->end; }
static gpr_timespec g_now;
static grpc_server *g_server;
static grpc_channel *g_channel;
-static grpc_buffer_pool *g_buffer_pool;
+static grpc_resource_quota *g_resource_quota;
extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
@@ -253,7 +253,7 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
} else if (g_server != NULL) {
grpc_endpoint *client;
grpc_endpoint *server;
- grpc_passthru_endpoint_create(&client, &server, g_buffer_pool);
+ grpc_passthru_endpoint_create(&client, &server, g_resource_quota);
*fc->ep = client;
grpc_transport *transport =
@@ -522,7 +522,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
int pending_pings = 0;
g_active_call = new_call(NULL, ROOT);
- g_buffer_pool = grpc_buffer_pool_create("api_fuzzer");
+ g_resource_quota = grpc_resource_quota_create("api_fuzzer");
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
@@ -944,7 +944,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// resize the buffer pool
case 21: {
- grpc_buffer_pool_resize(g_buffer_pool, read_uint22(&inp));
+ grpc_resource_quota_resize(g_resource_quota, read_uint22(&inp));
break;
}
}
@@ -962,7 +962,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
- grpc_buffer_pool_unref(g_buffer_pool);
+ grpc_resource_quota_unref(g_resource_quota);
grpc_shutdown();
return 0;
diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c
index 55d04ec28a..b57c8c95fd 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.c
+++ b/test/core/end2end/fuzzers/client_fuzzer.c
@@ -58,10 +58,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_init();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("client_fuzzer");
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("client_fuzzer");
grpc_endpoint *mock_endpoint =
- grpc_mock_endpoint_create(discard_write, buffer_pool);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
grpc_transport *transport =
diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c
index dd093e51ec..58c2a9d483 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.c
+++ b/test/core/end2end/fuzzers/server_fuzzer.c
@@ -56,10 +56,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_init();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("server_fuzzer");
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("server_fuzzer");
grpc_endpoint *mock_endpoint =
- grpc_mock_endpoint_create(discard_write, buffer_pool);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_mock_endpoint_put_read(
&exec_ctx, mock_endpoint,
gpr_slice_from_copied_buffer((const char *)data, size));
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 3fc827fc7d..0ae70ce308 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -88,7 +88,7 @@ LOWCPU = 0.1
END2END_TESTS = {
'bad_hostname': default_test_options,
'binary_metadata': default_test_options,
- 'buffer_pool_server': default_test_options._replace(large_writes=True,
+ 'resource_quota_server': default_test_options._replace(large_writes=True,
proxyable=False),
'call_creds': default_test_options._replace(secure=True),
'cancel_after_accept': default_test_options._replace(cpu_cost=LOWCPU),
diff --git a/test/core/end2end/tests/buffer_pool_server.c b/test/core/end2end/tests/buffer_pool_server.c
index daa971ccfc..81850aea58 100644
--- a/test/core/end2end/tests/buffer_pool_server.c
+++ b/test/core/end2end/tests/buffer_pool_server.c
@@ -107,9 +107,10 @@ static gpr_slice generate_random_slice() {
return gpr_slice_from_copied_string(output);
}
-void buffer_pool_server(grpc_end2end_test_config config) {
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("test_server");
- grpc_buffer_pool_resize(buffer_pool, 5 * 1024 * 1024);
+void resource_quota_server(grpc_end2end_test_config config) {
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("test_server");
+ grpc_resource_quota_resize(resource_quota, 5 * 1024 * 1024);
#define NUM_CALLS 100
#define CLIENT_BASE_TAG 1000
@@ -120,12 +121,12 @@ void buffer_pool_server(grpc_end2end_test_config config) {
grpc_arg arg;
arg.key = GRPC_ARG_BUFFER_POOL;
arg.type = GRPC_ARG_POINTER;
- arg.value.pointer.p = buffer_pool;
- arg.value.pointer.vtable = grpc_buffer_pool_arg_vtable();
+ arg.value.pointer.p = resource_quota;
+ arg.value.pointer.vtable = grpc_resource_quota_arg_vtable();
grpc_channel_args args = {1, &arg};
grpc_end2end_test_fixture f =
- begin_test(config, "buffer_pool_server", NULL, &args);
+ begin_test(config, "resource_quota_server", NULL, &args);
/* Create large request and response bodies. These are big enough to require
* multiple round trips to deliver to the peer, and their exact contents of
@@ -343,10 +344,10 @@ void buffer_pool_server(grpc_end2end_test_config config) {
grpc_byte_buffer_destroy(request_payload);
gpr_slice_unref(request_payload_slice);
- grpc_buffer_pool_unref(buffer_pool);
+ grpc_resource_quota_unref(resource_quota);
end_test(&f);
config.tear_down_data(&f);
}
-void buffer_pool_server_pre_init(void) {}
+void resource_quota_server_pre_init(void) {}
diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c
new file mode 100644
index 0000000000..c658776cba
--- /dev/null
+++ b/test/core/end2end/tests/resource_quota_server.c
@@ -0,0 +1,352 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "test/core/end2end/cq_verifier.h"
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char *test_name,
+ grpc_channel_args *client_args,
+ grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_time(int n) {
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+}
+
+static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+/* Creates and returns a gpr_slice containing random alphanumeric characters. */
+static gpr_slice generate_random_slice() {
+ size_t i;
+ static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
+ char output[1024 * 1024];
+ for (i = 0; i < GPR_ARRAY_SIZE(output) - 1; ++i) {
+ output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
+ }
+ output[GPR_ARRAY_SIZE(output) - 1] = '\0';
+ return gpr_slice_from_copied_string(output);
+}
+
+void resource_quota_server(grpc_end2end_test_config config) {
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_server");
+ grpc_resource_quota_resize(resource_quota, 5 * 1024 * 1024);
+
+#define NUM_CALLS 100
+#define CLIENT_BASE_TAG 1000
+#define SERVER_START_BASE_TAG 2000
+#define SERVER_RECV_BASE_TAG 3000
+#define SERVER_END_BASE_TAG 4000
+
+ grpc_arg arg;
+ arg.key = GRPC_ARG_BUFFER_POOL;
+ arg.type = GRPC_ARG_POINTER;
+ arg.value.pointer.p = resource_quota;
+ arg.value.pointer.vtable = grpc_resource_quota_arg_vtable();
+ grpc_channel_args args = {1, &arg};
+
+ grpc_end2end_test_fixture f =
+ begin_test(config, "resource_quota_server", NULL, &args);
+
+ /* Create large request and response bodies. These are big enough to require
+ * multiple round trips to deliver to the peer, and their exact contents of
+ * will be verified on completion. */
+ gpr_slice request_payload_slice = generate_random_slice();
+
+ grpc_call *client_calls[NUM_CALLS];
+ grpc_call *server_calls[NUM_CALLS];
+ grpc_metadata_array initial_metadata_recv[NUM_CALLS];
+ grpc_metadata_array trailing_metadata_recv[NUM_CALLS];
+ grpc_metadata_array request_metadata_recv[NUM_CALLS];
+ grpc_call_details call_details[NUM_CALLS];
+ grpc_status_code status[NUM_CALLS];
+ char *details[NUM_CALLS];
+ size_t details_capacity[NUM_CALLS];
+ grpc_byte_buffer *request_payload_recv[NUM_CALLS];
+ int was_cancelled[NUM_CALLS];
+ grpc_call_error error;
+ int pending_client_calls = 0;
+ int pending_server_start_calls = 0;
+ int pending_server_recv_calls = 0;
+ int pending_server_end_calls = 0;
+ int cancelled_calls_on_client = 0;
+ int cancelled_calls_on_server = 0;
+
+ grpc_byte_buffer *request_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+
+ grpc_op ops[6];
+ grpc_op *op;
+
+ for (int i = 0; i < NUM_CALLS; i++) {
+ grpc_metadata_array_init(&initial_metadata_recv[i]);
+ grpc_metadata_array_init(&trailing_metadata_recv[i]);
+ grpc_metadata_array_init(&request_metadata_recv[i]);
+ grpc_call_details_init(&call_details[i]);
+ details[i] = NULL;
+ details_capacity[i] = 0;
+ request_payload_recv[i] = NULL;
+ was_cancelled[i] = 0;
+ }
+
+ for (int i = 0; i < NUM_CALLS; i++) {
+ error = grpc_server_request_call(
+ f.server, &server_calls[i], &call_details[i], &request_metadata_recv[i],
+ f.cq, f.cq, tag(SERVER_START_BASE_TAG + i));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ pending_server_start_calls++;
+ }
+
+ for (int i = 0; i < NUM_CALLS; i++) {
+ client_calls[i] = grpc_channel_create_call(
+ f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo",
+ "foo.test.google.fr", n_seconds_time(60), NULL);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv[i];
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata =
+ &trailing_metadata_recv[i];
+ op->data.recv_status_on_client.status = &status[i];
+ op->data.recv_status_on_client.status_details = &details[i];
+ op->data.recv_status_on_client.status_details_capacity =
+ &details_capacity[i];
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(client_calls[i], ops, (size_t)(op - ops),
+ tag(CLIENT_BASE_TAG + i), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ pending_client_calls++;
+ }
+
+ while (pending_client_calls + pending_server_recv_calls +
+ pending_server_end_calls >
+ 0) {
+ grpc_event ev = grpc_completion_queue_next(f.cq, n_seconds_time(10), NULL);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+
+ int ev_tag = (int)(intptr_t)ev.tag;
+ if (ev_tag < CLIENT_BASE_TAG) {
+ abort(); /* illegal tag */
+ } else if (ev_tag < SERVER_START_BASE_TAG) {
+ /* client call finished */
+ int call_id = ev_tag - CLIENT_BASE_TAG;
+ GPR_ASSERT(call_id >= 0);
+ GPR_ASSERT(call_id < NUM_CALLS);
+ switch (status[call_id]) {
+ case GRPC_STATUS_RESOURCE_EXHAUSTED:
+ cancelled_calls_on_client++;
+ break;
+ case GRPC_STATUS_OK:
+ break;
+ default:
+ gpr_log(GPR_ERROR, "Unexpected status code: %d", status[call_id]);
+ abort();
+ }
+ GPR_ASSERT(pending_client_calls > 0);
+
+ grpc_metadata_array_destroy(&initial_metadata_recv[call_id]);
+ grpc_metadata_array_destroy(&trailing_metadata_recv[call_id]);
+ grpc_call_destroy(client_calls[call_id]);
+ gpr_free(details[call_id]);
+
+ pending_client_calls--;
+ } else if (ev_tag < SERVER_RECV_BASE_TAG) {
+ /* new incoming call to the server */
+ int call_id = ev_tag - SERVER_START_BASE_TAG;
+ GPR_ASSERT(call_id >= 0);
+ GPR_ASSERT(call_id < NUM_CALLS);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message = &request_payload_recv[call_id];
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error =
+ grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
+ tag(SERVER_RECV_BASE_TAG + call_id), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ GPR_ASSERT(pending_server_start_calls > 0);
+ pending_server_start_calls--;
+ pending_server_recv_calls++;
+
+ grpc_call_details_destroy(&call_details[call_id]);
+ grpc_metadata_array_destroy(&request_metadata_recv[call_id]);
+ } else if (ev_tag < SERVER_END_BASE_TAG) {
+ /* finished read on the server */
+ int call_id = ev_tag - SERVER_RECV_BASE_TAG;
+ GPR_ASSERT(call_id >= 0);
+ GPR_ASSERT(call_id < NUM_CALLS);
+
+ if (ev.success) {
+ if (request_payload_recv[call_id] != NULL) {
+ grpc_byte_buffer_destroy(request_payload_recv[call_id]);
+ request_payload_recv[call_id] = NULL;
+ }
+ } else {
+ GPR_ASSERT(request_payload_recv[call_id] == NULL);
+ }
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled[call_id];
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_OK;
+ op->data.send_status_from_server.status_details = "xyz";
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error =
+ grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
+ tag(SERVER_END_BASE_TAG + call_id), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ GPR_ASSERT(pending_server_recv_calls > 0);
+ pending_server_recv_calls--;
+ pending_server_end_calls++;
+ } else {
+ int call_id = ev_tag - SERVER_END_BASE_TAG;
+ GPR_ASSERT(call_id >= 0);
+ GPR_ASSERT(call_id < NUM_CALLS);
+
+ if (was_cancelled[call_id]) {
+ cancelled_calls_on_server++;
+ }
+ GPR_ASSERT(pending_server_end_calls > 0);
+ pending_server_end_calls--;
+
+ grpc_call_destroy(server_calls[call_id]);
+ }
+ }
+
+ gpr_log(
+ GPR_INFO,
+ "Done. %d total calls: %d cancelled at server, %d cancelled at client.",
+ NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client);
+
+ GPR_ASSERT(cancelled_calls_on_client >= cancelled_calls_on_server);
+ GPR_ASSERT(cancelled_calls_on_server >= 0.9 * cancelled_calls_on_client);
+
+ grpc_byte_buffer_destroy(request_payload);
+ gpr_slice_unref(request_payload_slice);
+ grpc_resource_quota_unref(resource_quota);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void resource_quota_server_pre_init(void) {}
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
index 1ecfe219d4..14318ae184 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.c
@@ -89,11 +89,11 @@ static void test_get(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("test_get");
- grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, buffer_pool, &req,
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
+ grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -129,11 +129,11 @@ static void test_post(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("test_post");
- grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, buffer_pool, &req, "hello",
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
+ grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello",
5, n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c
index 51ca73fdc6..966d5e4062 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.c
@@ -90,11 +90,11 @@ static void test_get(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("test_get");
- grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, buffer_pool, &req,
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
+ grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -131,11 +131,11 @@ static void test_post(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("test_post");
- grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, buffer_pool, &req, "hello",
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
+ grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello",
5, n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
diff --git a/test/core/internal_api_canaries/iomgr.c b/test/core/internal_api_canaries/iomgr.c
index 4f967ce751..f1efa87a69 100644
--- a/test/core/internal_api_canaries/iomgr.c
+++ b/test/core/internal_api_canaries/iomgr.c
@@ -84,7 +84,7 @@ static void test_code(void) {
grpc_endpoint_add_to_pollset_set,
grpc_endpoint_shutdown,
grpc_endpoint_destroy,
- grpc_endpoint_get_buffer_user,
+ grpc_endpoint_get_resource_user,
grpc_endpoint_get_peer};
endpoint.vtable = &vtable;
diff --git a/test/core/iomgr/endpoint_pair_test.c b/test/core/iomgr/endpoint_pair_test.c
index 4f8aab8323..53fb865e4b 100644
--- a/test/core/iomgr/endpoint_pair_test.c
+++ b/test/core/iomgr/endpoint_pair_test.c
@@ -49,10 +49,10 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
size_t slice_size) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_endpoint_test_fixture f;
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("endpoint_pair_test");
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("endpoint_pair_test");
grpc_endpoint_pair p =
- grpc_iomgr_create_endpoint_pair("test", buffer_pool, slice_size);
- grpc_buffer_pool_unref(buffer_pool);
+ grpc_iomgr_create_endpoint_pair("test", resource_quota, slice_size);
+ grpc_resource_quota_unref(resource_quota);
f.client_ep = p.client;
f.server_ep = p.server;
diff --git a/test/core/iomgr/fd_conservation_posix_test.c b/test/core/iomgr/fd_conservation_posix_test.c
index f3a36c78e4..652b37eb6f 100644
--- a/test/core/iomgr/fd_conservation_posix_test.c
+++ b/test/core/iomgr/fd_conservation_posix_test.c
@@ -52,18 +52,18 @@ int main(int argc, char **argv) {
of descriptors */
rlim.rlim_cur = rlim.rlim_max = 10;
GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim));
- grpc_buffer_pool *buffer_pool =
- grpc_buffer_pool_create("fd_conservation_posix_test");
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("fd_conservation_posix_test");
for (i = 0; i < 100; i++) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- p = grpc_iomgr_create_endpoint_pair("test", buffer_pool, 1);
+ p = grpc_iomgr_create_endpoint_pair("test", resource_quota, 1);
grpc_endpoint_destroy(&exec_ctx, p.client);
grpc_endpoint_destroy(&exec_ctx, p.server);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(buffer_pool);
+ grpc_resource_quota_unref(resource_quota);
grpc_iomgr_shutdown();
return 0;
diff --git a/test/core/iomgr/buffer_pool_test.c b/test/core/iomgr/resource_quota_test.c
index 3a58fc73ae..5963ed089b 100644
--- a/test/core/iomgr/buffer_pool_test.c
+++ b/test/core/iomgr/resource_quota_test.c
@@ -31,7 +31,7 @@
*
*/
-#include "src/core/lib/iomgr/buffer_pool.h"
+#include "src/core/lib/iomgr/resource_quota.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -49,23 +49,23 @@ grpc_closure *set_bool(bool *p) { return grpc_closure_create(set_bool_cb, p); }
typedef struct {
size_t size;
- grpc_buffer_user *buffer_user;
+ grpc_resource_user *resource_user;
grpc_closure *then;
} reclaimer_args;
static void reclaimer_cb(grpc_exec_ctx *exec_ctx, void *args,
grpc_error *error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
reclaimer_args *a = args;
- grpc_buffer_user_free(exec_ctx, a->buffer_user, a->size);
- grpc_buffer_user_finish_reclaimation(exec_ctx, a->buffer_user);
+ grpc_resource_user_free(exec_ctx, a->resource_user, a->size);
+ grpc_resource_user_finish_reclaimation(exec_ctx, a->resource_user);
grpc_closure_run(exec_ctx, a->then, GRPC_ERROR_NONE);
gpr_free(a);
}
-grpc_closure *make_reclaimer(grpc_buffer_user *buffer_user, size_t size,
+grpc_closure *make_reclaimer(grpc_resource_user *resource_user, size_t size,
grpc_closure *then) {
reclaimer_args *a = gpr_malloc(sizeof(*a));
a->size = size;
- a->buffer_user = buffer_user;
+ a->resource_user = resource_user;
a->then = then;
return grpc_closure_create(reclaimer_cb, a);
}
@@ -79,214 +79,219 @@ grpc_closure *make_unused_reclaimer(grpc_closure *then) {
return grpc_closure_create(unused_reclaimer_cb, then);
}
-static void destroy_user(grpc_buffer_user *usr) {
+static void destroy_user(grpc_resource_user *usr) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
bool done = false;
- grpc_buffer_user_shutdown(&exec_ctx, usr, set_bool(&done));
+ grpc_resource_user_shutdown(&exec_ctx, usr, set_bool(&done));
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(done);
- grpc_buffer_user_destroy(&exec_ctx, usr);
+ grpc_resource_user_destroy(&exec_ctx, usr);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_op(void) {
gpr_log(GPR_INFO, "** test_no_op **");
- grpc_buffer_pool_unref(grpc_buffer_pool_create("test_no_op"));
+ grpc_resource_quota_unref(grpc_resource_quota_create("test_no_op"));
}
static void test_resize_then_destroy(void) {
gpr_log(GPR_INFO, "** test_resize_then_destroy **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_resize_then_destroy");
- grpc_buffer_pool_resize(p, 1024 * 1024);
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_resize_then_destroy");
+ grpc_resource_quota_resize(p, 1024 * 1024);
+ grpc_resource_quota_unref(p);
}
-static void test_buffer_user_no_op(void) {
- gpr_log(GPR_INFO, "** test_buffer_user_no_op **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_buffer_user_no_op");
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
- grpc_buffer_pool_unref(p);
+static void test_resource_user_no_op(void) {
+ gpr_log(GPR_INFO, "** test_resource_user_no_op **");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_resource_user_no_op");
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_instant_alloc_then_free(void) {
gpr_log(GPR_INFO, "** test_instant_alloc_then_free **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_instant_alloc_then_free");
- grpc_buffer_pool_resize(p, 1024 * 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_instant_alloc_then_free");
+ grpc_resource_quota_resize(p, 1024 * 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, NULL);
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_instant_alloc_free_pair(void) {
gpr_log(GPR_INFO, "** test_instant_alloc_free_pair **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_instant_alloc_free_pair");
- grpc_buffer_pool_resize(p, 1024 * 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_instant_alloc_free_pair");
+ grpc_resource_quota_resize(p, 1024 * 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, NULL);
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, NULL);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_simple_async_alloc(void) {
gpr_log(GPR_INFO, "** test_simple_async_alloc **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_simple_async_alloc");
- grpc_buffer_pool_resize(p, 1024 * 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_simple_async_alloc");
+ grpc_resource_quota_resize(p, 1024 * 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_async_alloc_blocked_by_size(void) {
gpr_log(GPR_INFO, "** test_async_alloc_blocked_by_size **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_async_alloc_blocked_by_size");
- grpc_buffer_pool_resize(p, 1);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_async_alloc_blocked_by_size");
+ grpc_resource_quota_resize(p, 1);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
bool done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!done);
}
- grpc_buffer_pool_resize(p, 1024);
+ grpc_resource_quota_resize(p, 1024);
GPR_ASSERT(done);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_scavenge(void) {
gpr_log(GPR_INFO, "** test_scavenge **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_scavenge");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr1;
- grpc_buffer_user usr2;
- grpc_buffer_user_init(&usr1, p, "usr1");
- grpc_buffer_user_init(&usr2, p, "usr2");
+ grpc_resource_quota *p = grpc_resource_quota_create("test_scavenge");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr1;
+ grpc_resource_user usr2;
+ grpc_resource_user_init(&usr1, p, "usr1");
+ grpc_resource_user_init(&usr2, p, "usr2");
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr1, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr1, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr2, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr2, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr1);
destroy_user(&usr2);
}
static void test_scavenge_blocked(void) {
gpr_log(GPR_INFO, "** test_scavenge_blocked **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_scavenge_blocked");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr1;
- grpc_buffer_user usr2;
- grpc_buffer_user_init(&usr1, p, "usr1");
- grpc_buffer_user_init(&usr2, p, "usr2");
+ grpc_resource_quota *p = grpc_resource_quota_create("test_scavenge_blocked");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr1;
+ grpc_resource_user usr2;
+ grpc_resource_user_init(&usr1, p, "usr1");
+ grpc_resource_user_init(&usr2, p, "usr2");
bool done;
{
done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr1, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr1, 1024);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr2, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr2, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr1);
destroy_user(&usr2);
}
static void test_blocked_until_scheduled_reclaim(void) {
gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_blocked_until_scheduled_reclaim");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_blocked_until_scheduled_reclaim");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
bool reclaim_done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, false,
make_reclaimer(&usr, 1024, set_bool(&reclaim_done)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -294,40 +299,40 @@ static void test_blocked_until_scheduled_reclaim(void) {
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(reclaim_done);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim_and_scavenge **");
- grpc_buffer_pool *p = grpc_buffer_pool_create(
+ grpc_resource_quota *p = grpc_resource_quota_create(
"test_blocked_until_scheduled_reclaim_and_scavenge");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr1;
- grpc_buffer_user usr2;
- grpc_buffer_user_init(&usr1, p, "usr1");
- grpc_buffer_user_init(&usr2, p, "usr2");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr1;
+ grpc_resource_user usr2;
+ grpc_resource_user_init(&usr1, p, "usr1");
+ grpc_resource_user_init(&usr2, p, "usr2");
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr1, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
bool reclaim_done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr1, false,
make_reclaimer(&usr1, 1024, set_bool(&reclaim_done)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -335,39 +340,39 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr2, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(reclaim_done);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr2, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr2, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr1);
destroy_user(&usr2);
}
static void test_blocked_until_scheduled_destructive_reclaim(void) {
gpr_log(GPR_INFO, "** test_blocked_until_scheduled_destructive_reclaim **");
- grpc_buffer_pool *p = grpc_buffer_pool_create(
+ grpc_resource_quota *p = grpc_resource_quota_create(
"test_blocked_until_scheduled_destructive_reclaim");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
bool reclaim_done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, true,
make_reclaimer(&usr, 1024, set_bool(&reclaim_done)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -375,41 +380,41 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(reclaim_done);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
}
static void test_unused_reclaim_is_cancelled(void) {
gpr_log(GPR_INFO, "** test_unused_reclaim_is_cancelled **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_unused_reclaim_is_cancelled");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_unused_reclaim_is_cancelled");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
bool benign_done = false;
bool destructive_done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, false, make_unused_reclaimer(set_bool(&benign_done)));
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, true,
make_unused_reclaimer(set_bool(&destructive_done)));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!benign_done);
GPR_ASSERT(!destructive_done);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
GPR_ASSERT(benign_done);
GPR_ASSERT(destructive_done);
@@ -417,26 +422,26 @@ static void test_unused_reclaim_is_cancelled(void) {
static void test_benign_reclaim_is_preferred(void) {
gpr_log(GPR_INFO, "** test_benign_reclaim_is_preferred **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_benign_reclaim_is_preferred");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_benign_reclaim_is_preferred");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
bool benign_done = false;
bool destructive_done = false;
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, false,
make_reclaimer(&usr, 1024, set_bool(&benign_done)));
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, true,
make_unused_reclaimer(set_bool(&destructive_done)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -446,7 +451,7 @@ static void test_benign_reclaim_is_preferred(void) {
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(benign_done);
GPR_ASSERT(!destructive_done);
@@ -454,10 +459,10 @@ static void test_benign_reclaim_is_preferred(void) {
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
GPR_ASSERT(benign_done);
GPR_ASSERT(destructive_done);
@@ -465,26 +470,26 @@ static void test_benign_reclaim_is_preferred(void) {
static void test_multiple_reclaims_can_be_triggered(void) {
gpr_log(GPR_INFO, "** test_multiple_reclaims_can_be_triggered **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_multiple_reclaims_can_be_triggered");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_multiple_reclaims_can_be_triggered");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
bool benign_done = false;
bool destructive_done = false;
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, false,
make_reclaimer(&usr, 512, set_bool(&benign_done)));
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, true,
make_reclaimer(&usr, 512, set_bool(&destructive_done)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -494,7 +499,7 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(benign_done);
GPR_ASSERT(destructive_done);
@@ -502,62 +507,62 @@ static void test_multiple_reclaims_can_be_triggered(void) {
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
destroy_user(&usr);
GPR_ASSERT(benign_done);
GPR_ASSERT(destructive_done);
}
-static void test_buffer_user_stays_allocated_until_memory_released(void) {
+static void test_resource_user_stays_allocated_until_memory_released(void) {
gpr_log(GPR_INFO,
- "** test_buffer_user_stays_allocated_until_memory_released **");
- grpc_buffer_pool *p = grpc_buffer_pool_create(
- "test_buffer_user_stays_allocated_until_memory_released");
- grpc_buffer_pool_resize(p, 1024 * 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ "** test_resource_user_stays_allocated_until_memory_released **");
+ grpc_resource_quota *p = grpc_resource_quota_create(
+ "test_resource_user_stays_allocated_until_memory_released");
+ grpc_resource_quota_resize(p, 1024 * 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
bool done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, NULL);
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_pool_unref(p);
- grpc_buffer_user_shutdown(&exec_ctx, &usr, set_bool(&done));
+ grpc_resource_quota_unref(p);
+ grpc_resource_user_shutdown(&exec_ctx, &usr, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_destroy(&exec_ctx, &usr);
+ grpc_resource_user_destroy(&exec_ctx, &usr);
grpc_exec_ctx_finish(&exec_ctx);
}
}
-static void test_pools_merged_on_buffer_user_deletion(void) {
- gpr_log(GPR_INFO, "** test_pools_merged_on_buffer_user_deletion **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_pools_merged_on_buffer_user_deletion");
- grpc_buffer_pool_resize(p, 1024);
+static void test_pools_merged_on_resource_user_deletion(void) {
+ gpr_log(GPR_INFO, "** test_pools_merged_on_resource_user_deletion **");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_pools_merged_on_resource_user_deletion");
+ grpc_resource_quota_resize(p, 1024);
for (int i = 0; i < 10; i++) {
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
bool done = false;
bool reclaimer_cancelled = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, false,
make_unused_reclaimer(set_bool(&reclaimer_cancelled)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -566,45 +571,45 @@ static void test_pools_merged_on_buffer_user_deletion(void) {
{
bool allocated = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(allocated);
GPR_ASSERT(!reclaimer_cancelled);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_shutdown(&exec_ctx, &usr, set_bool(&done));
+ grpc_resource_user_shutdown(&exec_ctx, &usr, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!done);
GPR_ASSERT(!reclaimer_cancelled);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(done);
GPR_ASSERT(reclaimer_cancelled);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_destroy(&exec_ctx, &usr);
+ grpc_resource_user_destroy(&exec_ctx, &usr);
grpc_exec_ctx_finish(&exec_ctx);
}
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
}
static void test_reclaimers_can_be_posted_repeatedly(void) {
gpr_log(GPR_INFO, "** test_reclaimers_can_be_posted_repeatedly **");
- grpc_buffer_pool *p =
- grpc_buffer_pool_create("test_reclaimers_can_be_posted_repeatedly");
- grpc_buffer_pool_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_reclaimers_can_be_posted_repeatedly");
+ grpc_resource_quota_resize(p, 1024);
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
{
bool allocated = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(allocated);
}
@@ -612,7 +617,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
bool reclaimer_done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_post_reclaimer(
+ grpc_resource_user_post_reclaimer(
&exec_ctx, &usr, false,
make_reclaimer(&usr, 1024, set_bool(&reclaimer_done)));
grpc_exec_ctx_finish(&exec_ctx);
@@ -621,7 +626,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
{
bool allocated = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
+ grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(allocated);
GPR_ASSERT(reclaimer_done);
@@ -629,25 +634,26 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_free(&exec_ctx, &usr, 1024);
+ grpc_resource_user_free(&exec_ctx, &usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
destroy_user(&usr);
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
}
static void test_one_slice(void) {
gpr_log(GPR_INFO, "** test_one_slice **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_one_slice");
- grpc_buffer_pool_resize(p, 1024);
+ grpc_resource_quota *p = grpc_resource_quota_create("test_one_slice");
+ grpc_resource_quota_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
- grpc_buffer_user_slice_allocator alloc;
+ grpc_resource_user_slice_allocator alloc;
int num_allocs = 0;
- grpc_buffer_user_slice_allocator_init(&alloc, &usr, inc_int_cb, &num_allocs);
+ grpc_resource_user_slice_allocator_init(&alloc, &usr, inc_int_cb,
+ &num_allocs);
gpr_slice_buffer buffer;
gpr_slice_buffer_init(&buffer);
@@ -655,28 +661,30 @@ static void test_one_slice(void) {
{
const int start_allocs = num_allocs;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
+ grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(num_allocs == start_allocs + 1);
}
gpr_slice_buffer_destroy(&buffer);
destroy_user(&usr);
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
}
static void test_one_slice_deleted_late(void) {
gpr_log(GPR_INFO, "** test_one_slice_deleted_late **");
- grpc_buffer_pool *p = grpc_buffer_pool_create("test_one_slice_deleted_late");
- grpc_buffer_pool_resize(p, 1024);
+ grpc_resource_quota *p =
+ grpc_resource_quota_create("test_one_slice_deleted_late");
+ grpc_resource_quota_resize(p, 1024);
- grpc_buffer_user usr;
- grpc_buffer_user_init(&usr, p, "usr");
+ grpc_resource_user usr;
+ grpc_resource_user_init(&usr, p, "usr");
- grpc_buffer_user_slice_allocator alloc;
+ grpc_resource_user_slice_allocator alloc;
int num_allocs = 0;
- grpc_buffer_user_slice_allocator_init(&alloc, &usr, inc_int_cb, &num_allocs);
+ grpc_resource_user_slice_allocator_init(&alloc, &usr, inc_int_cb,
+ &num_allocs);
gpr_slice_buffer buffer;
gpr_slice_buffer_init(&buffer);
@@ -684,7 +692,7 @@ static void test_one_slice_deleted_late(void) {
{
const int start_allocs = num_allocs;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
+ grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(num_allocs == start_allocs + 1);
}
@@ -692,17 +700,17 @@ static void test_one_slice_deleted_late(void) {
bool done = false;
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_shutdown(&exec_ctx, &usr, set_bool(&done));
+ grpc_resource_user_shutdown(&exec_ctx, &usr, set_bool(&done));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(!done);
}
- grpc_buffer_pool_unref(p);
+ grpc_resource_quota_unref(p);
gpr_slice_buffer_destroy(&buffer);
GPR_ASSERT(done);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_buffer_user_destroy(&exec_ctx, &usr);
+ grpc_resource_user_destroy(&exec_ctx, &usr);
grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -712,7 +720,7 @@ int main(int argc, char **argv) {
grpc_init();
test_no_op();
test_resize_then_destroy();
- test_buffer_user_no_op();
+ test_resource_user_no_op();
test_instant_alloc_then_free();
test_instant_alloc_free_pair();
test_simple_async_alloc();
@@ -725,8 +733,8 @@ int main(int argc, char **argv) {
test_unused_reclaim_is_cancelled();
test_benign_reclaim_is_preferred();
test_multiple_reclaims_can_be_triggered();
- test_buffer_user_stays_allocated_until_memory_released();
- test_pools_merged_on_buffer_user_deletion();
+ test_resource_user_stays_allocated_until_memory_released();
+ test_pools_merged_on_resource_user_deletion();
test_reclaimers_can_be_posted_repeatedly();
test_one_slice();
test_one_slice_deleted_late();
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 04522b8ddf..3f2e19ffd8 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -176,10 +176,10 @@ static void read_test(size_t num_bytes, size_t slice_size) {
create_sockets(sv);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("read_test");
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), buffer_pool,
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("read_test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), resource_quota,
slice_size, "test");
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
@@ -226,10 +226,11 @@ static void large_read_test(size_t slice_size) {
create_sockets(sv);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("large_read_test");
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), buffer_pool,
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("large_read_test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), resource_quota,
slice_size, "test");
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
written_bytes = fill_socket(sv[0]);
@@ -364,10 +365,11 @@ static void write_test(size_t num_bytes, size_t slice_size) {
create_sockets(sv);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("write_test");
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), buffer_pool,
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("write_test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), resource_quota,
GRPC_TCP_DEFAULT_READ_SLICE_SIZE, "test");
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
state.ep = ep;
@@ -430,11 +432,12 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
create_sockets(sv);
- grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create("release_fd_test");
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), buffer_pool,
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("release_fd_test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), resource_quota,
slice_size, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
@@ -520,13 +523,13 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
create_sockets(sv);
- grpc_buffer_pool *buffer_pool =
- grpc_buffer_pool_create("tcp_posix_test_socketpair");
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("tcp_posix_test_socketpair");
f.client_ep = grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"),
- buffer_pool, slice_size, "test");
+ resource_quota, slice_size, "test");
f.server_ep = grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"),
- buffer_pool, slice_size, "test");
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ resource_quota, slice_size, "test");
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index 3397c9563e..2262fde98d 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -56,10 +56,10 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
grpc_endpoint_test_fixture f;
grpc_endpoint_pair tcp;
- grpc_buffer_pool *buffer_pool =
- grpc_buffer_pool_create("secure_endpoint_test");
- tcp = grpc_iomgr_create_endpoint_pair("fixture", buffer_pool, slice_size);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("secure_endpoint_test");
+ tcp = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, slice_size);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset);
grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset);
diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c
index a70de7678c..2b041a4484 100644
--- a/test/core/util/mock_endpoint.c
+++ b/test/core/util/mock_endpoint.c
@@ -46,7 +46,7 @@ typedef struct grpc_mock_endpoint {
gpr_slice_buffer read_buffer;
gpr_slice_buffer *on_read_out;
grpc_closure *on_read;
- grpc_buffer_user buffer_user;
+ grpc_resource_user resource_user;
} grpc_mock_endpoint;
static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
@@ -83,7 +83,7 @@ static void unref(grpc_exec_ctx *exec_ctx, grpc_mock_endpoint *m) {
if (0 == --m->refs) {
gpr_mu_unlock(&m->mu);
gpr_slice_buffer_destroy(&m->read_buffer);
- grpc_buffer_user_destroy(exec_ctx, &m->buffer_user);
+ grpc_resource_user_destroy(exec_ctx, &m->resource_user);
gpr_free(m);
} else {
gpr_mu_unlock(&m->mu);
@@ -104,8 +104,8 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
GRPC_ERROR_CREATE("Endpoint Shutdown"), NULL);
m->on_read = NULL;
}
- grpc_buffer_user_shutdown(exec_ctx, &m->buffer_user,
- grpc_closure_create(me_finish_shutdown, m));
+ grpc_resource_user_shutdown(exec_ctx, &m->resource_user,
+ grpc_closure_create(me_finish_shutdown, m));
gpr_mu_unlock(&m->mu);
}
@@ -118,9 +118,9 @@ static char *me_get_peer(grpc_endpoint *ep) {
return gpr_strdup("fake:mock_endpoint");
}
-static grpc_buffer_user *me_get_buffer_user(grpc_endpoint *ep) {
+static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) {
grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
- return &m->buffer_user;
+ return &m->resource_user;
}
static grpc_workqueue *me_get_workqueue(grpc_endpoint *ep) { return NULL; }
@@ -133,18 +133,18 @@ static const grpc_endpoint_vtable vtable = {
me_add_to_pollset_set,
me_shutdown,
me_destroy,
- me_get_buffer_user,
+ me_get_resource_user,
me_get_peer,
};
grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice),
- grpc_buffer_pool *buffer_pool) {
+ grpc_resource_quota *resource_quota) {
grpc_mock_endpoint *m = gpr_malloc(sizeof(*m));
m->base.vtable = &vtable;
m->refs = 2;
char *name;
gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m);
- grpc_buffer_user_init(&m->buffer_user, buffer_pool, name);
+ grpc_resource_user_init(&m->resource_user, resource_quota, name);
gpr_free(name);
gpr_slice_buffer_init(&m->read_buffer);
gpr_mu_init(&m->mu);
diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h
index bb59a16f7a..b3a464ca01 100644
--- a/test/core/util/mock_endpoint.h
+++ b/test/core/util/mock_endpoint.h
@@ -37,7 +37,7 @@
#include "src/core/lib/iomgr/endpoint.h"
grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice),
- grpc_buffer_pool *buffer_pool);
+ grpc_resource_quota *resource_quota);
void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx,
grpc_endpoint *mock_endpoint, gpr_slice slice);
diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c
index a1aaeda916..85ed1c824c 100644
--- a/test/core/util/passthru_endpoint.c
+++ b/test/core/util/passthru_endpoint.c
@@ -46,7 +46,7 @@ typedef struct {
gpr_slice_buffer read_buffer;
gpr_slice_buffer *on_read_out;
grpc_closure *on_read;
- grpc_buffer_user buffer_user;
+ grpc_resource_user resource_user;
} half;
struct passthru_endpoint {
@@ -142,7 +142,7 @@ static void me_really_destroy(grpc_exec_ctx *exec_ctx, void *ep,
static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
half *m = (half *)ep;
- grpc_buffer_user_shutdown(exec_ctx, &m->buffer_user,
+ grpc_resource_user_shutdown(exec_ctx, &m->resource_user,
grpc_closure_create(me_really_destroy, m));
}
@@ -152,9 +152,9 @@ static char *me_get_peer(grpc_endpoint *ep) {
static grpc_workqueue *me_get_workqueue(grpc_endpoint *ep) { return NULL; }
-static grpc_buffer_user *me_get_buffer_user(grpc_endpoint *ep) {
+static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) {
half *m = (half *)ep;
- return &m->buffer_user;
+ return &m->resource_user;
}
static const grpc_endpoint_vtable vtable = {
@@ -165,12 +165,12 @@ static const grpc_endpoint_vtable vtable = {
me_add_to_pollset_set,
me_shutdown,
me_destroy,
- me_get_buffer_user,
+ me_get_resource_user,
me_get_peer,
};
static void half_init(half *m, passthru_endpoint *parent,
- grpc_buffer_pool *buffer_pool, const char *half_name) {
+ grpc_resource_quota *resource_quota, const char *half_name) {
m->base.vtable = &vtable;
m->parent = parent;
gpr_slice_buffer_init(&m->read_buffer);
@@ -178,18 +178,18 @@ static void half_init(half *m, passthru_endpoint *parent,
char *name;
gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name,
(intptr_t)parent);
- grpc_buffer_user_init(&m->buffer_user, buffer_pool, name);
+ grpc_resource_user_init(&m->resource_user, resource_quota, name);
gpr_free(name);
}
void grpc_passthru_endpoint_create(grpc_endpoint **client,
grpc_endpoint **server,
- grpc_buffer_pool *buffer_pool) {
+ grpc_resource_quota *resource_quota) {
passthru_endpoint *m = gpr_malloc(sizeof(*m));
m->halves = 2;
m->shutdown = 0;
- half_init(&m->client, m, buffer_pool, "client");
- half_init(&m->server, m, buffer_pool, "server");
+ half_init(&m->client, m, resource_quota, "client");
+ half_init(&m->server, m, resource_quota, "server");
gpr_mu_init(&m->mu);
*client = &m->client.base;
*server = &m->server.base;
diff --git a/test/core/util/passthru_endpoint.h b/test/core/util/passthru_endpoint.h
index 9756315084..b81ac5571c 100644
--- a/test/core/util/passthru_endpoint.h
+++ b/test/core/util/passthru_endpoint.h
@@ -38,6 +38,6 @@
void grpc_passthru_endpoint_create(grpc_endpoint **client,
grpc_endpoint **server,
- grpc_buffer_pool *buffer_pool);
+ grpc_resource_quota *resource_quota);
#endif
diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c
index f9e16ca407..b2342feeb4 100644
--- a/test/core/util/port_server_client.c
+++ b/test/core/util/port_server_client.c
@@ -99,12 +99,12 @@ void grpc_free_port_using_server(char *server, int port) {
req.http.path = path;
grpc_httpcli_context_init(&context);
- grpc_buffer_pool *buffer_pool =
- grpc_buffer_pool_create("port_server_client/free");
- grpc_httpcli_get(&exec_ctx, &context, &pr.pops, buffer_pool, &req,
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("port_server_client/free");
+ grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
grpc_closure_create(freed_port_from_server, &pr), &rsp);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(pr.mu);
while (!pr.done) {
grpc_pollset_worker *worker = NULL;
@@ -170,13 +170,13 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
req.http.path = "/get";
grpc_http_response_destroy(&pr->response);
memset(&pr->response, 0, sizeof(pr->response));
- grpc_buffer_pool *buffer_pool =
- grpc_buffer_pool_create("port_server_client/pick_retry");
- grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, buffer_pool, &req,
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("port_server_client/pick_retry");
+ grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
grpc_closure_create(got_port_from_server, pr),
&pr->response);
- grpc_buffer_pool_internal_unref(exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(exec_ctx, resource_quota);
return;
}
GPR_ASSERT(response);
@@ -217,13 +217,13 @@ int grpc_pick_port_using_server(char *server) {
req.http.path = "/get";
grpc_httpcli_context_init(&context);
- grpc_buffer_pool *buffer_pool =
- grpc_buffer_pool_create("port_server_client/pick");
- grpc_httpcli_get(&exec_ctx, &context, &pr.pops, buffer_pool, &req,
+ grpc_resource_quota *resource_quota =
+ grpc_resource_quota_create("port_server_client/pick");
+ grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10),
grpc_closure_create(got_port_from_server, &pr),
&pr.response);
- grpc_buffer_pool_internal_unref(&exec_ctx, buffer_pool);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 17e6d248b5..a94ed4d8da 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -34,10 +34,10 @@
#include <mutex>
#include <thread>
-#include <grpc++/buffer_pool.h>
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
#include <grpc++/create_channel.h>
+#include <grpc++/resource_quota.h>
#include <grpc++/security/auth_metadata_processor.h>
#include <grpc++/security/credentials.h>
#include <grpc++/security/server_credentials.h>
@@ -1481,19 +1481,20 @@ TEST_P(SecureEnd2endTest, ClientAuthContext) {
}
}
-class BufferPoolEnd2endTest : public End2endTest {
+class ResourceQuotaEnd2endTest : public End2endTest {
public:
- BufferPoolEnd2endTest() : server_buffer_pool_("server_buffer_pool") {}
+ ResourceQuotaEnd2endTest()
+ : server_resource_quota_("server_resource_quota") {}
virtual void ConfigureServerBuilder(ServerBuilder* builder) GRPC_OVERRIDE {
- builder->SetBufferPool(server_buffer_pool_);
+ builder->SetResourceQuota(server_resource_quota_);
}
private:
- BufferPool server_buffer_pool_;
+ ResourceQuota server_resource_quota_;
};
-TEST_P(BufferPoolEnd2endTest, SimpleRequest) {
+TEST_P(ResourceQuotaEnd2endTest, SimpleRequest) {
ResetStub();
EchoRequest request;
@@ -1543,7 +1544,7 @@ INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(false, false,
true)));
-INSTANTIATE_TEST_CASE_P(BufferPoolEnd2end, BufferPoolEnd2endTest,
+INSTANTIATE_TEST_CASE_P(ResourceQuotaEnd2end, ResourceQuotaEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(false, true,
true)));
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 3d2ac78868..b2529a1121 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -37,8 +37,8 @@
#include <mutex>
#include <thread>
-#include <grpc++/buffer_pool.h>
#include <grpc++/generic/async_generic_service.h>
+#include <grpc++/resource_quota.h>
#include <grpc++/security/server_credentials.h>
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
@@ -96,9 +96,9 @@ class AsyncQpsServerTest : public Server {
srv_cqs_.emplace_back(builder.AddCompletionQueue());
}
- if (config.buffer_pool_size() > 0) {
- builder.SetBufferPool(
- BufferPool("AsyncQpsServerTest").Resize(config.buffer_pool_size()));
+ if (config.resource_quota_size() > 0) {
+ builder.SetResourceQuota(ResourceQuota("AsyncQpsServerTest")
+ .Resize(config.resource_quota_size()));
}
server_ = builder.BuildAndStart();
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index 97f709b714..96f50a35ac 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -33,7 +33,7 @@
#include <thread>
-#include <grpc++/buffer_pool.h>
+#include <grpc++/resource_quota.h>
#include <grpc++/security/server_credentials.h>
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
@@ -94,9 +94,9 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server {
Server::CreateServerCredentials(config));
gpr_free(server_address);
- if (config.buffer_pool_size() > 0) {
- builder.SetBufferPool(
- BufferPool("AsyncQpsServerTest").Resize(config.buffer_pool_size()));
+ if (config.resource_quota_size() > 0) {
+ builder.SetResourceQuota(ResourceQuota("AsyncQpsServerTest")
+ .Resize(config.resource_quota_size()));
}
builder.RegisterService(&service_);