Fix bug in dcb; rearrange mysql_backend gw_backend_close to cope with receiving DCB that is no longer linked to a session.

This commit is contained in:
counterpoint
2015-06-09 12:03:58 +01:00
parent d0e92a15f8
commit 393e25e953
2 changed files with 23 additions and 19 deletions

View File

@ -1331,6 +1331,7 @@ dcb_close(DCB *dcb)
dcb->session = NULL;
spinlock_release(&dcb->server->persistlock);
atomic_add(&dcb->server->stats.n_persistent, 1);
atomic_add(&dcb->server->stats.n_current, -1);
}
else
{

View File

@ -1140,7 +1140,6 @@ gw_backend_close(DCB *dcb)
CHK_DCB(dcb);
session = dcb->session;
CHK_SESSION(session);
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
"%lu [gw_backend_close]",
@ -1153,6 +1152,10 @@ gw_backend_close(DCB *dcb)
mysql_send_com_quit(dcb, 0, quitbuf);
mysql_protocol_done(dcb);
if (session)
{
CHK_SESSION(session);
/**
* The lock is needed only to protect the read of session->state and
* session->client values. Client's state may change by other thread
@ -1164,8 +1167,7 @@ gw_backend_close(DCB *dcb)
* If session->state is STOPPING, start closing client session.
* Otherwise only this backend connection is closed.
*/
if (session != NULL &&
session->state == SESSION_STATE_STOPPING &&
if (session->state == SESSION_STATE_STOPPING &&
session->client != NULL)
{
if (session->client->state == DCB_STATE_POLLING)
@ -1184,6 +1186,7 @@ gw_backend_close(DCB *dcb)
{
spinlock_release(&session->ses_lock);
}
}
return 1;
}