aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--build.json6
-rw-r--r--src/core/channel/channel_stack.c2
-rw-r--r--src/core/channel/channel_stack.h4
-rw-r--r--src/core/debug/trace.c65
-rw-r--r--src/core/debug/trace.h22
-rw-r--r--src/core/iomgr/iomgr_posix.c3
-rw-r--r--src/core/iomgr/tcp_posix.c6
-rw-r--r--src/core/iomgr/tcp_posix.h2
-rw-r--r--src/core/security/secure_endpoint.c6
-rw-r--r--src/core/security/secure_endpoint.h2
-rw-r--r--src/core/surface/init.c10
-rw-r--r--src/core/surface/init.h39
-rw-r--r--src/core/surface/init_secure.c42
-rw-r--r--src/core/surface/init_unsecure.c37
-rw-r--r--src/core/surface/surface_trace.c36
-rw-r--r--src/core/surface/surface_trace.h4
-rw-r--r--src/core/transport/chttp2/frame_settings.c3
-rw-r--r--src/core/transport/chttp2_transport.c5
-rw-r--r--src/core/transport/chttp2_transport.h2
-rw-r--r--src/core/tsi/transport_security.c4
-rw-r--r--src/core/tsi/transport_security_interface.h4
-rw-r--r--vsprojects/vs2013/grpc.vcxproj5
-rw-r--r--vsprojects/vs2013/grpc.vcxproj.filters9
-rw-r--r--vsprojects/vs2013/grpc_shared.vcxproj5
-rw-r--r--vsprojects/vs2013/grpc_shared.vcxproj.filters9
-rw-r--r--vsprojects/vs2013/grpc_unsecure.vcxproj5
-rw-r--r--vsprojects/vs2013/grpc_unsecure.vcxproj.filters9
28 files changed, 293 insertions, 63 deletions
diff --git a/Makefile b/Makefile
index 3601a4dd1c..64871343e1 100644
--- a/Makefile
+++ b/Makefile
@@ -2328,6 +2328,7 @@ LIBGRPC_SRC = \
src/core/security/secure_transport_setup.c \
src/core/security/security_context.c \
src/core/security/server_secure_chttp2.c \
+ src/core/surface/init_secure.c \
src/core/surface/secure_channel_create.c \
src/core/surface/secure_server_create.c \
src/core/tsi/fake_transport_security.c \
@@ -2407,6 +2408,7 @@ LIBGRPC_SRC = \
src/core/surface/server.c \
src/core/surface/server_chttp2.c \
src/core/surface/server_create.c \
+ src/core/surface/surface_trace.c \
src/core/transport/chttp2/alpn.c \
src/core/transport/chttp2/bin_encoder.c \
src/core/transport/chttp2/frame_data.c \
@@ -2472,6 +2474,7 @@ src/core/security/secure_endpoint.c: $(OPENSSL_DEP)
src/core/security/secure_transport_setup.c: $(OPENSSL_DEP)
src/core/security/security_context.c: $(OPENSSL_DEP)
src/core/security/server_secure_chttp2.c: $(OPENSSL_DEP)
+src/core/surface/init_secure.c: $(OPENSSL_DEP)
src/core/surface/secure_channel_create.c: $(OPENSSL_DEP)
src/core/surface/secure_server_create.c: $(OPENSSL_DEP)
src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP)
@@ -2551,6 +2554,7 @@ src/core/surface/metadata_array.c: $(OPENSSL_DEP)
src/core/surface/server.c: $(OPENSSL_DEP)
src/core/surface/server_chttp2.c: $(OPENSSL_DEP)
src/core/surface/server_create.c: $(OPENSSL_DEP)
+src/core/surface/surface_trace.c: $(OPENSSL_DEP)
src/core/transport/chttp2/alpn.c: $(OPENSSL_DEP)
src/core/transport/chttp2/bin_encoder.c: $(OPENSSL_DEP)
src/core/transport/chttp2/frame_data.c: $(OPENSSL_DEP)
@@ -2633,6 +2637,7 @@ $(OBJDIR)/$(CONFIG)/src/core/security/secure_endpoint.o:
$(OBJDIR)/$(CONFIG)/src/core/security/secure_transport_setup.o:
$(OBJDIR)/$(CONFIG)/src/core/security/security_context.o:
$(OBJDIR)/$(CONFIG)/src/core/security/server_secure_chttp2.o:
+$(OBJDIR)/$(CONFIG)/src/core/surface/init_secure.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/secure_channel_create.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/secure_server_create.o:
$(OBJDIR)/$(CONFIG)/src/core/tsi/fake_transport_security.o:
@@ -2712,6 +2717,7 @@ $(OBJDIR)/$(CONFIG)/src/core/surface/metadata_array.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/server.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/server_chttp2.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/server_create.o:
+$(OBJDIR)/$(CONFIG)/src/core/surface/surface_trace.o:
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/alpn.o:
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/bin_encoder.o:
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/frame_data.o:
@@ -2811,6 +2817,7 @@ $(OBJDIR)/$(CONFIG)/test/core/util/slice_splitter.o:
LIBGRPC_UNSECURE_SRC = \
+ src/core/surface/init_unsecure.c \
src/core/channel/call_op_string.c \
src/core/channel/census_filter.c \
src/core/channel/channel_args.c \
@@ -2885,6 +2892,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/surface/server.c \
src/core/surface/server_chttp2.c \
src/core/surface/server_create.c \
+ src/core/surface/surface_trace.c \
src/core/transport/chttp2/alpn.c \
src/core/transport/chttp2/bin_encoder.c \
src/core/transport/chttp2/frame_data.c \
@@ -2947,6 +2955,7 @@ ifneq ($(NO_DEPS),true)
-include $(LIBGRPC_UNSECURE_OBJS:.o=.dep)
endif
+$(OBJDIR)/$(CONFIG)/src/core/surface/init_unsecure.o:
$(OBJDIR)/$(CONFIG)/src/core/channel/call_op_string.o:
$(OBJDIR)/$(CONFIG)/src/core/channel/census_filter.o:
$(OBJDIR)/$(CONFIG)/src/core/channel/channel_args.o:
@@ -3021,6 +3030,7 @@ $(OBJDIR)/$(CONFIG)/src/core/surface/metadata_array.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/server.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/server_chttp2.o:
$(OBJDIR)/$(CONFIG)/src/core/surface/server_create.o:
+$(OBJDIR)/$(CONFIG)/src/core/surface/surface_trace.o:
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/alpn.o:
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/bin_encoder.o:
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/frame_data.o:
diff --git a/build.json b/build.json
index 2bbb012fbd..cfba96180f 100644
--- a/build.json
+++ b/build.json
@@ -79,6 +79,7 @@
"src/core/surface/client.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
+ "src/core/surface/init.h",
"src/core/surface/lame_client.h",
"src/core/surface/server.h",
"src/core/surface/surface_trace.h",
@@ -180,6 +181,7 @@
"src/core/surface/server.c",
"src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c",
+ "src/core/surface/surface_trace.c",
"src/core/transport/chttp2/alpn.c",
"src/core/transport/chttp2/bin_encoder.c",
"src/core/transport/chttp2/frame_data.c",
@@ -329,6 +331,7 @@
"src/core/security/secure_transport_setup.c",
"src/core/security/security_context.c",
"src/core/security/server_secure_chttp2.c",
+ "src/core/surface/init_secure.c",
"src/core/surface/secure_channel_create.c",
"src/core/surface/secure_server_create.c",
"src/core/tsi/fake_transport_security.c",
@@ -372,6 +375,9 @@
"name": "grpc_unsecure",
"build": "all",
"language": "c",
+ "src": [
+ "src/core/surface/init_unsecure.c"
+ ],
"deps": [
"gpr"
],
diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c
index 0382a7a2f3..21df9771ce 100644
--- a/src/core/channel/channel_stack.c
+++ b/src/core/channel/channel_stack.c
@@ -36,6 +36,8 @@
#include <stdlib.h>
+int grpc_trace_channel = 0;
+
/* Memory layouts.
Channel stack is laid out as: {
diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h
index c136f5c17c..ef1da7b33b 100644
--- a/src/core/channel/channel_stack.h
+++ b/src/core/channel/channel_stack.h
@@ -298,7 +298,9 @@ void grpc_call_element_recv_metadata(grpc_call_element *cur_elem,
void grpc_call_element_send_cancel(grpc_call_element *cur_elem);
void grpc_call_element_send_finish(grpc_call_element *cur_elem);
+extern int grpc_trace_channel;
+
#define GRPC_CALL_LOG_OP(sev, elem, op) \
- if (grpc_trace_bits & GRPC_TRACE_CHANNEL) grpc_call_log_op(sev, elem, op)
+ if (grpc_trace_channel) grpc_call_log_op(sev, elem, op)
#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H */
diff --git a/src/core/debug/trace.c b/src/core/debug/trace.c
index b8eb755bff..32c35e7fb3 100644
--- a/src/core/debug/trace.c
+++ b/src/core/debug/trace.c
@@ -39,8 +39,21 @@
#include <grpc/support/log.h>
#include "src/core/support/env.h"
-#if GRPC_ENABLE_TRACING
-gpr_uint32 grpc_trace_bits = 0;
+typedef struct tracer {
+ const char *name;
+ int *flag;
+ struct tracer *next;
+} tracer;
+static tracer *tracers;
+
+void grpc_register_tracer(const char *name, int *flag) {
+ tracer *t = gpr_malloc(sizeof(*t));
+ t->name = name;
+ t->flag = flag;
+ t->next = tracers;
+ *flag = 0;
+ tracers = t;
+}
static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
size_t n = *ns;
@@ -67,26 +80,26 @@ static void parse(const char *s) {
char **strings = NULL;
size_t nstrings = 0;
size_t i;
+ tracer *t;
split(s, &strings, &nstrings);
- grpc_trace_bits = 0;
-
for (i = 0; i < nstrings; i++) {
const char *s = strings[i];
- if (0 == strcmp(s, "surface")) {
- grpc_trace_bits |= GRPC_TRACE_SURFACE;
- } else if (0 == strcmp(s, "channel")) {
- grpc_trace_bits |= GRPC_TRACE_CHANNEL;
- } else if (0 == strcmp(s, "tcp")) {
- grpc_trace_bits |= GRPC_TRACE_TCP;
- } else if (0 == strcmp(s, "secure_endpoint")) {
- grpc_trace_bits |= GRPC_TRACE_SECURE_ENDPOINT;
- } else if (0 == strcmp(s, "http")) {
- grpc_trace_bits |= GRPC_TRACE_HTTP;
- } else if (0 == strcmp(s, "all")) {
- grpc_trace_bits = -1;
+ if (0 == strcmp(s, "all")) {
+ for (t = tracers; t; t = t->next) {
+ *t->flag = 1;
+ }
} else {
- gpr_log(GPR_ERROR, "Unknown trace var: '%s'", s);
+ int found = 0;
+ for (t = tracers; t; t = t->next) {
+ if (0 == strcmp(s, t->name)) {
+ *t->flag = 1;
+ found = 1;
+ }
+ }
+ if (!found) {
+ gpr_log(GPR_ERROR, "Unknown trace var: '%s'", s);
+ }
}
}
@@ -96,17 +109,15 @@ static void parse(const char *s) {
gpr_free(strings);
}
-void grpc_init_trace_bits() {
- char *e = gpr_getenv("GRPC_TRACE");
- if (e == NULL) {
- grpc_trace_bits = 0;
- } else {
+void grpc_tracer_init(const char *env_var) {
+ char *e = gpr_getenv(env_var);
+ if (e != NULL) {
parse(e);
gpr_free(e);
}
+ while (tracers) {
+ tracer *t = tracers;
+ tracers = t->next;
+ gpr_free(t);
+ }
}
-#else
-void grpc_init_trace_bits() {
-}
-#endif
-
diff --git a/src/core/debug/trace.h b/src/core/debug/trace.h
index 2059599a7d..c02f14b7f2 100644
--- a/src/core/debug/trace.h
+++ b/src/core/debug/trace.h
@@ -36,25 +36,7 @@
#include <grpc/support/port_platform.h>
-/* set to zero to remove all debug trace code */
-#ifndef GRPC_ENABLE_TRACING
-# define GRPC_ENABLE_TRACING 1
-#endif
-
-typedef enum {
- GRPC_TRACE_SURFACE = 1 << 0,
- GRPC_TRACE_CHANNEL = 1 << 1,
- GRPC_TRACE_TCP = 1 << 2,
- GRPC_TRACE_SECURE_ENDPOINT = 1 << 3,
- GRPC_TRACE_HTTP = 1 << 4
-} grpc_trace_bit_value;
-
-#if GRPC_ENABLE_TRACING
-extern gpr_uint32 grpc_trace_bits;
-#else
-# define grpc_trace_bits 0
-#endif
-
-void grpc_init_trace_bits();
+void grpc_register_tracer(const char *name, int *flag);
+void grpc_tracer_init(const char *env_var_name);
#endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */
diff --git a/src/core/iomgr/iomgr_posix.c b/src/core/iomgr/iomgr_posix.c
index 14e3d182f6..758ae77b86 100644
--- a/src/core/iomgr/iomgr_posix.c
+++ b/src/core/iomgr/iomgr_posix.c
@@ -36,11 +36,14 @@
#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/iomgr_posix.h"
+#include "src/core/debug/trace.h"
#include "src/core/iomgr/fd_posix.h"
+#include "src/core/iomgr/tcp_posix.h"
void grpc_iomgr_platform_init(void) {
grpc_fd_global_init();
grpc_pollset_global_init();
+ grpc_register_tracer("tcp", &grpc_tcp_trace);
}
void grpc_iomgr_platform_shutdown(void) {
diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c
index eceb0feadb..597a2a62d3 100644
--- a/src/core/iomgr/tcp_posix.c
+++ b/src/core/iomgr/tcp_posix.c
@@ -63,6 +63,8 @@ typedef struct grpc_tcp_slice_state {
int memory_owned; /* True if slices array is owned */
} grpc_tcp_slice_state;
+int grpc_tcp_trace = 0;
+
static void slice_state_init(grpc_tcp_slice_state *state, gpr_slice *slices,
size_t nslices, size_t valid_slices) {
state->slices = slices;
@@ -294,7 +296,7 @@ static void call_read_cb(grpc_tcp *tcp, gpr_slice *slices, size_t nslices,
grpc_endpoint_cb_status status) {
grpc_endpoint_read_cb cb = tcp->read_cb;
- if (grpc_trace_bits & GRPC_TRACE_TCP) {
+ if (grpc_tcp_trace) {
size_t i;
gpr_log(GPR_DEBUG, "read: status=%d", status);
for (i = 0; i < nslices; i++) {
@@ -495,7 +497,7 @@ static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep,
grpc_tcp *tcp = (grpc_tcp *)ep;
grpc_endpoint_write_status status;
- if (grpc_trace_bits & GRPC_TRACE_TCP) {
+ if (grpc_tcp_trace) {
size_t i;
for (i = 0; i < nslices; i++) {
diff --git a/src/core/iomgr/tcp_posix.h b/src/core/iomgr/tcp_posix.h
index 7e8064bffc..44279d5a26 100644
--- a/src/core/iomgr/tcp_posix.h
+++ b/src/core/iomgr/tcp_posix.h
@@ -49,6 +49,8 @@
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
+extern int grpc_tcp_trace;
+
/* Create a tcp endpoint given a file desciptor and a read slice size.
Takes ownership of fd. */
grpc_endpoint *grpc_tcp_create(grpc_fd *fd, size_t read_slice_size);
diff --git a/src/core/security/secure_endpoint.c b/src/core/security/secure_endpoint.c
index d6bdf5a709..7bb1de4413 100644
--- a/src/core/security/secure_endpoint.c
+++ b/src/core/security/secure_endpoint.c
@@ -65,6 +65,8 @@ typedef struct {
gpr_refcount ref;
} secure_endpoint;
+int grpc_trace_secure_endpoint = 0;
+
static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); }
static void destroy(secure_endpoint *secure_ep) {
@@ -96,7 +98,7 @@ static void flush_read_staging_buffer(secure_endpoint *ep, gpr_uint8 **cur,
static void call_read_cb(secure_endpoint *ep, gpr_slice *slices, size_t nslices,
grpc_endpoint_cb_status error) {
- if (grpc_trace_bits & GRPC_TRACE_SECURE_ENDPOINT) {
+ if (grpc_trace_secure_endpoint) {
size_t i;
for (i = 0; i < nslices; i++) {
char *data =
@@ -231,7 +233,7 @@ static grpc_endpoint_write_status endpoint_write(grpc_endpoint *secure_ep,
grpc_endpoint_write_status status;
GPR_ASSERT(ep->output_buffer.count == 0);
- if (grpc_trace_bits & GRPC_TRACE_SECURE_ENDPOINT) {
+ if (grpc_trace_secure_endpoint) {
for (i = 0; i < nslices; i++) {
char *data =
gpr_hexdump((char *)GPR_SLICE_START_PTR(slices[i]),
diff --git a/src/core/security/secure_endpoint.h b/src/core/security/secure_endpoint.h
index 808889bf04..93c29b5111 100644
--- a/src/core/security/secure_endpoint.h
+++ b/src/core/security/secure_endpoint.h
@@ -39,6 +39,8 @@
struct tsi_frame_protector;
+extern int grpc_trace_secure_endpoint;
+
/* Takes ownership of protector and to_wrap, and refs leftover_slices. */
grpc_endpoint *grpc_secure_endpoint_create(
struct tsi_frame_protector *protector, grpc_endpoint *to_wrap,
diff --git a/src/core/surface/init.c b/src/core/surface/init.c
index 2d8f36e9c2..4db66fb66e 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -35,6 +35,10 @@
#include "src/core/iomgr/iomgr.h"
#include "src/core/debug/trace.h"
#include "src/core/statistics/census_interface.h"
+#include "src/core/channel/channel_stack.h"
+#include "src/core/surface/init.h"
+#include "src/core/surface/surface_trace.h"
+#include "src/core/transport/chttp2_transport.h"
static gpr_once g_init = GPR_ONCE_INIT;
static gpr_mu g_init_mu;
@@ -50,7 +54,11 @@ void grpc_init(void) {
gpr_mu_lock(&g_init_mu);
if (++g_initializations == 1) {
- grpc_init_trace_bits();
+ grpc_register_tracer("channel", &grpc_trace_channel);
+ grpc_register_tracer("surface", &grpc_surface_trace);
+ grpc_register_tracer("http", &grpc_http_trace);
+ grpc_security_pre_init();
+ grpc_tracer_init("GRPC_TRACE");
grpc_iomgr_init();
census_init();
}
diff --git a/src/core/surface/init.h b/src/core/surface/init.h
new file mode 100644
index 0000000000..ab40bedf87
--- /dev/null
+++ b/src/core/surface/init.h
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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_INIT_H
+#define GRPC_INTERNAL_CORE_SURFACE_INIT_H
+
+void grpc_security_pre_init(void);
+
+#endif /* GRPC_INTERNAL_CORE_SURFACE_INIT_H */
diff --git a/src/core/surface/init_secure.c b/src/core/surface/init_secure.c
new file mode 100644
index 0000000000..fa20e91583
--- /dev/null
+++ b/src/core/surface/init_secure.c
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "src/core/surface/init.h"
+#include "src/core/debug/trace.h"
+#include "src/core/security/secure_endpoint.h"
+#include "src/core/tsi/transport_security_interface.h"
+
+void grpc_security_pre_init(void) {
+ grpc_register_tracer("secure_endpoint", &grpc_trace_secure_endpoint);
+ grpc_register_tracer("transport_security", &tsi_tracing_enabled);
+}
diff --git a/src/core/surface/init_unsecure.c b/src/core/surface/init_unsecure.c
new file mode 100644
index 0000000000..ddb70cef8e
--- /dev/null
+++ b/src/core/surface/init_unsecure.c
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "src/core/surface/init.h"
+
+void grpc_security_pre_init(void) {
+}
diff --git a/src/core/surface/surface_trace.c b/src/core/surface/surface_trace.c
new file mode 100644
index 0000000000..57a0053162
--- /dev/null
+++ b/src/core/surface/surface_trace.c
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "src/core/surface/surface_trace.h"
+
+int grpc_surface_trace = 0;
diff --git a/src/core/surface/surface_trace.h b/src/core/surface/surface_trace.h
index 50071ee317..01302bb5d4 100644
--- a/src/core/surface/surface_trace.h
+++ b/src/core/surface/surface_trace.h
@@ -37,8 +37,10 @@
#include "src/core/debug/trace.h"
#include <grpc/support/log.h>
+extern int grpc_surface_trace;
+
#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
- if (grpc_trace_bits & GRPC_TRACE_SURFACE) { \
+ if (grpc_surface_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/transport/chttp2/frame_settings.c b/src/core/transport/chttp2/frame_settings.c
index e6c4b7e38f..8d3250c34f 100644
--- a/src/core/transport/chttp2/frame_settings.c
+++ b/src/core/transport/chttp2/frame_settings.c
@@ -37,6 +37,7 @@
#include "src/core/debug/trace.h"
#include "src/core/transport/chttp2/frame.h"
+#include "src/core/transport/chttp2_transport.h"
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
@@ -218,7 +219,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
}
}
parser->incoming_settings[parser->id] = parser->value;
- if (grpc_trace_bits & GRPC_TRACE_HTTP) {
+ if (grpc_http_trace) {
gpr_log(GPR_DEBUG, "CHTTP2: got setting %d = %d", parser->id,
parser->value);
}
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 6b7273e3e4..0d01a37112 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -37,7 +37,6 @@
#include <stdio.h>
#include <string.h>
-#include "src/core/debug/trace.h"
#include "src/core/support/string.h"
#include "src/core/transport/chttp2/frame_data.h"
#include "src/core/transport/chttp2/frame_goaway.h"
@@ -64,11 +63,13 @@
#define CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
#define CLIENT_CONNECT_STRLEN 24
+int grpc_http_trace = 0;
+
typedef struct transport transport;
typedef struct stream stream;
#define IF_TRACING(stmt) \
- if (!(grpc_trace_bits & GRPC_TRACE_HTTP)) \
+ if (!(grpc_http_trace)) \
; \
else \
stmt
diff --git a/src/core/transport/chttp2_transport.h b/src/core/transport/chttp2_transport.h
index c5b65bd4f7..a7f1b9a864 100644
--- a/src/core/transport/chttp2_transport.h
+++ b/src/core/transport/chttp2_transport.h
@@ -37,6 +37,8 @@
#include "src/core/iomgr/endpoint.h"
#include "src/core/transport/transport.h"
+extern int grpc_http_trace;
+
void grpc_create_chttp2_transport(grpc_transport_setup_callback setup,
void *arg,
const grpc_channel_args *channel_args,
diff --git a/src/core/tsi/transport_security.c b/src/core/tsi/transport_security.c
index 04b30004fc..c8c74c5de5 100644
--- a/src/core/tsi/transport_security.c
+++ b/src/core/tsi/transport_security.c
@@ -40,10 +40,6 @@
int tsi_tracing_enabled = 0;
-void tsi_enable_tracing() {
- tsi_tracing_enabled = 1;
-}
-
/* --- Utils. --- */
char* tsi_strdup(const char* src) {
diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h
index 33a19bef0d..0edff54235 100644
--- a/src/core/tsi/transport_security_interface.h
+++ b/src/core/tsi/transport_security_interface.h
@@ -63,8 +63,8 @@ const char* tsi_result_to_string(tsi_result result);
/* --- tsi tracing --- */
-/* Call this function before any other tsi function to avoid races. */
-void tsi_enable_tracing(void);
+/* Set this early to avoid races */
+extern int tsi_tracing_enabled;
/* --- tsi_frame_protector object ---
diff --git a/vsprojects/vs2013/grpc.vcxproj b/vsprojects/vs2013/grpc.vcxproj
index 48f975f99b..60dc980242 100644
--- a/vsprojects/vs2013/grpc.vcxproj
+++ b/vsprojects/vs2013/grpc.vcxproj
@@ -160,6 +160,7 @@
<ClInclude Include="..\..\src\core\surface\client.h" />
<ClInclude Include="..\..\src\core\surface\completion_queue.h" />
<ClInclude Include="..\..\src\core\surface\event_string.h" />
+ <ClInclude Include="..\..\src\core\surface\init.h" />
<ClInclude Include="..\..\src\core\surface\lame_client.h" />
<ClInclude Include="..\..\src\core\surface\server.h" />
<ClInclude Include="..\..\src\core\surface\surface_trace.h" />
@@ -219,6 +220,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\security\server_secure_chttp2.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\init_secure.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\surface\secure_channel_create.c">
</ClCompile>
<ClCompile Include="..\..\src\core\surface\secure_server_create.c">
@@ -377,6 +380,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\surface\server_create.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\surface_trace.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\alpn.c">
</ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\bin_encoder.c">
diff --git a/vsprojects/vs2013/grpc.vcxproj.filters b/vsprojects/vs2013/grpc.vcxproj.filters
index 867e54516c..9fc70e74d9 100644
--- a/vsprojects/vs2013/grpc.vcxproj.filters
+++ b/vsprojects/vs2013/grpc.vcxproj.filters
@@ -49,6 +49,9 @@
<ClCompile Include="..\..\src\core\security\server_secure_chttp2.c">
<Filter>src\core\security</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\init_secure.c">
+ <Filter>src\core\surface</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\surface\secure_channel_create.c">
<Filter>src\core\surface</Filter>
</ClCompile>
@@ -286,6 +289,9 @@
<ClCompile Include="..\..\src\core\surface\server_create.c">
<Filter>src\core\surface</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\surface_trace.c">
+ <Filter>src\core\surface</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\alpn.c">
<Filter>src\core\transport\chttp2</Filter>
</ClCompile>
@@ -590,6 +596,9 @@
<ClInclude Include="..\..\src\core\surface\event_string.h">
<Filter>src\core\surface</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\core\surface\init.h">
+ <Filter>src\core\surface</Filter>
+ </ClInclude>
<ClInclude Include="..\..\src\core\surface\lame_client.h">
<Filter>src\core\surface</Filter>
</ClInclude>
diff --git a/vsprojects/vs2013/grpc_shared.vcxproj b/vsprojects/vs2013/grpc_shared.vcxproj
index 4b2f1e725e..5c2e23b513 100644
--- a/vsprojects/vs2013/grpc_shared.vcxproj
+++ b/vsprojects/vs2013/grpc_shared.vcxproj
@@ -164,6 +164,7 @@
<ClInclude Include="..\..\src\core\surface\client.h" />
<ClInclude Include="..\..\src\core\surface\completion_queue.h" />
<ClInclude Include="..\..\src\core\surface\event_string.h" />
+ <ClInclude Include="..\..\src\core\surface\init.h" />
<ClInclude Include="..\..\src\core\surface\lame_client.h" />
<ClInclude Include="..\..\src\core\surface\server.h" />
<ClInclude Include="..\..\src\core\surface\surface_trace.h" />
@@ -223,6 +224,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\security\server_secure_chttp2.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\init_secure.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\surface\secure_channel_create.c">
</ClCompile>
<ClCompile Include="..\..\src\core\surface\secure_server_create.c">
@@ -381,6 +384,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\surface\server_create.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\surface_trace.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\alpn.c">
</ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\bin_encoder.c">
diff --git a/vsprojects/vs2013/grpc_shared.vcxproj.filters b/vsprojects/vs2013/grpc_shared.vcxproj.filters
index 867e54516c..9fc70e74d9 100644
--- a/vsprojects/vs2013/grpc_shared.vcxproj.filters
+++ b/vsprojects/vs2013/grpc_shared.vcxproj.filters
@@ -49,6 +49,9 @@
<ClCompile Include="..\..\src\core\security\server_secure_chttp2.c">
<Filter>src\core\security</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\init_secure.c">
+ <Filter>src\core\surface</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\surface\secure_channel_create.c">
<Filter>src\core\surface</Filter>
</ClCompile>
@@ -286,6 +289,9 @@
<ClCompile Include="..\..\src\core\surface\server_create.c">
<Filter>src\core\surface</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\surface_trace.c">
+ <Filter>src\core\surface</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\alpn.c">
<Filter>src\core\transport\chttp2</Filter>
</ClCompile>
@@ -590,6 +596,9 @@
<ClInclude Include="..\..\src\core\surface\event_string.h">
<Filter>src\core\surface</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\core\surface\init.h">
+ <Filter>src\core\surface</Filter>
+ </ClInclude>
<ClInclude Include="..\..\src\core\surface\lame_client.h">
<Filter>src\core\surface</Filter>
</ClInclude>
diff --git a/vsprojects/vs2013/grpc_unsecure.vcxproj b/vsprojects/vs2013/grpc_unsecure.vcxproj
index 0c81ec4768..9181db0b4e 100644
--- a/vsprojects/vs2013/grpc_unsecure.vcxproj
+++ b/vsprojects/vs2013/grpc_unsecure.vcxproj
@@ -145,6 +145,7 @@
<ClInclude Include="..\..\src\core\surface\client.h" />
<ClInclude Include="..\..\src\core\surface\completion_queue.h" />
<ClInclude Include="..\..\src\core\surface\event_string.h" />
+ <ClInclude Include="..\..\src\core\surface\init.h" />
<ClInclude Include="..\..\src\core\surface\lame_client.h" />
<ClInclude Include="..\..\src\core\surface\server.h" />
<ClInclude Include="..\..\src\core\surface\surface_trace.h" />
@@ -172,6 +173,8 @@
<ClInclude Include="..\..\src\core\transport\transport_impl.h" />
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\..\src\core\surface\init_unsecure.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\channel\call_op_string.c">
</ClCompile>
<ClCompile Include="..\..\src\core\channel\census_filter.c">
@@ -320,6 +323,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\surface\server_create.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\surface_trace.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\alpn.c">
</ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\bin_encoder.c">
diff --git a/vsprojects/vs2013/grpc_unsecure.vcxproj.filters b/vsprojects/vs2013/grpc_unsecure.vcxproj.filters
index 4b5370a573..4583fa41ea 100644
--- a/vsprojects/vs2013/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/vs2013/grpc_unsecure.vcxproj.filters
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
+ <ClCompile Include="..\..\src\core\surface\init_unsecure.c">
+ <Filter>src\core\surface</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\channel\call_op_string.c">
<Filter>src\core\channel</Filter>
</ClCompile>
@@ -223,6 +226,9 @@
<ClCompile Include="..\..\src\core\surface\server_create.c">
<Filter>src\core\surface</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\surface\surface_trace.c">
+ <Filter>src\core\surface</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\transport\chttp2\alpn.c">
<Filter>src\core\transport\chttp2</Filter>
</ClCompile>
@@ -482,6 +488,9 @@
<ClInclude Include="..\..\src\core\surface\event_string.h">
<Filter>src\core\surface</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\core\surface\init.h">
+ <Filter>src\core\surface</Filter>
+ </ClInclude>
<ClInclude Include="..\..\src\core\surface\lame_client.h">
<Filter>src\core\surface</Filter>
</ClInclude>