Adding support to enable tracing in tsi.

pull/854/head
Julien Boeuf 10 years ago
parent fe3c37c281
commit 980f600c83
  1. 20
      src/core/tsi/fake_transport_security.c
  2. 2
      src/core/tsi/ssl_transport_security.c
  3. 8
      src/core/tsi/transport_security.c
  4. 2
      src/core/tsi/transport_security.h
  5. 5
      src/core/tsi/transport_security_interface.h

@ -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;

@ -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));
}

@ -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) {

@ -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 {

@ -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.

Loading…
Cancel
Save