aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Julien Boeuf <jboeuf@google.com>2015-02-26 16:41:41 -0800
committerGravatar Julien Boeuf <jboeuf@google.com>2015-03-01 00:20:01 -0800
commit980f600c83d6c213d4037ab69dc8ffca35015e22 (patch)
treebbedd14fc217b0d3d8fd8dc7a285cafaed9af685 /src/core
parentfe3c37c2817a5973d5c0a0d72e2f114d7551fe36 (diff)
Adding support to enable tracing in tsi.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/tsi/fake_transport_security.c20
-rw-r--r--src/core/tsi/ssl_transport_security.c2
-rw-r--r--src/core/tsi/transport_security.c8
-rw-r--r--src/core/tsi/transport_security.h2
-rw-r--r--src/core/tsi/transport_security_interface.h5
5 files changed, 30 insertions, 7 deletions
diff --git a/src/core/tsi/fake_transport_security.c b/src/core/tsi/fake_transport_security.c
index e8af200284..f58f04ea20 100644
--- a/src/core/tsi/fake_transport_security.c
+++ b/src/core/tsi/fake_transport_security.c
@@ -392,8 +392,10 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX;
}
- gpr_log(GPR_INFO, "%s prepared %s.", impl->is_client ? "Client" : "Server",
- tsi_fake_handshake_message_to_string(impl->next_message_to_send));
+ if (tsi_tracing_enabled) {
+ gpr_log(GPR_INFO, "%s prepared %s.", impl->is_client ? "Client" : "Server",
+ tsi_fake_handshake_message_to_string(impl->next_message_to_send));
+ }
impl->next_message_to_send = next_message_to_send;
}
result = drain_frame_to_bytes(bytes, bytes_size, &impl->outgoing);
@@ -401,7 +403,9 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
if (!impl->is_client &&
impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
/* We're done. */
- gpr_log(GPR_INFO, "Server is done.");
+ if (tsi_tracing_enabled) {
+ gpr_log(GPR_INFO, "Server is done.");
+ }
impl->result = TSI_OK;
} else {
impl->needs_incoming_message = 1;
@@ -436,13 +440,17 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
tsi_fake_handshake_message_to_string(received_msg),
tsi_fake_handshake_message_to_string(expected_msg));
}
- gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server",
- tsi_fake_handshake_message_to_string(received_msg));
+ if (tsi_tracing_enabled) {
+ gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server",
+ tsi_fake_handshake_message_to_string(received_msg));
+ }
tsi_fake_frame_reset(&impl->incoming, 0 /* needs_draining */);
impl->needs_incoming_message = 0;
if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
/* We're done. */
- gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server");
+ if (tsi_tracing_enabled) {
+ gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server");
+ }
impl->result = TSI_OK;
}
return TSI_OK;
diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c
index 8446cc4fdc..dc43f7e270 100644
--- a/src/core/tsi/ssl_transport_security.c
+++ b/src/core/tsi/ssl_transport_security.c
@@ -162,7 +162,7 @@ static const char* ssl_error_string(int error) {
/* TODO(jboeuf): Remove when we are past the debugging phase with this code. */
static void ssl_log_where_info(const SSL* ssl, int where, int flag,
const char* msg) {
- if (where & flag) {
+ if ((where & flag) && tsi_tracing_enabled) {
gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg,
SSL_state_string_long(ssl), SSL_state_string(ssl));
}
diff --git a/src/core/tsi/transport_security.c b/src/core/tsi/transport_security.c
index aeb9b3fc17..04b30004fc 100644
--- a/src/core/tsi/transport_security.c
+++ b/src/core/tsi/transport_security.c
@@ -36,6 +36,14 @@
#include <stdlib.h>
#include <string.h>
+/* --- Tracing. --- */
+
+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.h b/src/core/tsi/transport_security.h
index e47e258e59..59e5dcff9a 100644
--- a/src/core/tsi/transport_security.h
+++ b/src/core/tsi/transport_security.h
@@ -40,6 +40,8 @@
extern "C" {
#endif
+extern int tsi_tracing_enabled;
+
/* Base for tsi_frame_protector implementations.
See transport_security_interface.h for documentation. */
typedef struct {
diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h
index 50de7b927f..33a19bef0d 100644
--- a/src/core/tsi/transport_security_interface.h
+++ b/src/core/tsi/transport_security_interface.h
@@ -61,6 +61,11 @@ typedef enum {
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);
+
/* --- tsi_frame_protector object ---
This object protects and unprotects buffers once the handshake is done.