Added more function parameter checks.

This commit is contained in:
Markus Makela
2015-08-18 22:19:26 +03:00
parent 98ab399e6e
commit 3f26c306c5
2 changed files with 29 additions and 11 deletions

View File

@ -1581,10 +1581,17 @@ void check_drop_tmp_table(
DCB* master_dcb = NULL; DCB* master_dcb = NULL;
rses_property_t* rses_prop_tmp; rses_property_t* rses_prop_tmp;
if(router_cli_ses == NULL || querybuf == NULL)
{
skygw_log_write(LE,"[%s] Error: NULL parameters passed: %p %p",
__FUNCTION__,router_cli_ses,querybuf);
return;
}
rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
master_dcb = router_cli_ses->rses_master_ref->bref_dcb; master_dcb = router_cli_ses->rses_master_ref->bref_dcb;
if(master_dcb == NULL) if(master_dcb == NULL || master_dcb->session == NULL)
{ {
skygw_log_write(LE,"[%s] Error: Master server DBC is NULL. " skygw_log_write(LE,"[%s] Error: Master server DBC is NULL. "
"This means that the connection to the master server is already " "This means that the connection to the master server is already "
@ -1659,10 +1666,17 @@ static skygw_query_type_t is_read_tmp_table(
skygw_query_type_t qtype = type; skygw_query_type_t qtype = type;
rses_property_t* rses_prop_tmp; rses_property_t* rses_prop_tmp;
if(router_cli_ses == NULL || querybuf == NULL)
{
skygw_log_write(LE,"[%s] Error: NULL parameters passed: %p %p",
__FUNCTION__,router_cli_ses,querybuf);
return type;
}
rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
master_dcb = router_cli_ses->rses_master_ref->bref_dcb; master_dcb = router_cli_ses->rses_master_ref->bref_dcb;
if(master_dcb == NULL) if(master_dcb == NULL || master_dcb->session == NULL)
{ {
skygw_log_write(LE,"[%s] Error: Master server DBC is NULL. " skygw_log_write(LE,"[%s] Error: Master server DBC is NULL. "
"This means that the connection to the master server is already " "This means that the connection to the master server is already "
@ -1740,22 +1754,26 @@ static void check_create_tmp_table(
GWBUF* querybuf, GWBUF* querybuf,
skygw_query_type_t type) skygw_query_type_t type)
{ {
int klen = 0; int klen = 0;
char *hkey,*dbname; char *hkey,*dbname;
MYSQL_session* data; MYSQL_session* data;
DCB* master_dcb = NULL; DCB* master_dcb = NULL;
rses_property_t* rses_prop_tmp; rses_property_t* rses_prop_tmp;
HASHTABLE* h; HASHTABLE* h;
if(router_cli_ses == NULL || querybuf == NULL)
{
skygw_log_write(LE,"[%s] Error: NULL parameters passed: %p %p",
__FUNCTION__,router_cli_ses,querybuf);
return;
}
rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; rses_prop_tmp = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
master_dcb = router_cli_ses->rses_master_ref->bref_dcb; master_dcb = router_cli_ses->rses_master_ref->bref_dcb;
if(master_dcb == NULL) if(master_dcb == NULL || master_dcb->session == NULL)
{ {
skygw_log_write(LE,"[%s] Error: Master server DBC is NULL. " skygw_log_write(LE,"[%s] Error: Master server DCB is NULL. "
"This means that the connection to the master server is already " "This means that the connection to the master server is already "
"closed while a query is still being routed.",__FUNCTION__); "closed while a query is still being routed.",__FUNCTION__);
return; return;

View File

@ -33,7 +33,7 @@ static void *newSession(ROUTER *instance, SESSION *session);
static void closeSession(ROUTER *instance, void *session); static void closeSession(ROUTER *instance, void *session);
static void freeSession(ROUTER *instance, void *session); static void freeSession(ROUTER *instance, void *session);
static int routeQuery(ROUTER *instance, void *session, GWBUF *queue); static int routeQuery(ROUTER *instance, void *session, GWBUF *queue);
static void clientReply(ROUTER *instance, void *session, GWBUF *queue); static void clientReply(ROUTER *instance, void *session, GWBUF *queue,DCB*);
static void diagnostic(ROUTER *instance, DCB *dcb); static void diagnostic(ROUTER *instance, DCB *dcb);
static uint8_t getCapabilities (ROUTER* inst, void* router_session); static uint8_t getCapabilities (ROUTER* inst, void* router_session);
static void handleError( static void handleError(
@ -151,7 +151,7 @@ routeQuery(ROUTER *instance, void *session, GWBUF *queue)
return 0; return 0;
} }
void clientReply(ROUTER* instance, void* session, GWBUF* queue) void clientReply(ROUTER* instance, void* session, GWBUF* queue, DCB* dcb)
{ {
} }