mysql_client.c:gw_error_client_event & gw_client_hangup_event: added session state check, if session is already closing, don't start redundant call to dcb_close.
mysql_common.c:mysql_protocol_done: added protocol state check. Used not to check it which caused double free of allocated memory.
This commit is contained in:
@ -978,9 +978,10 @@ int below_water;
|
|||||||
}
|
}
|
||||||
if (dolog)
|
if (dolog)
|
||||||
{
|
{
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LD, (skygw_log_write(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_DEBUG,
|
||||||
"Error : Writing to %s socket failed due %d, %s.",
|
"%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||||
|
pthread_self(),
|
||||||
dcb_isclient(dcb) ? "client" : "backend server",
|
dcb_isclient(dcb) ? "client" : "backend server",
|
||||||
saved_errno,
|
saved_errno,
|
||||||
strerror(saved_errno))));
|
strerror(saved_errno))));
|
||||||
|
|||||||
@ -777,11 +777,6 @@ static int gw_error_backend_event(DCB *dcb)
|
|||||||
router = session->service->router;
|
router = session->service->router;
|
||||||
router_instance = session->service->router_instance;
|
router_instance = session->service->router_instance;
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"Backend error event handling.")));
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* Avoid running redundant error handling procedure.
|
* Avoid running redundant error handling procedure.
|
||||||
* dcb_close is already called for the DCB. Thus, either connection is
|
* dcb_close is already called for the DCB. Thus, either connection is
|
||||||
@ -820,6 +815,11 @@ static int gw_error_backend_event(DCB *dcb)
|
|||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"Backend error event handling.")));
|
||||||
|
#endif
|
||||||
router->handleError(router_instance,
|
router->handleError(router_instance,
|
||||||
rsession,
|
rsession,
|
||||||
errbuf,
|
errbuf,
|
||||||
@ -963,14 +963,7 @@ gw_backend_hangup(DCB *dcb)
|
|||||||
|
|
||||||
rsession = session->router_session;
|
rsession = session->router_session;
|
||||||
router = session->service->router;
|
router = session->service->router;
|
||||||
router_instance = session->service->router_instance;
|
router_instance = session->service->router_instance;
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"Backend hangup error handling.")));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
errbuf = mysql_create_custom_error(
|
errbuf = mysql_create_custom_error(
|
||||||
1,
|
1,
|
||||||
@ -999,6 +992,12 @@ gw_backend_hangup(DCB *dcb)
|
|||||||
gwbuf_free(errbuf);
|
gwbuf_free(errbuf);
|
||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"Backend hangup error handling.")));
|
||||||
|
#endif
|
||||||
|
|
||||||
router->handleError(router_instance,
|
router->handleError(router_instance,
|
||||||
rsession,
|
rsession,
|
||||||
errbuf,
|
errbuf,
|
||||||
|
|||||||
@ -1300,12 +1300,19 @@ static int gw_error_client_event(
|
|||||||
STRDCBSTATE(dcb->state),
|
STRDCBSTATE(dcb->state),
|
||||||
(session != NULL ? session : NULL))));
|
(session != NULL ? session : NULL))));
|
||||||
|
|
||||||
|
if (session != NULL && session->state == SESSION_STATE_STOPPING)
|
||||||
|
{
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Client error event handling.")));
|
"Client error event handling.")));
|
||||||
#endif
|
#endif
|
||||||
dcb_close(dcb);
|
dcb_close(dcb);
|
||||||
|
|
||||||
|
retblock:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1380,12 +1387,19 @@ gw_client_hangup_event(DCB *dcb)
|
|||||||
{
|
{
|
||||||
CHK_SESSION(session);
|
CHK_SESSION(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (session != NULL && session->state == SESSION_STATE_STOPPING)
|
||||||
|
{
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Client hangup error handling.")));
|
"Client hangup error handling.")));
|
||||||
#endif
|
#endif
|
||||||
dcb_close(dcb);
|
dcb_close(dcb);
|
||||||
|
|
||||||
|
retblock:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -117,6 +117,10 @@ void mysql_protocol_done (
|
|||||||
|
|
||||||
spinlock_acquire(&p->protocol_lock);
|
spinlock_acquire(&p->protocol_lock);
|
||||||
|
|
||||||
|
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||||
|
{
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
scmd = p->protocol_cmd_history;
|
scmd = p->protocol_cmd_history;
|
||||||
|
|
||||||
while (scmd != NULL)
|
while (scmd != NULL)
|
||||||
@ -127,6 +131,7 @@ void mysql_protocol_done (
|
|||||||
}
|
}
|
||||||
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
||||||
|
|
||||||
|
retblock:
|
||||||
spinlock_release(&p->protocol_lock);
|
spinlock_release(&p->protocol_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1548,7 +1548,7 @@ static void clientReply (
|
|||||||
(uint8_t *)GWBUF_DATA((scur->scmd_cur_cmd->my_sescmd_buf));
|
(uint8_t *)GWBUF_DATA((scur->scmd_cur_cmd->my_sescmd_buf));
|
||||||
size_t len = MYSQL_GET_PACKET_LEN(buf);
|
size_t len = MYSQL_GET_PACKET_LEN(buf);
|
||||||
char* cmdstr = (char *)malloc(len+1);
|
char* cmdstr = (char *)malloc(len+1);
|
||||||
|
/** data+termination character == len */
|
||||||
snprintf(cmdstr, len, "%s", &buf[5]);
|
snprintf(cmdstr, len, "%s", &buf[5]);
|
||||||
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
|||||||
Reference in New Issue
Block a user