From 1c36cfb28592a549d526a97ea47a6064afba278b Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 8 Jun 2015 18:04:43 +0300 Subject: [PATCH] Added more debug output. --- server/core/dcb.c | 15 +++++++++++---- .../include/mysql_client_server_protocol.h | 4 ++-- server/modules/protocol/mysql_client.c | 11 +++++++++++ server/modules/protocol/mysql_common.c | 6 +++++- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/server/core/dcb.c b/server/core/dcb.c index e7862dbd4..cc8d77259 100644 --- a/server/core/dcb.c +++ b/server/core/dcb.c @@ -2825,14 +2825,19 @@ int dcb_create_SSL(DCB* dcb) */ int dcb_accept_SSL(DCB* dcb) { - int rval = 0,ssl_rval,errnum,fd,b = 0; + int rval = 0,ssl_rval,errnum = 0,fd,b = 0; char errbuf[140]; fd = dcb->fd; ioctl(fd,FIONREAD,&b); +#ifdef SS_DEBUG + skygw_log_write(LD,"[dcb_accept_SSL] fd %d bytes: %d",fd,b); +#endif while(b > 0 && rval != -1) { ssl_rval = SSL_accept(dcb->ssl); - +#ifdef SS_DEBUG + skygw_log_write(LD,"[dcb_accept_SSL] SSL_accept returned %d.",ssl_rval); +#endif switch(ssl_rval) { case 0: @@ -2882,8 +2887,10 @@ int dcb_accept_SSL(DCB* dcb) break; } ioctl(fd,FIONREAD,&b); - if(LOG_IS_ENABLED(LD) && b > 0) - skygw_log_write_flush(LD,"[dcb_accept_SSL] FD %d has %d bytes ",fd,b); +#ifdef SS_DEBUG + skygw_log_write_flush(LD,"[dcb_accept_SSL] fd %d: %d bytes",fd,b); + skygw_log_write_flush(LD,"[dcb_accept_SSL] SSL error: %d",errnum); +#endif } return rval; } diff --git a/server/modules/include/mysql_client_server_protocol.h b/server/modules/include/mysql_client_server_protocol.h index f72416491..905f57dd3 100644 --- a/server/modules/include/mysql_client_server_protocol.h +++ b/server/modules/include/mysql_client_server_protocol.h @@ -321,7 +321,7 @@ typedef struct { #define MYSQL_IS_CHANGE_USER(payload) (MYSQL_GET_COMMAND(payload)==0x11) #define MYSQL_GET_NATTR(payload) ((int)payload[4]) -#endif /** _MYSQL_PROTOCOL_H */ + MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd); void mysql_protocol_done (DCB* dcb); @@ -417,4 +417,4 @@ void init_response_status ( int* npackets, ssize_t* nbytes); - +#endif /** _MYSQL_PROTOCOL_H */ \ No newline at end of file diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index dc5c08d89..fcbb1958e 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -652,9 +652,16 @@ int gw_read_client_event( protocol = DCB_PROTOCOL(dcb, MySQLProtocol); CHK_PROTOCOL(protocol); +#ifdef SS_DEBUG + skygw_log_write(LD,"[gw_read_client_event] Protocol state: %s", + gw_mysql_protocol_state2string(protocol->protocol_auth_state)); + +#endif + if(protocol->protocol_auth_state == MYSQL_AUTH_SSL_HANDSHAKE_ONGOING || protocol->protocol_auth_state == MYSQL_AUTH_SSL_REQ) { + switch(do_ssl_accept(protocol)) { case 0: @@ -1943,6 +1950,10 @@ int do_ssl_accept(MySQLProtocol* protocol) rval); break; } +#ifdef SS_DEBUG + skygw_log_write(LD,"[do_ssl_accept] Protocol state: %s", + gw_mysql_protocol_state2string(protocol->protocol_auth_state)); +#endif return rval; } diff --git a/server/modules/protocol/mysql_common.c b/server/modules/protocol/mysql_common.c index 0a1d2195b..d8f9a96ba 100644 --- a/server/modules/protocol/mysql_common.c +++ b/server/modules/protocol/mysql_common.c @@ -890,7 +890,11 @@ gw_mysql_protocol_state2string (int state) { case MYSQL_AUTH_FAILED: return "MySQL Authentication failed"; case MYSQL_IDLE: - return "MySQL authentication is succesfully done."; + return "MySQL authentication is succesfully done."; + case MYSQL_AUTH_SSL_REQ: return "MYSQL_AUTH_SSL_REQ"; + case MYSQL_AUTH_SSL_HANDSHAKE_DONE: return "MYSQL_AUTH_SSL_HANDSHAKE_DONE"; + case MYSQL_AUTH_SSL_HANDSHAKE_FAILED: return "MYSQL_AUTH_SSL_HANDSHAKE_FAILED"; + case MYSQL_AUTH_SSL_HANDSHAKE_ONGOING: return "MYSQL_AUTH_SSL_HANDSHAKE_ONGOING"; default: return "MySQL (unknown protocol state)"; }