Cleanup, added also a macro for printing dcb state.

This commit is contained in:
vraatikka 2013-10-23 09:11:20 +03:00
parent 1ef015196b
commit da60fe701c
3 changed files with 18 additions and 10 deletions

View File

@ -340,11 +340,13 @@ poll_waitevents(void *arg)
skygw_log_write_flush(
LOGFILE_DEBUG,
"%lu [poll_waitevents] event %d dcb %p",
"%lu [poll_waitevents] event %d dcb %p "
"role %s",
pthread_self(),
ev,
dcb);
dcb,
STRDCBROLE(dcb->dcb_role));
if (ev & EPOLLERR)
{
int eno = gw_getsockerrno(dcb->fd);
@ -354,7 +356,8 @@ poll_waitevents(void *arg)
skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"Added fake errno %d. %s",
"Added fake errno %d. "
"%s",
pthread_self(),
eno,
strerror(eno));

View File

@ -58,7 +58,7 @@ static SESSION *allSessions = NULL;
* @return The newly created session or NULL if an error occured
*/
SESSION *
session_alloc(SERVICE *service, DCB *client)
session_alloc(SERVICE *service, DCB *client_dcb)
{
SESSION *session;
@ -88,7 +88,7 @@ session_alloc(SERVICE *service, DCB *client)
*/
spinlock_acquire(&session->ses_lock);
session->service = service;
session->client = client;
session->client = client_dcb;
memset(&session->stats, 0, sizeof(SESSION_STATS));
session->stats.connect = time(0);
session->state = SESSION_STATE_ALLOC;
@ -99,8 +99,8 @@ session_alloc(SERVICE *service, DCB *client)
* session has not been made available to the other threads at this
* point.
*/
session->data = client->data;
client->session = session;
session->data = client_dcb->data;
client_dcb->session = session;
session->refcount = 1;
/**
* This indicates that session is ready to be shared with backend
@ -121,14 +121,14 @@ session_alloc(SERVICE *service, DCB *client)
* session, therefore it is important that the session lock is
* relinquished beforethe router call.
*/
if (client->state != DCB_STATE_LISTENING)
if (client_dcb->state != DCB_STATE_LISTENING)
{
session->router_session =
service->router->newSession(service->router_instance,
session);
if (session->router_session == NULL) {
client->session = NULL;
client_dcb->session = NULL;
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to create router "

View File

@ -170,6 +170,11 @@ typedef enum skygw_chk_t {
((s) == MYSQL_SESSION_CHANGE ? "MYSQL_SESSION_CHANGE" : \
"UNKNOWN MYSQL STATE"))))))))))
#define STRDCBROLE(r) ((r) == DCB_ROLE_SERVICE_LISTENER ? "DCB_ROLE_SERVICE_LISTENER" : \
((r) == DCB_ROLE_REQUEST_HANDLER ? "DCB_ROLE_REQUEST_HANDLER" : \
"UNKNOWN DCB ROLE"))
#define CHK_MLIST(l) { \
ss_info_dassert((l->mlist_chk_top == CHK_NUM_MLIST && \
l->mlist_chk_tail == CHK_NUM_MLIST), \