Added spinlock ses_lock to struct SESSION to ensure that for each session closeSession is called only once.
closeSession is called from mysql_backend.c:gw_read_backend_event, and from dcb.c:dcb_close. This is part of Bug #163.
This commit is contained in:
@ -611,11 +611,29 @@ dcb_close(DCB *dcb)
|
||||
*/
|
||||
SERVICE *service = dcb->session->service;
|
||||
|
||||
if (service && service->router && dcb->session->router_session)
|
||||
if (service != NULL &&
|
||||
service->router != NULL &&
|
||||
dcb->session->router_session != NULL)
|
||||
{
|
||||
service->router->closeSession(
|
||||
service->router_instance,
|
||||
dcb->session->router_session);
|
||||
void* rsession = NULL;
|
||||
/**
|
||||
* Protect call of closeSession.
|
||||
*/
|
||||
spinlock_acquire(&dcb->session->ses_lock);
|
||||
rsession = dcb->session->router_session;
|
||||
dcb->session->router_session = NULL;
|
||||
spinlock_release(&dcb->session->ses_lock);
|
||||
|
||||
if (rsession != NULL) {
|
||||
service->router->closeSession(
|
||||
service->router_instance,
|
||||
rsession);
|
||||
} else {
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
"%lu [dcb_close] rsession was NULL in dcb_close.",
|
||||
pthread_self());
|
||||
}
|
||||
}
|
||||
session_free(dcb->session);
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ SESSION *session;
|
||||
|
||||
if ((session = (SESSION *)malloc(sizeof(SESSION))) == NULL)
|
||||
return NULL;
|
||||
spinlock_init(&session->ses_lock);
|
||||
session->service = service;
|
||||
session->client = client;
|
||||
memset(&session->stats, 0, sizeof(SESSION_STATS));
|
||||
|
||||
Reference in New Issue
Block a user