MXS-2196: Always allocate a session
Whenever a client DCB is accepted, a session for it is allocated. This simplifies the handling of shared data between DCBs by allowing it to be placed inside the session object. Currently, the data is stashed away in the client DCB.
This commit is contained in:
@ -144,10 +144,7 @@ static int cdc_read_event(DCB* dcb)
|
||||
|
||||
if (auth_val == CDC_STATE_AUTH_OK)
|
||||
{
|
||||
/* start a real session */
|
||||
session = session_alloc(dcb->service, dcb);
|
||||
|
||||
if (session != NULL)
|
||||
if (session_start(dcb->session))
|
||||
{
|
||||
protocol->state = CDC_STATE_HANDLE_REQUEST;
|
||||
|
||||
|
@ -370,8 +370,7 @@ static int httpd_accept(DCB* client_dcb)
|
||||
}
|
||||
client_dcb->data = client_data;
|
||||
|
||||
client_dcb->session = session_alloc(client_dcb->service, client_dcb);
|
||||
if (NULL == client_dcb->session || poll_add_dcb(client_dcb) == -1)
|
||||
if (!session_start(client_dcb->session) || poll_add_dcb(client_dcb) == -1)
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
return 0;
|
||||
|
@ -293,7 +293,7 @@ int MySQLSendHandshake(DCB* dcb)
|
||||
}
|
||||
|
||||
// Get the equivalent of the server thread id.
|
||||
protocol->thread_id = session_get_next_id();
|
||||
protocol->thread_id = dcb->session->ses_id;
|
||||
// Send only the low 32bits in the handshake.
|
||||
gw_mysql_set_byte4(mysql_thread_id_num, (uint32_t)(protocol->thread_id));
|
||||
memcpy(mysql_scramble_buf, server_scramble, 8);
|
||||
@ -766,23 +766,20 @@ static int gw_read_do_authentication(DCB* dcb, GWBUF* read_buffer, int nbytes_re
|
||||
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_RESPONSE_SENT;
|
||||
/**
|
||||
* Create session, and a router session for it.
|
||||
* Start session, and a router session for it.
|
||||
* If successful, there will be backend connection(s)
|
||||
* after this point. The protocol authentication state
|
||||
* is changed so that future data will go through the
|
||||
* normal data handling function instead of this one.
|
||||
*/
|
||||
MXS_SESSION* session =
|
||||
session_alloc_with_id(dcb->service, dcb, protocol->thread_id);
|
||||
|
||||
if (session != NULL)
|
||||
if (session_start(dcb->session))
|
||||
{
|
||||
mxb_assert(session->state != SESSION_STATE_ALLOC
|
||||
&& session->state != SESSION_STATE_DUMMY);
|
||||
mxb_assert(dcb->session->state != SESSION_STATE_ALLOC
|
||||
&& dcb->session->state != SESSION_STATE_DUMMY);
|
||||
// For the time being only the sql_mode is stored in MXS_SESSION::client_protocol_data.
|
||||
session->client_protocol_data = QC_SQL_MODE_DEFAULT;
|
||||
dcb->session->client_protocol_data = QC_SQL_MODE_DEFAULT;
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_COMPLETE;
|
||||
MXB_AT_DEBUG(bool check = ) mxs_rworker_register_session(session);
|
||||
MXB_AT_DEBUG(bool check = ) mxs_rworker_register_session(dcb->session);
|
||||
mxb_assert(check);
|
||||
mxs_mysql_send_ok(dcb, next_sequence, 0, NULL);
|
||||
|
||||
|
@ -373,9 +373,7 @@ static int maxscaled_accept(DCB* client_dcb)
|
||||
pthread_mutex_init(&maxscaled_protocol->lock, NULL);
|
||||
client_dcb->protocol = (void*)maxscaled_protocol;
|
||||
|
||||
client_dcb->session = session_alloc(client_dcb->service, client_dcb);
|
||||
|
||||
if (NULL == client_dcb->session || poll_add_dcb(client_dcb))
|
||||
if (!session_start(client_dcb->session) || poll_add_dcb(client_dcb))
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
return 0;
|
||||
|
@ -289,8 +289,7 @@ static int telnetd_accept(DCB* client_dcb)
|
||||
telnetd_protocol->username = NULL;
|
||||
client_dcb->protocol = (void*)telnetd_protocol;
|
||||
|
||||
client_dcb->session = session_alloc(client_dcb->service, client_dcb);
|
||||
if (NULL == client_dcb->session || poll_add_dcb(client_dcb))
|
||||
if (!session_start(client_dcb->session) || poll_add_dcb(client_dcb))
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user