From ef6b97659edb575a002d574db89d90f7ebf4b979 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 28 Sep 2016 08:37:51 -0700 Subject: Add tracing, fix some transport bugs wrt buffer_pools --- test/core/util/mock_endpoint.c | 12 +++++++++--- test/core/util/passthru_endpoint.c | 16 +++++++++++----- test/core/util/port_server_client.c | 11 ++++++++--- 3 files changed, 28 insertions(+), 11 deletions(-) (limited to 'test/core/util') diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c index dcb4e5896f..a70de7678c 100644 --- a/test/core/util/mock_endpoint.c +++ b/test/core/util/mock_endpoint.c @@ -33,6 +33,8 @@ #include "test/core/util/mock_endpoint.h" +#include + #include #include @@ -88,7 +90,8 @@ static void unref(grpc_exec_ctx *exec_ctx, grpc_mock_endpoint *m) { } } -static void me_finish_shutdown(grpc_exec_ctx *exec_ctx, void *me, grpc_error *error) { +static void me_finish_shutdown(grpc_exec_ctx *exec_ctx, void *me, + grpc_error *error) { grpc_mock_endpoint *m = me; unref(exec_ctx, m); } @@ -108,7 +111,7 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; - unref(exec_ctx,m); + unref(exec_ctx, m); } static char *me_get_peer(grpc_endpoint *ep) { @@ -139,7 +142,10 @@ grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice), grpc_mock_endpoint *m = gpr_malloc(sizeof(*m)); m->base.vtable = &vtable; m->refs = 2; - grpc_buffer_user_init(&m->buffer_user, buffer_pool); + char *name; + gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m); + grpc_buffer_user_init(&m->buffer_user, buffer_pool, name); + gpr_free(name); gpr_slice_buffer_init(&m->read_buffer); gpr_mu_init(&m->mu); m->on_write = on_write; diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c index bdf75ce587..a1aaeda916 100644 --- a/test/core/util/passthru_endpoint.c +++ b/test/core/util/passthru_endpoint.c @@ -33,6 +33,8 @@ #include "test/core/util/passthru_endpoint.h" +#include + #include #include @@ -141,7 +143,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_closure_create(me_really_destroy, m)); + grpc_closure_create(me_really_destroy, m)); } static char *me_get_peer(grpc_endpoint *ep) { @@ -168,12 +170,16 @@ static const grpc_endpoint_vtable vtable = { }; static void half_init(half *m, passthru_endpoint *parent, - grpc_buffer_pool *buffer_pool) { + grpc_buffer_pool *buffer_pool, const char *half_name) { m->base.vtable = &vtable; m->parent = parent; gpr_slice_buffer_init(&m->read_buffer); m->on_read = NULL; - grpc_buffer_user_init(&m->buffer_user, buffer_pool); + char *name; + gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name, + (intptr_t)parent); + grpc_buffer_user_init(&m->buffer_user, buffer_pool, name); + gpr_free(name); } void grpc_passthru_endpoint_create(grpc_endpoint **client, @@ -182,8 +188,8 @@ void grpc_passthru_endpoint_create(grpc_endpoint **client, passthru_endpoint *m = gpr_malloc(sizeof(*m)); m->halves = 2; m->shutdown = 0; - half_init(&m->client, m, buffer_pool); - half_init(&m->server, m, buffer_pool); + half_init(&m->client, m, buffer_pool, "client"); + half_init(&m->server, m, buffer_pool, "server"); gpr_mu_init(&m->mu); *client = &m->client.base; *server = &m->server.base; diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index dd444236e9..9bd34677cb 100644 --- a/test/core/util/port_server_client.c +++ b/test/core/util/port_server_client.c @@ -49,6 +49,8 @@ #include "src/core/lib/http/httpcli.h" +int grpc_buffer_pool_trace = 0; + typedef struct freereq { gpr_mu *mu; grpc_polling_entity pops; @@ -99,7 +101,8 @@ 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(); + 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_TIMEOUT_SECONDS_TO_DEADLINE(10), grpc_closure_create(freed_port_from_server, &pr), &rsp); @@ -169,7 +172,8 @@ 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(); + 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_TIMEOUT_SECONDS_TO_DEADLINE(10), grpc_closure_create(got_port_from_server, pr), @@ -215,7 +219,8 @@ 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(); + 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_TIMEOUT_SECONDS_TO_DEADLINE(10), grpc_closure_create(got_port_from_server, &pr), -- cgit v1.2.3