aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/census/grpc_context.c4
-rw-r--r--src/core/client_config/resolvers/zookeeper_resolver.c2
-rw-r--r--src/core/client_config/subchannel.h8
-rw-r--r--src/core/compression/algorithm.c13
-rw-r--r--src/core/iomgr/pollset_posix.c6
-rw-r--r--src/core/iomgr/tcp_client_posix.c14
-rw-r--r--src/core/security/credentials.c45
-rw-r--r--src/core/security/google_default_credentials.c4
-rw-r--r--src/core/security/security_context.c24
-rw-r--r--src/core/security/server_secure_chttp2.c6
-rw-r--r--src/core/surface/api_trace.c (renamed from src/core/surface/surface_trace.c)4
-rw-r--r--src/core/surface/api_trace.h65
-rw-r--r--src/core/surface/call.c13
-rw-r--r--src/core/surface/call.h10
-rw-r--r--src/core/surface/call_details.c4
-rw-r--r--src/core/surface/call_log_batch.c2
-rw-r--r--src/core/surface/channel.c24
-rw-r--r--src/core/surface/channel_connectivity.c12
-rw-r--r--src/core/surface/channel_create.c4
-rw-r--r--src/core/surface/completion_queue.c18
-rw-r--r--src/core/surface/init.c8
-rw-r--r--src/core/surface/lame_client.c5
-rw-r--r--src/core/surface/metadata_array.c4
-rw-r--r--src/core/surface/secure_channel_create.c6
-rw-r--r--src/core/surface/server.c28
-rw-r--r--src/core/surface/server_chttp2.c4
-rw-r--r--src/core/surface/server_create.c3
-rw-r--r--src/core/surface/surface_trace.h5
-rw-r--r--src/core/surface/version.c4
-rw-r--r--src/core/transport/chttp2_transport.c2
30 files changed, 324 insertions, 27 deletions
diff --git a/src/core/census/grpc_context.c b/src/core/census/grpc_context.c
index 429f3ec9db..4b61382a2c 100644
--- a/src/core/census/grpc_context.c
+++ b/src/core/census/grpc_context.c
@@ -33,9 +33,12 @@
#include <grpc/census.h>
#include <grpc/grpc.h>
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
void grpc_census_call_set_context(grpc_call *call, census_context *context) {
+ GRPC_API_TRACE("grpc_census_call_set_context(call=%p, census_context=%p)", 2,
+ (call, context));
if (census_enabled() == CENSUS_FEATURE_NONE) {
return;
}
@@ -45,5 +48,6 @@ void grpc_census_call_set_context(grpc_call *call, census_context *context) {
}
census_context *grpc_census_call_get_context(grpc_call *call) {
+ GRPC_API_TRACE("grpc_census_call_get_context(call=%p)", 1, (call));
return (census_context *)grpc_call_context_get(call, GRPC_CONTEXT_TRACING);
}
diff --git a/src/core/client_config/resolvers/zookeeper_resolver.c b/src/core/client_config/resolvers/zookeeper_resolver.c
index f640a0084a..136197d4c6 100644
--- a/src/core/client_config/resolvers/zookeeper_resolver.c
+++ b/src/core/client_config/resolvers/zookeeper_resolver.c
@@ -45,6 +45,7 @@
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/support/string.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/json/json.h"
/** Zookeeper session expiration time in milliseconds */
@@ -487,6 +488,7 @@ static void zookeeper_plugin_init() {
}
void grpc_zookeeper_register() {
+ GRPC_API_TRACE("grpc_zookeeper_register(void)", 0, ());
grpc_register_plugin(zookeeper_plugin_init, NULL);
}
diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h
index 03e7cd0590..86b7fa5851 100644
--- a/src/core/client_config/subchannel.h
+++ b/src/core/client_config/subchannel.h
@@ -64,13 +64,13 @@ typedef struct grpc_subchannel_args grpc_subchannel_args;
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS
#endif
-void grpc_subchannel_ref(
- grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_ref(grpc_subchannel *channel
+ GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_call_ref(
- grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_call_ref(grpc_subchannel_call *call
+ GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel_call *call
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
diff --git a/src/core/compression/algorithm.c b/src/core/compression/algorithm.c
index 8adde13b1e..d55e499f5e 100644
--- a/src/core/compression/algorithm.c
+++ b/src/core/compression/algorithm.c
@@ -37,12 +37,19 @@
#include <grpc/compression.h>
#include <grpc/support/useful.h>
+#include "src/core/surface/api_trace.h"
+
int grpc_compression_algorithm_parse(const char *name, size_t name_length,
grpc_compression_algorithm *algorithm) {
/* we use strncmp not only because it's safer (even though in this case it
* doesn't matter, given that we are comparing against string literals, but
* because this way we needn't have "name" nil-terminated (useful for slice
* data, for example) */
+ GRPC_API_TRACE(
+ "grpc_compression_algorithm_parse("
+ "name=%*.*s, name_length=%lu, algorithm=%p)",
+ 5, ((int)name_length, (int)name_length, name, (unsigned long)name_length,
+ algorithm));
if (name_length == 0) {
return 0;
}
@@ -60,6 +67,8 @@ int grpc_compression_algorithm_parse(const char *name, size_t name_length,
int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm,
char **name) {
+ GRPC_API_TRACE("grpc_compression_algorithm_parse(algorithm=%d, name=%p)", 2,
+ ((int)algorithm, name));
switch (algorithm) {
case GRPC_COMPRESS_NONE:
*name = "identity";
@@ -80,6 +89,8 @@ int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm,
* compression algorithms */
grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level) {
+ GRPC_API_TRACE("grpc_compression_algorithm_for_level(level=%d)", 1,
+ ((int)level));
switch (level) {
case GRPC_COMPRESS_LEVEL_NONE:
return GRPC_COMPRESS_NONE;
@@ -96,6 +107,8 @@ grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level grpc_compression_level_for_algorithm(
grpc_compression_algorithm algorithm) {
grpc_compression_level clevel;
+ GRPC_API_TRACE("grpc_compression_level_for_algorithm(algorithm=%d)", 1,
+ ((int)algorithm));
for (clevel = GRPC_COMPRESS_LEVEL_NONE; clevel < GRPC_COMPRESS_LEVEL_COUNT;
++clevel) {
if (grpc_compression_algorithm_for_level(clevel) == algorithm) {
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index 4ba1bda1a9..42ee407938 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -352,6 +352,7 @@ static void basic_do_promote(grpc_exec_ctx *exec_ctx, void *args, int success) {
if (pollset->shutting_down) {
/* We don't care about this pollset anymore. */
if (pollset->in_flight_cbs == 0 && !pollset->called_shutdown) {
+ pollset->called_shutdown = 1;
finish_shutdown(exec_ctx, pollset);
}
} else if (grpc_fd_is_orphaned(fd)) {
@@ -476,6 +477,7 @@ static void basic_pollset_maybe_work_and_unlock(grpc_exec_ctx *exec_ctx,
if (fd) {
pfd[2].fd = fd->fd;
pfd[2].revents = 0;
+ GRPC_FD_REF(fd, "basicpoll_begin");
gpr_mu_unlock(&pollset->mu);
pfd[2].events =
(short)grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher);
@@ -522,6 +524,10 @@ static void basic_pollset_maybe_work_and_unlock(grpc_exec_ctx *exec_ctx,
}
}
}
+
+ if (fd) {
+ GRPC_FD_UNREF(fd, "basicpoll_begin");
+ }
}
static void basic_pollset_destroy(grpc_pollset *pollset) {
diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c
index 037964a97c..073c760c91 100644
--- a/src/core/iomgr/tcp_client_posix.c
+++ b/src/core/iomgr/tcp_client_posix.c
@@ -141,7 +141,8 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, int success) {
err = getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &so_error, &so_error_size);
} while (err < 0 && errno == EINTR);
if (err < 0) {
- gpr_log(GPR_ERROR, "getsockopt(ERROR): %s", strerror(errno));
+ gpr_log(GPR_ERROR, "failed to connect to '%s': getsockopt(ERROR): %s",
+ ac->addr_str, strerror(errno));
goto finish;
} else if (so_error != 0) {
if (so_error == ENOBUFS) {
@@ -166,10 +167,14 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, int success) {
} else {
switch (so_error) {
case ECONNREFUSED:
- gpr_log(GPR_ERROR, "socket error: connection refused");
+ gpr_log(
+ GPR_ERROR,
+ "failed to connect to '%s': socket error: connection refused",
+ ac->addr_str);
break;
default:
- gpr_log(GPR_ERROR, "socket error: %d", so_error);
+ gpr_log(GPR_ERROR, "failed to connect to '%s': socket error: %d",
+ ac->addr_str, so_error);
break;
}
goto finish;
@@ -181,7 +186,8 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, int success) {
goto finish;
}
} else {
- gpr_log(GPR_ERROR, "on_writable failed during connect");
+ gpr_log(GPR_ERROR, "failed to connect to '%s': timeout occurred",
+ ac->addr_str);
goto finish;
}
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index bdd9ab8e9c..398db20e8c 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -41,6 +41,7 @@
#include "src/core/json/json.h"
#include "src/core/httpcli/httpcli.h"
#include "src/core/iomgr/iomgr.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
@@ -91,6 +92,7 @@ void grpc_credentials_unref(grpc_credentials *creds) {
}
void grpc_credentials_release(grpc_credentials *creds) {
+ GRPC_API_TRACE("grpc_credentials_release(creds=%p)", 1, (creds));
grpc_credentials_unref(creds);
}
@@ -152,6 +154,7 @@ void grpc_server_credentials_unref(grpc_server_credentials *creds) {
}
void grpc_server_credentials_release(grpc_server_credentials *creds) {
+ GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
grpc_server_credentials_unref(creds);
}
@@ -166,6 +169,11 @@ grpc_security_status grpc_server_credentials_create_security_connector(
void grpc_server_credentials_set_auth_metadata_processor(
grpc_server_credentials *creds, grpc_auth_metadata_processor processor) {
+ GRPC_API_TRACE(
+ "grpc_server_credentials_set_auth_metadata_processor("
+ "creds=%p, "
+ "processor=grpc_auth_metadata_processor { process: %lx, state: %p })",
+ 3, (creds, (unsigned long)processor.process, processor.state));
if (creds == NULL) return;
if (creds->processor.destroy != NULL && creds->processor.state != NULL) {
creds->processor.destroy(creds->processor.state);
@@ -317,6 +325,11 @@ grpc_credentials *grpc_ssl_credentials_create(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
void *reserved) {
grpc_ssl_credentials *c = gpr_malloc(sizeof(grpc_ssl_credentials));
+ GRPC_API_TRACE(
+ "grpc_ssl_credentials_create(pem_root_certs=%s, "
+ "pem_key_cert_pair=%p, "
+ "reserved=%p)",
+ 3, (pem_root_certs, pem_key_cert_pair, reserved));
GPR_ASSERT(reserved == NULL);
memset(c, 0, sizeof(grpc_ssl_credentials));
c->base.type = GRPC_CREDENTIALS_TYPE_SSL;
@@ -331,6 +344,12 @@ grpc_server_credentials *grpc_ssl_server_credentials_create(
size_t num_key_cert_pairs, int force_client_auth, void *reserved) {
grpc_ssl_server_credentials *c =
gpr_malloc(sizeof(grpc_ssl_server_credentials));
+ GRPC_API_TRACE(
+ "grpc_ssl_server_credentials_create("
+ "pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, "
+ "force_client_auth=%d, reserved=%p)",
+ 5, (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs,
+ force_client_auth, reserved));
GPR_ASSERT(reserved == NULL);
memset(c, 0, sizeof(grpc_ssl_server_credentials));
c->base.type = GRPC_CREDENTIALS_TYPE_SSL;
@@ -449,6 +468,14 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
grpc_credentials *grpc_service_account_jwt_access_credentials_create(
const char *json_key, gpr_timespec token_lifetime, void *reserved) {
+ GRPC_API_TRACE(
+ "grpc_service_account_jwt_access_credentials_create("
+ "json_key=%s, "
+ "token_lifetime="
+ "gpr_timespec { tv_sec: %ld, tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 5, (json_key, (long)token_lifetime.tv_sec, token_lifetime.tv_nsec,
+ (int)token_lifetime.clock_type, reserved));
GPR_ASSERT(reserved == NULL);
return grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
grpc_auth_json_key_create_from_string(json_key), token_lifetime);
@@ -659,6 +686,8 @@ grpc_credentials *grpc_google_compute_engine_credentials_create(
void *reserved) {
grpc_oauth2_token_fetcher_credentials *c =
gpr_malloc(sizeof(grpc_oauth2_token_fetcher_credentials));
+ GRPC_API_TRACE("grpc_compute_engine_credentials_create(reserved=%p)", 1,
+ (reserved));
GPR_ASSERT(reserved == NULL);
init_oauth2_token_fetcher(c, compute_engine_fetch_oauth2);
c->base.vtable = &compute_engine_vtable;
@@ -720,6 +749,10 @@ grpc_credentials *grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_credentials *grpc_google_refresh_token_credentials_create(
const char *json_refresh_token, void *reserved) {
+ GRPC_API_TRACE(
+ "grpc_refresh_token_credentials_create(json_refresh_token=%s, "
+ "reserved=%p)",
+ 2, (json_refresh_token, reserved));
GPR_ASSERT(reserved == NULL);
return grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_auth_refresh_token_create_from_string(json_refresh_token));
@@ -820,6 +853,10 @@ grpc_credentials *grpc_access_token_credentials_create(const char *access_token,
grpc_access_token_credentials *c =
gpr_malloc(sizeof(grpc_access_token_credentials));
char *token_md_value;
+ GRPC_API_TRACE(
+ "grpc_access_token_credentials_create(access_token=%s, "
+ "reserved=%p)",
+ 2, (access_token, reserved));
GPR_ASSERT(reserved == NULL);
memset(c, 0, sizeof(grpc_access_token_credentials));
c->base.type = GRPC_CREDENTIALS_TYPE_OAUTH2;
@@ -1056,6 +1093,10 @@ grpc_credentials *grpc_composite_credentials_create(grpc_credentials *creds1,
grpc_credentials_array creds1_array;
grpc_credentials_array creds2_array;
grpc_composite_credentials *c;
+ GRPC_API_TRACE(
+ "grpc_composite_credentials_create(creds1=%p, creds2=%p, "
+ "reserved=%p)",
+ 3, (creds1, creds2, reserved));
GPR_ASSERT(reserved == NULL);
GPR_ASSERT(creds1 != NULL);
GPR_ASSERT(creds2 != NULL);
@@ -1158,6 +1199,10 @@ static grpc_credentials_vtable iam_vtable = {
grpc_credentials *grpc_google_iam_credentials_create(
const char *token, const char *authority_selector, void *reserved) {
grpc_google_iam_credentials *c;
+ GRPC_API_TRACE(
+ "grpc_iam_credentials_create(token=%s, authority_selector=%s, "
+ "reserved=%p)",
+ 3, (token, authority_selector, reserved));
GPR_ASSERT(reserved == NULL);
GPR_ASSERT(token != NULL);
GPR_ASSERT(authority_selector != NULL);
diff --git a/src/core/security/google_default_credentials.c b/src/core/security/google_default_credentials.c
index 7b85842808..45135305b2 100644
--- a/src/core/security/google_default_credentials.c
+++ b/src/core/security/google_default_credentials.c
@@ -42,6 +42,7 @@
#include "src/core/httpcli/httpcli.h"
#include "src/core/support/env.h"
#include "src/core/support/file.h"
+#include "src/core/surface/api_trace.h"
/* -- Constants. -- */
@@ -178,6 +179,9 @@ end:
grpc_credentials *grpc_google_default_credentials_create(void) {
grpc_credentials *result = NULL;
int serving_cached_credentials = 0;
+
+ GRPC_API_TRACE("grpc_google_default_credentials_create(void)", 0, ());
+
gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_mu);
diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c
index 95d80ba122..fb905e0b22 100644
--- a/src/core/security/security_context.c
+++ b/src/core/security/security_context.c
@@ -34,6 +34,7 @@
#include <string.h>
#include "src/core/security/security_context.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
#include "src/core/support/string.h"
@@ -47,6 +48,8 @@
grpc_call_error grpc_call_set_credentials(grpc_call *call,
grpc_credentials *creds) {
grpc_client_security_context *ctx = NULL;
+ GRPC_API_TRACE("grpc_call_set_credentials(call=%p, creds=%p)", 2,
+ (call, creds));
if (!grpc_call_is_client(call)) {
gpr_log(GPR_ERROR, "Method is client-side only.");
return GRPC_CALL_ERROR_NOT_ON_SERVER;
@@ -71,6 +74,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call *call,
grpc_auth_context *grpc_call_auth_context(grpc_call *call) {
void *sec_ctx = grpc_call_context_get(call, GRPC_CONTEXT_SECURITY);
+ GRPC_API_TRACE("grpc_call_auth_context(call=%p)", 1, (call));
if (sec_ctx == NULL) return NULL;
return grpc_call_is_client(call)
? GRPC_AUTH_CONTEXT_REF(
@@ -82,6 +86,7 @@ grpc_auth_context *grpc_call_auth_context(grpc_call *call) {
}
void grpc_auth_context_release(grpc_auth_context *context) {
+ GRPC_API_TRACE("grpc_auth_context_release(context=%p)", 1, (context));
GRPC_AUTH_CONTEXT_UNREF(context, "grpc_auth_context_unref");
}
@@ -174,6 +179,8 @@ void grpc_auth_context_unref(grpc_auth_context *ctx) {
const char *grpc_auth_context_peer_identity_property_name(
const grpc_auth_context *ctx) {
+ GRPC_API_TRACE("grpc_auth_context_peer_identity_property_name(ctx=%p)", 1,
+ (ctx));
return ctx->peer_identity_property_name;
}
@@ -182,6 +189,9 @@ int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context *ctx,
grpc_auth_property_iterator it =
grpc_auth_context_find_properties_by_name(ctx, name);
const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ GRPC_API_TRACE(
+ "grpc_auth_context_set_peer_identity_property_name(ctx=%p, name=%s)", 2,
+ (ctx, name));
if (prop == NULL) {
gpr_log(GPR_ERROR, "Property name %s not found in auth context.",
name != NULL ? name : "NULL");
@@ -192,12 +202,14 @@ int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context *ctx,
}
int grpc_auth_context_peer_is_authenticated(const grpc_auth_context *ctx) {
+ GRPC_API_TRACE("grpc_auth_context_peer_is_authenticated(ctx=%p)", 1, (ctx));
return ctx->peer_identity_property_name == NULL ? 0 : 1;
}
grpc_auth_property_iterator grpc_auth_context_property_iterator(
const grpc_auth_context *ctx) {
grpc_auth_property_iterator it = empty_iterator;
+ GRPC_API_TRACE("grpc_auth_context_property_iterator(ctx=%p)", 1, (ctx));
if (ctx == NULL) return it;
it.ctx = ctx;
return it;
@@ -205,6 +217,7 @@ grpc_auth_property_iterator grpc_auth_context_property_iterator(
const grpc_auth_property *grpc_auth_property_iterator_next(
grpc_auth_property_iterator *it) {
+ GRPC_API_TRACE("grpc_auth_property_iterator_next(it=%p)", 1, (it));
if (it == NULL || it->ctx == NULL) return NULL;
while (it->index == it->ctx->properties.count) {
if (it->ctx->chained == NULL) return NULL;
@@ -229,6 +242,8 @@ const grpc_auth_property *grpc_auth_property_iterator_next(
grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
const grpc_auth_context *ctx, const char *name) {
grpc_auth_property_iterator it = empty_iterator;
+ GRPC_API_TRACE("grpc_auth_context_find_properties_by_name(ctx=%p, name=%s)",
+ 2, (ctx, name));
if (ctx == NULL || name == NULL) return empty_iterator;
it.ctx = ctx;
it.name = name;
@@ -237,6 +252,7 @@ grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
grpc_auth_property_iterator grpc_auth_context_peer_identity(
const grpc_auth_context *ctx) {
+ GRPC_API_TRACE("grpc_auth_context_peer_identity(ctx=%p)", 1, (ctx));
if (ctx == NULL) return empty_iterator;
return grpc_auth_context_find_properties_by_name(
ctx, ctx->peer_identity_property_name);
@@ -255,6 +271,11 @@ static void ensure_auth_context_capacity(grpc_auth_context *ctx) {
void grpc_auth_context_add_property(grpc_auth_context *ctx, const char *name,
const char *value, size_t value_length) {
grpc_auth_property *prop;
+ GRPC_API_TRACE(
+ "grpc_auth_context_add_property(ctx=%p, name=%s, value=%*.*s, "
+ "value_length=%lu)",
+ 6, (ctx, name, (int)value_length, (int)value_length, value,
+ (unsigned long)value_length));
ensure_auth_context_capacity(ctx);
prop = &ctx->properties.array[ctx->properties.count++];
prop->name = gpr_strdup(name);
@@ -268,6 +289,9 @@ void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
const char *name,
const char *value) {
grpc_auth_property *prop;
+ GRPC_API_TRACE(
+ "grpc_auth_context_add_cstring_property(ctx=%p, name=%s, value=%s)", 3,
+ (ctx, name, value));
ensure_auth_context_capacity(ctx);
prop = &ctx->properties.array[ctx->properties.count++];
prop->name = gpr_strdup(name);
diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c
index a6c515dc34..881e44a3fe 100644
--- a/src/core/security/server_secure_chttp2.c
+++ b/src/core/security/server_secure_chttp2.c
@@ -44,6 +44,7 @@
#include "src/core/security/credentials.h"
#include "src/core/security/security_connector.h"
#include "src/core/security/security_context.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/server.h"
#include "src/core/transport/chttp2_transport.h"
#include <grpc/support/alloc.h>
@@ -222,6 +223,11 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
grpc_security_connector *sc = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE(
+ "grpc_server_add_secure_http2_port("
+ "server=%p, addr=%s, creds=%p)",
+ 3, (server, addr, creds));
+
/* create security context */
if (creds == NULL) goto error;
status = grpc_server_credentials_create_security_connector(creds, &sc);
diff --git a/src/core/surface/surface_trace.c b/src/core/surface/api_trace.c
index 57a0053162..9f0b900d46 100644
--- a/src/core/surface/surface_trace.c
+++ b/src/core/surface/api_trace.c
@@ -31,6 +31,6 @@
*
*/
-#include "src/core/surface/surface_trace.h"
+#include "src/core/surface/api_trace.h"
-int grpc_surface_trace = 0;
+int grpc_api_trace = 0;
diff --git a/src/core/surface/api_trace.h b/src/core/surface/api_trace.h
new file mode 100644
index 0000000000..82bbf3b62b
--- /dev/null
+++ b/src/core/surface/api_trace.h
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright 2015, 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.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CORE_SURFACE_API_TRACE_H
+#define GRPC_INTERNAL_CORE_SURFACE_API_TRACE_H
+
+#include "src/core/debug/trace.h"
+#include <grpc/support/log.h>
+
+extern int grpc_api_trace;
+
+/* Provide unwrapping macros because we're in C89 and variadic macros weren't
+ introduced until C99... */
+#define GRPC_API_TRACE_UNWRAP0()
+#define GRPC_API_TRACE_UNWRAP1(a) , a
+#define GRPC_API_TRACE_UNWRAP2(a, b) , a, b
+#define GRPC_API_TRACE_UNWRAP3(a, b, c) , a, b, c
+#define GRPC_API_TRACE_UNWRAP4(a, b, c, d) , a, b, c, d
+#define GRPC_API_TRACE_UNWRAP5(a, b, c, d, e) , a, b, c, d, e
+#define GRPC_API_TRACE_UNWRAP6(a, b, c, d, e, f) , a, b, c, d, e, f
+#define GRPC_API_TRACE_UNWRAP7(a, b, c, d, e, f, g) , a, b, c, d, e, f, g
+#define GRPC_API_TRACE_UNWRAP8(a, b, c, d, e, f, g, h) , a, b, c, d, e, f, g, h
+#define GRPC_API_TRACE_UNWRAP9(a, b, c, d, e, f, g, h, i) \
+ , a, b, c, d, e, f, g, h, i
+#define GRPC_API_TRACE_UNWRAP10(a, b, c, d, e, f, g, h, i, j) \
+ , a, b, c, d, e, f, g, h, i, j
+
+/* Due to the limitations of C89's preprocessor, the arity of the var-arg list
+ 'nargs' must be specified. */
+#define GRPC_API_TRACE(fmt, nargs, args) \
+ if (grpc_api_trace) { \
+ gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \
+ }
+
+#endif /* GRPC_INTERNAL_CORE_SURFACE_API_TRACE_H */
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 4aa3ac3cd3..08626108d0 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -45,6 +45,7 @@
#include "src/core/iomgr/timer.h"
#include "src/core/profiling/timers.h"
#include "src/core/support/string.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/byte_buffer_queue.h"
#include "src/core/surface/call.h"
#include "src/core/surface/channel.h"
@@ -1280,6 +1281,8 @@ void grpc_call_destroy(grpc_call *c) {
grpc_call *parent = c->parent;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_call_destroy(c=%p)", 1, (c));
+
if (parent) {
gpr_mu_lock(&parent->mu);
if (c == parent->first_child) {
@@ -1308,6 +1311,7 @@ void grpc_call_destroy(grpc_call *c) {
}
grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved) {
+ GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
GPR_ASSERT(!reserved);
return grpc_call_cancel_with_status(call, GRPC_STATUS_CANCELLED, "Cancelled",
NULL);
@@ -1319,6 +1323,10 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *c,
void *reserved) {
grpc_call_error r;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE(
+ "grpc_call_cancel_with_status("
+ "c=%p, status=%d, description=%s, reserved=%p)",
+ 4, (c, (int)status, description, reserved));
GPR_ASSERT(reserved == NULL);
lock(c);
r = cancel_with_status(c, status, description);
@@ -1386,6 +1394,7 @@ char *grpc_call_get_peer(grpc_call *call) {
grpc_call_element *elem = CALL_ELEM_FROM_CALL(call, 0);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
char *result = elem->filter->get_peer(&exec_ctx, elem);
+ GRPC_API_TRACE("grpc_call_get_peer(%p)", 1, (call));
grpc_exec_ctx_finish(&exec_ctx);
return result;
}
@@ -1580,6 +1589,10 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
grpc_call_error error;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE(
+ "grpc_call_start_batch(call=%p, ops=%p, nops=%lu, tag=%p, reserved=%p)",
+ 5, (call, ops, (unsigned long)nops, tag, reserved));
+
if (reserved != NULL) {
error = GRPC_CALL_ERROR;
goto done;
diff --git a/src/core/surface/call.h b/src/core/surface/call.h
index 7ac0c92ab7..f421a81619 100644
--- a/src/core/surface/call.h
+++ b/src/core/surface/call.h
@@ -36,6 +36,8 @@
#include "src/core/channel/channel_stack.h"
#include "src/core/channel/context.h"
+#include "src/core/surface/api_trace.h"
+#include "src/core/surface/surface_trace.h"
#include <grpc/grpc.h>
#ifdef __cplusplus
@@ -128,8 +130,6 @@ grpc_call_stack *grpc_call_get_call_stack(grpc_call *call);
/* Given the top call_element, get the call object. */
grpc_call *grpc_call_from_top_element(grpc_call_element *surface_element);
-extern int grpc_trace_batch;
-
void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
grpc_call *call, const grpc_op *ops, size_t nops,
void *tag);
@@ -155,17 +155,17 @@ void grpc_call_context_set(grpc_call *call, grpc_context_index elem,
void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
#define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
- if (grpc_trace_batch) grpc_call_log_batch(sev, call, ops, nops, tag)
+ if (grpc_api_trace) grpc_call_log_batch(sev, call, ops, nops, tag)
#define GRPC_SERVER_LOG_REQUEST_CALL(sev, server, call, details, \
initial_metadata, cq_bound_to_call, \
cq_for_notifications, tag) \
- if (grpc_trace_batch) \
+ if (grpc_api_trace) \
grpc_server_log_request_call(sev, server, call, details, initial_metadata, \
cq_bound_to_call, cq_for_notifications, tag)
#define GRPC_SERVER_LOG_SHUTDOWN(sev, server, cq, tag) \
- if (grpc_trace_batch) grpc_server_log_shutdown(sev, server, cq, tag)
+ if (grpc_api_trace) grpc_server_log_shutdown(sev, server, cq, tag)
gpr_uint8 grpc_call_is_client(grpc_call *call);
diff --git a/src/core/surface/call_details.c b/src/core/surface/call_details.c
index 65d2d1da5b..60f0029819 100644
--- a/src/core/surface/call_details.c
+++ b/src/core/surface/call_details.c
@@ -36,11 +36,15 @@
#include <string.h>
+#include "src/core/surface/api_trace.h"
+
void grpc_call_details_init(grpc_call_details* cd) {
+ GRPC_API_TRACE("grpc_call_details_init(cd=%p)", 1, (cd));
memset(cd, 0, sizeof(*cd));
}
void grpc_call_details_destroy(grpc_call_details* cd) {
+ GRPC_API_TRACE("grpc_call_details_destroy(cd=%p)", 1, (cd));
gpr_free(cd->method);
gpr_free(cd->host);
}
diff --git a/src/core/surface/call_log_batch.c b/src/core/surface/call_log_batch.c
index 5a3ef1e5f4..2dd9737cf8 100644
--- a/src/core/surface/call_log_batch.c
+++ b/src/core/surface/call_log_batch.c
@@ -37,8 +37,6 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
-int grpc_trace_batch = 0;
-
static void add_metadata(gpr_strvec *b, const grpc_metadata *md, size_t count) {
size_t i;
for (i = 0; i < count; i++) {
diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c
index aed7a79e4e..a9a5f828f2 100644
--- a/src/core/surface/channel.c
+++ b/src/core/surface/channel.c
@@ -43,6 +43,7 @@
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/support/string.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
#include "src/core/surface/init.h"
@@ -184,6 +185,7 @@ grpc_channel *grpc_channel_create_from_filters(
}
char *grpc_channel_get_target(grpc_channel *channel) {
+ GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel));
return gpr_strdup(channel->target);
}
@@ -213,6 +215,15 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_completion_queue *cq,
const char *method, const char *host,
gpr_timespec deadline, void *reserved) {
+ GRPC_API_TRACE(
+ "grpc_channel_create_call("
+ "channel=%p, parent_call=%p, propagation_mask=%x, cq=%p, method=%s, "
+ "host=%s, "
+ "deadline=gpr_timespec { tv_sec: %ld, tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 10, (channel, parent_call, (unsigned)propagation_mask, cq, method, host,
+ (long)deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
+ reserved));
GPR_ASSERT(!reserved);
return grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, cq,
@@ -230,6 +241,9 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel,
void *grpc_channel_register_call(grpc_channel *channel, const char *method,
const char *host, void *reserved) {
registered_call *rc = gpr_malloc(sizeof(registered_call));
+ GRPC_API_TRACE(
+ "grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)",
+ 4, (channel, method, host, reserved));
GPR_ASSERT(!reserved);
rc->path = grpc_mdelem_from_metadata_strings(
channel->metadata_context, GRPC_MDSTR_REF(channel->path_string),
@@ -252,6 +266,15 @@ grpc_call *grpc_channel_create_registered_call(
grpc_completion_queue *completion_queue, void *registered_call_handle,
gpr_timespec deadline, void *reserved) {
registered_call *rc = registered_call_handle;
+ GRPC_API_TRACE(
+ "grpc_channel_create_registered_call("
+ "channel=%p, parent_call=%p, propagation_mask=%x, completion_queue=%p, "
+ "registered_call_handle=%p, "
+ "deadline=gpr_timespec { tv_sec: %ld, tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 9, (channel, parent_call, (unsigned)propagation_mask, completion_queue,
+ registered_call_handle, (long)deadline.tv_sec, deadline.tv_nsec,
+ (int)deadline.clock_type, reserved));
GPR_ASSERT(!reserved);
return grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, completion_queue,
@@ -317,6 +340,7 @@ void grpc_channel_destroy(grpc_channel *channel) {
grpc_transport_op op;
grpc_channel_element *elem;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (channel));
memset(&op, 0, sizeof(op));
op.disconnect = 1;
elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
diff --git a/src/core/surface/channel_connectivity.c b/src/core/surface/channel_connectivity.c
index b992437d78..0af3469319 100644
--- a/src/core/surface/channel_connectivity.c
+++ b/src/core/surface/channel_connectivity.c
@@ -38,6 +38,7 @@
#include "src/core/channel/client_channel.h"
#include "src/core/iomgr/timer.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/completion_queue.h"
grpc_connectivity_state grpc_channel_check_connectivity_state(
@@ -47,6 +48,9 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_connectivity_state state;
+ GRPC_API_TRACE(
+ "grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
+ (channel, try_to_connect));
if (client_channel_elem->filter != &grpc_client_channel_filter) {
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
@@ -175,6 +179,14 @@ void grpc_channel_watch_connectivity_state(
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
state_watcher *w = gpr_malloc(sizeof(*w));
+ GRPC_API_TRACE(
+ "grpc_channel_watch_connectivity_state("
+ "channel=%p, last_observed_state=%d, "
+ "deadline=gpr_timespec { tv_sec: %ld, tv_nsec: %d, clock_type: %d }, "
+ "cq=%p, tag=%p)",
+ 7, (channel, (int)last_observed_state, (long)deadline.tv_sec,
+ deadline.tv_nsec, (int)deadline.clock_type, cq, tag));
+
grpc_cq_begin_op(cq);
gpr_mu_init(&w->mu);
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index 05591ce27f..51d9130b63 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -45,6 +45,7 @@
#include "src/core/channel/http_client_filter.h"
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/tcp_client.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/channel.h"
#include "src/core/transport/chttp2_transport.h"
@@ -184,6 +185,9 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
grpc_mdctx *mdctx = grpc_mdctx_create();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
size_t n = 0;
+ GRPC_API_TRACE(
+ "grpc_insecure_channel_create(target=%p, args=%p, reserved=%p)", 3,
+ (target, args, reserved));
GPR_ASSERT(!reserved);
if (grpc_channel_args_is_census_enabled(args)) {
filters[n++] = &grpc_client_census_filter;
diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c
index d73e5a7b46..4edcbb5e11 100644
--- a/src/core/surface/completion_queue.c
+++ b/src/core/surface/completion_queue.c
@@ -39,6 +39,7 @@
#include "src/core/iomgr/timer.h"
#include "src/core/iomgr/pollset.h"
#include "src/core/support/string.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
#include "src/core/surface/event_string.h"
#include "src/core/surface/surface_trace.h"
@@ -86,6 +87,7 @@ static void on_pollset_destroy_done(grpc_exec_ctx *exec_ctx, void *cc,
grpc_completion_queue *grpc_completion_queue_create(void *reserved) {
grpc_completion_queue *cc = gpr_malloc(sizeof(grpc_completion_queue));
+ GRPC_API_TRACE("grpc_completion_queue_create(reserved=%p)", 1, (reserved));
GPR_ASSERT(!reserved);
memset(cc, 0, sizeof(*cc));
/* Initial ref is dropped by grpc_completion_queue_shutdown */
@@ -193,6 +195,13 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
gpr_timespec now;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE(
+ "grpc_completion_queue_next("
+ "cc=%p, "
+ "deadline=gpr_timespec { tv_sec: %ld, tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 5, (cc, (long)deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
+ reserved));
GPR_ASSERT(!reserved);
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
@@ -270,6 +279,13 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
int first_loop = 1;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE(
+ "grpc_completion_queue_pluck("
+ "cc=%p, tag=%p, "
+ "deadline=gpr_timespec { tv_sec: %ld, tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 6, (cc, tag, (long)deadline.tv_sec, deadline.tv_nsec,
+ (int)deadline.clock_type, reserved));
GPR_ASSERT(!reserved);
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
@@ -335,6 +351,7 @@ done:
to zero here, then enter shutdown mode and wake up any waiters */
void grpc_completion_queue_shutdown(grpc_completion_queue *cc) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_completion_queue_shutdown(cc=%p)", 1, (cc));
gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
if (cc->shutdown_called) {
gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset));
@@ -354,6 +371,7 @@ void grpc_completion_queue_shutdown(grpc_completion_queue *cc) {
}
void grpc_completion_queue_destroy(grpc_completion_queue *cc) {
+ GRPC_API_TRACE("grpc_completion_queue_destroy(cc=%p)", 1, (cc));
grpc_completion_queue_shutdown(cc);
GRPC_CQ_INTERNAL_UNREF(cc, "destroy");
}
diff --git a/src/core/surface/init.c b/src/core/surface/init.c
index 93c27c77bf..95011cab17 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -49,6 +49,7 @@
#include "src/core/debug/trace.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/profiling/timers.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
#include "src/core/surface/init.h"
#include "src/core/surface/surface_trace.h"
@@ -75,6 +76,8 @@ static grpc_plugin g_all_of_the_plugins[MAX_PLUGINS];
static int g_number_of_plugins = 0;
void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) {
+ GRPC_API_TRACE("grpc_register_plugin(init=%lx, destroy=%lx)", 2,
+ ((unsigned long)init, (unsigned long)destroy));
GPR_ASSERT(g_number_of_plugins != MAX_PLUGINS);
g_all_of_the_plugins[g_number_of_plugins].init = init;
g_all_of_the_plugins[g_number_of_plugins].destroy = destroy;
@@ -98,11 +101,10 @@ void grpc_init(void) {
#ifdef GPR_POSIX_SOCKET
grpc_register_resolver_type(grpc_unix_resolver_factory_create());
#endif
+ grpc_register_tracer("api", &grpc_api_trace);
grpc_register_tracer("channel", &grpc_trace_channel);
- grpc_register_tracer("surface", &grpc_surface_trace);
grpc_register_tracer("http", &grpc_http_trace);
grpc_register_tracer("flowctl", &grpc_flowctl_trace);
- grpc_register_tracer("batch", &grpc_trace_batch);
grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace);
grpc_security_pre_init();
grpc_iomgr_init();
@@ -121,10 +123,12 @@ void grpc_init(void) {
}
}
gpr_mu_unlock(&g_init_mu);
+ GRPC_API_TRACE("grpc_init(void)", 0, ());
}
void grpc_shutdown(void) {
int i;
+ GRPC_API_TRACE("grpc_shutdown(void)", 0, ());
gpr_mu_lock(&g_init_mu);
if (--g_initializations == 0) {
grpc_iomgr_shutdown();
diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c
index 9e14ce2191..e72264fbcd 100644
--- a/src/core/surface/lame_client.c
+++ b/src/core/surface/lame_client.c
@@ -37,6 +37,7 @@
#include "src/core/channel/channel_stack.h"
#include "src/core/support/string.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/call.h"
#include <grpc/support/alloc.h>
@@ -151,6 +152,10 @@ grpc_channel *grpc_lame_client_channel_create(const char *target,
channel = grpc_channel_create_from_filters(&exec_ctx, target, filters, 1,
NULL, grpc_mdctx_create(), 1);
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
+ GRPC_API_TRACE(
+ "grpc_lame_client_channel_create(target=%s, error_code=%d, "
+ "error_message=%s)",
+ 3, (target, (int)error_code, error_message));
GPR_ASSERT(elem->filter == &lame_filter);
chand = (channel_data *)elem->channel_data;
chand->error_code = error_code;
diff --git a/src/core/surface/metadata_array.c b/src/core/surface/metadata_array.c
index 648c579266..4c7bf17835 100644
--- a/src/core/surface/metadata_array.c
+++ b/src/core/surface/metadata_array.c
@@ -36,10 +36,14 @@
#include <string.h>
+#include "src/core/surface/api_trace.h"
+
void grpc_metadata_array_init(grpc_metadata_array* array) {
+ GRPC_API_TRACE("grpc_metadata_array_init(array=%p)", 1, (array));
memset(array, 0, sizeof(*array));
}
void grpc_metadata_array_destroy(grpc_metadata_array* array) {
+ GRPC_API_TRACE("grpc_metadata_array_destroy(array=%p)", 1, (array));
gpr_free(array->metadata);
}
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index d6070a54a8..1282ee99ed 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -47,6 +47,7 @@
#include "src/core/iomgr/tcp_client.h"
#include "src/core/security/auth_filters.h"
#include "src/core/security/credentials.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/channel.h"
#include "src/core/transport/chttp2_transport.h"
#include "src/core/tsi/transport_security_interface.h"
@@ -246,7 +247,12 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds,
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
size_t n = 0;
+ GRPC_API_TRACE(
+ "grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
+ "reserved=%p)",
+ 4, (creds, target, args, reserved));
GPR_ASSERT(reserved == NULL);
+
if (grpc_find_security_connector_in_args(args) != NULL) {
gpr_log(GPR_ERROR, "Cannot set security context in channel args.");
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index e3ce88b3e6..819226278d 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -48,6 +48,7 @@
#include "src/core/iomgr/iomgr.h"
#include "src/core/support/stack_lockfree.h"
#include "src/core/support/string.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/completion_queue.h"
@@ -776,6 +777,9 @@ void grpc_server_register_completion_queue(grpc_server *server,
grpc_completion_queue *cq,
void *reserved) {
size_t i, n;
+ GRPC_API_TRACE(
+ "grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3,
+ (server, cq, reserved));
GPR_ASSERT(!reserved);
for (i = 0; i < server->cq_count; i++) {
if (server->cqs[i] == cq) return;
@@ -854,6 +858,8 @@ static int streq(const char *a, const char *b) {
void *grpc_server_register_method(grpc_server *server, const char *method,
const char *host) {
registered_method *m;
+ GRPC_API_TRACE("grpc_server_register_method(server=%p, method=%s, host=%s)",
+ 3, (server, method, host));
if (!method) {
gpr_log(GPR_ERROR,
"grpc_server_register_method method string cannot be NULL");
@@ -881,6 +887,8 @@ void grpc_server_start(grpc_server *server) {
size_t i;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_server_start(server=%p)", 1, (server));
+
server->pollsets = gpr_malloc(sizeof(grpc_pollset *) * server->cq_count);
for (i = 0; i < server->cq_count; i++) {
server->pollsets[i] = grpc_cq_pollset(server->cqs[i]);
@@ -1011,6 +1019,9 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
channel_broadcaster broadcaster;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_server_shutdown_and_notify(server=%p, cq=%p, tag=%p)", 3,
+ (server, cq, tag));
+
GRPC_SERVER_LOG_SHUTDOWN(GPR_INFO, server, cq, tag);
/* lock, and gather up some stuff to do */
@@ -1063,6 +1074,8 @@ void grpc_server_cancel_all_calls(grpc_server *server) {
channel_broadcaster broadcaster;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_server_cancel_all_calls(server=%p)", 1, (server));
+
gpr_mu_lock(&server->mu_global);
channel_broadcaster_init(server, &broadcaster);
gpr_mu_unlock(&server->mu_global);
@@ -1075,6 +1088,8 @@ void grpc_server_destroy(grpc_server *server) {
listener *l;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_server_destroy(server=%p)", 1, (server));
+
gpr_mu_lock(&server->mu_global);
GPR_ASSERT(gpr_atm_acq_load(&server->shutdown_flag) || !server->listeners);
GPR_ASSERT(server->listeners_destroyed == num_listeners(server));
@@ -1169,6 +1184,12 @@ grpc_call_error grpc_server_request_call(
grpc_call_error error;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
requested_call *rc = gpr_malloc(sizeof(*rc));
+ GRPC_API_TRACE(
+ "grpc_server_request_call("
+ "server=%p, call=%p, details=%p, initial_metadata=%p, "
+ "cq_bound_to_call=%p, cq_for_notification=%p, tag%p)",
+ 7, (server, call, details, initial_metadata, cq_bound_to_call,
+ cq_for_notification, tag));
GRPC_SERVER_LOG_REQUEST_CALL(GPR_INFO, server, call, details,
initial_metadata, cq_bound_to_call,
cq_for_notification, tag);
@@ -1202,6 +1223,13 @@ grpc_call_error grpc_server_request_registered_call(
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
requested_call *rc = gpr_malloc(sizeof(*rc));
registered_method *rm = rmp;
+ GRPC_API_TRACE(
+ "grpc_server_request_registered_call("
+ "server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, "
+ "optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, "
+ "tag=%p)",
+ 9, (server, rmp, call, deadline, initial_metadata, optional_payload,
+ cq_bound_to_call, cq_for_notification, tag));
if (!grpc_cq_is_server_cq(cq_for_notification)) {
gpr_free(rc);
error = GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE;
diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c
index 3904ce969d..580b91573c 100644
--- a/src/core/surface/server_chttp2.c
+++ b/src/core/surface/server_chttp2.c
@@ -36,6 +36,7 @@
#include "src/core/channel/http_server_filter.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/tcp_server.h"
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/server.h"
#include "src/core/transport/chttp2_transport.h"
#include <grpc/support/alloc.h>
@@ -92,6 +93,9 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
int port_temp;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_API_TRACE("grpc_server_add_insecure_http2_port(server=%p, addr=%s)", 2,
+ (server, addr));
+
resolved = grpc_blocking_resolve_address(addr, "http");
if (!resolved) {
goto error;
diff --git a/src/core/surface/server_create.c b/src/core/surface/server_create.c
index fc7ae820f5..c7811a6d88 100644
--- a/src/core/surface/server_create.c
+++ b/src/core/surface/server_create.c
@@ -32,13 +32,14 @@
*/
#include <grpc/grpc.h>
+#include "src/core/surface/api_trace.h"
#include "src/core/surface/completion_queue.h"
#include "src/core/surface/server.h"
#include "src/core/channel/compress_filter.h"
grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
const grpc_channel_filter *filters[] = {&grpc_compress_filter};
- (void)reserved;
+ GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
return grpc_server_create_from_filters(filters, GPR_ARRAY_SIZE(filters),
args);
}
diff --git a/src/core/surface/surface_trace.h b/src/core/surface/surface_trace.h
index 2b4728e2b4..93b2859ac5 100644
--- a/src/core/surface/surface_trace.h
+++ b/src/core/surface/surface_trace.h
@@ -35,12 +35,11 @@
#define GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H
#include "src/core/debug/trace.h"
+#include "src/core/surface/api_trace.h"
#include <grpc/support/log.h>
-extern int grpc_surface_trace;
-
#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
- if (grpc_surface_trace) { \
+ if (grpc_api_trace) { \
char *_ev = grpc_event_string(event); \
gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \
gpr_free(_ev); \
diff --git a/src/core/surface/version.c b/src/core/surface/version.c
index 4b90e06a04..e559d51448 100644
--- a/src/core/surface/version.c
+++ b/src/core/surface/version.c
@@ -36,6 +36,4 @@
#include <grpc/grpc.h>
-const char *grpc_version_string(void) {
- return "0.11.0.0";
-}
+const char *grpc_version_string(void) { return "0.11.0.0"; }
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 0437dbfadf..de74379546 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -1136,7 +1136,7 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, int success) {
grpc_chttp2_publish_reads(exec_ctx, &t->global, &t->parsing);
t->parsing_active = 0;
}
- if (!success || i != t->read_buffer.count) {
+ if (!success || i != t->read_buffer.count || t->closed) {
drop_connection(exec_ctx, t);
read_error_locked(exec_ctx, t);
} else if (!t->closed) {