Merge branch '2.1' into develop
This commit is contained in:
@ -637,9 +637,7 @@ gw_reply_on_error(DCB *dcb, mxs_auth_state_t state)
|
||||
session->router_session,
|
||||
errbuf, dcb, ERRACT_REPLY_CLIENT, &succp);
|
||||
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
spinlock_release(&session->ses_lock);
|
||||
ss_dassert(dcb->dcb_errhandle_called);
|
||||
}
|
||||
else
|
||||
@ -736,9 +734,7 @@ gw_read_and_write(DCB *dcb)
|
||||
|
||||
if (!succp)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1173,22 +1169,7 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
0,
|
||||
"Lost connection to backend server.");
|
||||
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/**
|
||||
* Session might be initialized when DCB already is in the poll set.
|
||||
* Thus hangup can occur in the middle of session initialization.
|
||||
* Only complete and successfully initialized sessions allow for
|
||||
* calling error handler.
|
||||
*/
|
||||
while (ses_state == SESSION_STATE_READY)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
@ -1225,9 +1206,7 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
*/
|
||||
if (!succp)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
|
||||
retblock:
|
||||
@ -1277,22 +1256,7 @@ static int gw_backend_hangup(DCB *dcb)
|
||||
0,
|
||||
"Lost connection to backend server.");
|
||||
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/**
|
||||
* Session might be initialized when DCB already is in the poll set.
|
||||
* Thus hangup can occur in the middle of session initialization.
|
||||
* Only complete and successfully initialized sessions allow for
|
||||
* calling error handler.
|
||||
*/
|
||||
while (ses_state == SESSION_STATE_READY)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
@ -1330,9 +1294,7 @@ static int gw_backend_hangup(DCB *dcb)
|
||||
/** There are no required backends available, close session. */
|
||||
if (!succp)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
|
||||
retblock:
|
||||
@ -1371,7 +1333,7 @@ static int gw_backend_close(DCB *dcb)
|
||||
* but client's close and adding client's DCB to zombies list is executed
|
||||
* only if client's DCB's state does _not_ change in parallel.
|
||||
*/
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
|
||||
/**
|
||||
* If session->state is STOPPING, start closing client session.
|
||||
* Otherwise only this backend connection is closed.
|
||||
@ -1381,19 +1343,9 @@ static int gw_backend_close(DCB *dcb)
|
||||
{
|
||||
if (session->client_dcb->state == DCB_STATE_POLLING)
|
||||
{
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/** Close client DCB */
|
||||
dcb_close(session->client_dcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -1471,9 +1423,7 @@ static int backend_write_delayqueue(DCB *dcb, GWBUF *buffer)
|
||||
|
||||
if (!succp)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1564,8 +1514,6 @@ static int gw_change_user(DCB *backend,
|
||||
memcpy(&backend_protocol->charset, client_auth_packet, sizeof(int));
|
||||
}
|
||||
|
||||
spinlock_acquire(&in_session->ses_lock);
|
||||
|
||||
/* save current_database name */
|
||||
strcpy(current_database, current_session->db);
|
||||
|
||||
@ -1595,7 +1543,6 @@ static int gw_change_user(DCB *backend,
|
||||
client_sha1, sizeof(client_sha1));
|
||||
|
||||
strcpy(current_session->db, current_database);
|
||||
spinlock_release(&in_session->ses_lock);
|
||||
|
||||
if (auth_ret != 0)
|
||||
{
|
||||
@ -1603,7 +1550,6 @@ static int gw_change_user(DCB *backend,
|
||||
{
|
||||
/* Try authentication again with new repository data */
|
||||
/* Note: if no auth client authentication will fail */
|
||||
spinlock_acquire(&in_session->ses_lock);
|
||||
*current_session->db = 0;
|
||||
|
||||
auth_ret = dcb->authfunc.reauthenticate(dcb, username,
|
||||
@ -1613,7 +1559,6 @@ static int gw_change_user(DCB *backend,
|
||||
client_sha1, sizeof(client_sha1));
|
||||
|
||||
strcpy(current_session->db, current_database);
|
||||
spinlock_release(&in_session->ses_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1361,6 @@ gw_client_close(DCB *dcb)
|
||||
if (session != NULL && SESSION_STATE_DUMMY != session->state)
|
||||
{
|
||||
CHK_SESSION(session);
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
|
||||
if (session->state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
@ -1375,14 +1374,9 @@ gw_client_close(DCB *dcb)
|
||||
*/
|
||||
if (session->router_session != NULL)
|
||||
{
|
||||
spinlock_release(&session->ses_lock);
|
||||
/** Close router session and all its connections */
|
||||
router->closeSession(router_instance, session->router_session);
|
||||
}
|
||||
else
|
||||
{
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -132,27 +132,21 @@ void mysql_protocol_done(DCB* dcb)
|
||||
|
||||
p = (MySQLProtocol *)dcb->protocol;
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||
if (p->protocol_state == MYSQL_PROTOCOL_ACTIVE)
|
||||
{
|
||||
goto retblock;
|
||||
scmd = p->protocol_cmd_history;
|
||||
|
||||
while (scmd != NULL)
|
||||
{
|
||||
scmd2 = scmd->scom_next;
|
||||
MXS_FREE(scmd);
|
||||
scmd = scmd2;
|
||||
}
|
||||
|
||||
gwbuf_free(p->stored_query);
|
||||
|
||||
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
||||
}
|
||||
scmd = p->protocol_cmd_history;
|
||||
|
||||
while (scmd != NULL)
|
||||
{
|
||||
scmd2 = scmd->scom_next;
|
||||
MXS_FREE(scmd);
|
||||
scmd = scmd2;
|
||||
}
|
||||
|
||||
gwbuf_free(p->stored_query);
|
||||
|
||||
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
||||
|
||||
retblock:
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -660,8 +654,6 @@ void protocol_archive_srv_command(MySQLProtocol* p)
|
||||
|
||||
CHK_PROTOCOL(p);
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||
{
|
||||
goto retblock;
|
||||
@ -710,7 +702,6 @@ void protocol_archive_srv_command(MySQLProtocol* p)
|
||||
}
|
||||
|
||||
retblock:
|
||||
spinlock_release(&p->protocol_lock);
|
||||
CHK_PROTOCOL(p);
|
||||
}
|
||||
|
||||
@ -725,11 +716,10 @@ void protocol_add_srv_command(MySQLProtocol* p,
|
||||
#if defined(EXTRA_SS_DEBUG)
|
||||
server_command_t* c;
|
||||
#endif
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||
{
|
||||
goto retblock;
|
||||
return;
|
||||
}
|
||||
/** this is the only server command in protocol */
|
||||
if (p->protocol_command.scom_cmd == MYSQL_COM_UNDEFINED)
|
||||
@ -758,8 +748,6 @@ void protocol_add_srv_command(MySQLProtocol* p,
|
||||
c = c->scom_next;
|
||||
}
|
||||
#endif
|
||||
retblock:
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
|
||||
@ -772,7 +760,7 @@ retblock:
|
||||
void protocol_remove_srv_command(MySQLProtocol* p)
|
||||
{
|
||||
server_command_t* s;
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
s = &p->protocol_command;
|
||||
#if defined(EXTRA_SS_DEBUG)
|
||||
MXS_INFO("Removed command %s from fd %d.",
|
||||
@ -788,8 +776,6 @@ void protocol_remove_srv_command(MySQLProtocol* p)
|
||||
p->protocol_command = *(s->scom_next);
|
||||
MXS_FREE(s->scom_next);
|
||||
}
|
||||
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
mysql_server_cmd_t protocol_get_srv_command(MySQLProtocol* p,
|
||||
@ -889,10 +875,8 @@ bool protocol_get_response_status(MySQLProtocol* p,
|
||||
|
||||
CHK_PROTOCOL(p);
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
*npackets = p->protocol_command.scom_nresponse_packets;
|
||||
*nbytes = (ssize_t)p->protocol_command.scom_nbytes_to_read;
|
||||
spinlock_release(&p->protocol_lock);
|
||||
|
||||
if (*npackets < 0 && *nbytes == 0)
|
||||
{
|
||||
@ -912,14 +896,10 @@ void protocol_set_response_status(MySQLProtocol* p,
|
||||
{
|
||||
CHK_PROTOCOL(p);
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
p->protocol_command.scom_nbytes_to_read = nbytes;
|
||||
ss_dassert(p->protocol_command.scom_nbytes_to_read >= 0);
|
||||
|
||||
p->protocol_command.scom_nresponse_packets = npackets_left;
|
||||
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
char* create_auth_failed_msg(GWBUF*readbuf,
|
||||
|
Reference in New Issue
Block a user