Reapply MXS-504 changes subsequent to optimisation changes. Merge SSL processing into non-SSL processing so far as possible, correct usage of OpenSSL, simplify where possible.
This commit is contained in:
@ -44,6 +44,8 @@
|
||||
* 11/06/2015 Martin Brampton COM_QUIT suppressed for persistent connections
|
||||
* 04/09/2015 Martin Brampton Introduce DUMMY session to fulfill guarantee DCB always has session
|
||||
* 09/09/2015 Martin Brampton Modify error handler calls
|
||||
* 11/01/2016 Martin Brampton Remove SSL write code, now handled at lower level;
|
||||
* replace gwbuf_consume by gwbuf_free (multiple).
|
||||
*/
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
@ -73,8 +75,6 @@ static int gw_error_client_event(DCB *dcb);
|
||||
static int gw_client_close(DCB *dcb);
|
||||
static int gw_client_hangup_event(DCB *dcb);
|
||||
int gw_read_client_event_SSL(DCB* dcb);
|
||||
int gw_MySQLWrite_client_SSL(DCB *dcb, GWBUF *queue);
|
||||
int gw_write_client_event_SSL(DCB *dcb);
|
||||
int mysql_send_ok(DCB *dcb, int packet_number, int in_affected_rows, const char* mysql_message);
|
||||
int MySQLSendHandshake(DCB* dcb);
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF **queue);
|
||||
@ -646,25 +646,6 @@ int gw_MySQLWrite_client(DCB *dcb, GWBUF *queue)
|
||||
return dcb_write(dcb, queue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write function for client DCB: writes data from MaxScale to Client using SSL
|
||||
* encryption. The SSH handshake must have already been done.
|
||||
*
|
||||
* @param dcb The DCB of the client
|
||||
* @param queue Queue of buffers to write
|
||||
*/
|
||||
int gw_MySQLWrite_client_SSL(DCB *dcb, GWBUF *queue)
|
||||
{
|
||||
CHK_DCB(dcb);
|
||||
#ifdef SS_DEBUG
|
||||
MySQLProtocol *protocol = NULL;
|
||||
protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
CHK_PROTOCOL(protocol);
|
||||
#endif
|
||||
return dcb_write_SSL(dcb, queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client read event triggered by EPOLLIN
|
||||
*
|
||||
@ -774,10 +755,8 @@ int gw_read_client_event(DCB* dcb)
|
||||
2,
|
||||
0,
|
||||
"failed to create new session");
|
||||
while (read_buffer)
|
||||
{
|
||||
read_buffer = gwbuf_consume(read_buffer, GWBUF_LENGTH(read_buffer));
|
||||
}
|
||||
gwbuf_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -865,10 +844,8 @@ int gw_read_client_event(DCB* dcb)
|
||||
/** SSL was requested and the handshake is either done or
|
||||
* still ongoing. After the handshake is done, the client
|
||||
* will send another auth packet. */
|
||||
while ((read_buffer = gwbuf_consume(read_buffer,GWBUF_LENGTH(read_buffer))))
|
||||
{
|
||||
;
|
||||
}
|
||||
gwbuf_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -962,7 +939,8 @@ int gw_read_client_event(DCB* dcb)
|
||||
|
||||
dcb_close(dcb);
|
||||
}
|
||||
read_buffer = gwbuf_consume(read_buffer, nbytes_read);
|
||||
gwbuf_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1062,7 +1040,8 @@ int gw_read_client_event(DCB* dcb)
|
||||
|
||||
dcb_close(dcb);
|
||||
}
|
||||
read_buffer = gwbuf_consume(read_buffer, nbytes_read);
|
||||
gwbuf_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1172,10 +1151,8 @@ int gw_read_client_event(DCB* dcb)
|
||||
"Session will be closed.");
|
||||
|
||||
}
|
||||
while (read_buffer)
|
||||
{
|
||||
read_buffer = gwbuf_consume(read_buffer, GWBUF_LENGTH(read_buffer));
|
||||
}
|
||||
gwbuf_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1271,56 +1248,6 @@ return_1:
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* EPOLLOUT event arrived and as a consequence, client input buffer (writeq) is
|
||||
* flushed. The data is encrypted and SSL is used. The SSL handshake must have
|
||||
* been successfully completed prior to this function being called.
|
||||
* @param client dcb
|
||||
* @return constantly 1
|
||||
*/
|
||||
int gw_write_client_event_SSL(DCB *dcb)
|
||||
{
|
||||
MySQLProtocol *protocol = NULL;
|
||||
|
||||
CHK_DCB(dcb);
|
||||
|
||||
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
||||
|
||||
if (dcb == NULL)
|
||||
{
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
if (dcb->state == DCB_STATE_DISCONNECTED)
|
||||
{
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
if (dcb->protocol == NULL)
|
||||
{
|
||||
goto return_1;
|
||||
}
|
||||
protocol = (MySQLProtocol *)dcb->protocol;
|
||||
CHK_PROTOCOL(protocol);
|
||||
|
||||
if (protocol->protocol_auth_state == MYSQL_IDLE)
|
||||
{
|
||||
dcb_drain_writeq_SSL(dcb);
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
return_1:
|
||||
#if defined(SS_DEBUG)
|
||||
if (dcb->state == DCB_STATE_POLLING ||
|
||||
dcb->state == DCB_STATE_NOPOLLING ||
|
||||
dcb->state == DCB_STATE_ZOMBIE)
|
||||
{
|
||||
CHK_PROTOCOL(protocol);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind the DCB to a network port or a UNIX Domain Socket.
|
||||
* @param listen_dcb Listener DCB
|
||||
@ -1983,11 +1910,6 @@ int do_ssl_accept(MySQLProtocol* protocol)
|
||||
protocol->use_ssl = true;
|
||||
spinlock_release(&protocol->protocol_lock);
|
||||
|
||||
spinlock_acquire(&dcb->authlock);
|
||||
dcb->func.write = gw_MySQLWrite_client_SSL;
|
||||
dcb->func.write_ready = gw_write_client_event_SSL;
|
||||
spinlock_release(&dcb->authlock);
|
||||
|
||||
rval = 1;
|
||||
|
||||
MXS_INFO("SSL_accept done for %s@%s",
|
||||
|
Reference in New Issue
Block a user