Fix to bug #612, http://bugs.mariadb.com/show_bug.cgi?id=612
Also added error logging in cases where memory allocation failed etc.
This commit is contained in:
@ -646,7 +646,13 @@ getUsers(SERVICE *service, USERS *users)
|
||||
|
||||
users_data = (char *)calloc(nusers, (users_data_row_len * sizeof(char)) + 1);
|
||||
|
||||
if(users_data == NULL) {
|
||||
if (users_data == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
errno,
|
||||
strerror(errno))));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
|
@ -196,8 +196,13 @@ GWPROTOCOL *funcs;
|
||||
|
||||
if (port->listener == NULL)
|
||||
{
|
||||
return 0;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to create listener for service %s.",
|
||||
service->name)));
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if (strcmp(port->protocol, "MySQLClient") == 0) {
|
||||
int loaded;
|
||||
|
||||
@ -206,12 +211,25 @@ GWPROTOCOL *funcs;
|
||||
* including hosts and db names
|
||||
*/
|
||||
service->users = mysql_users_alloc();
|
||||
loaded = load_mysql_users(service);
|
||||
|
||||
|
||||
if ((loaded = load_mysql_users(service)) < 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to load users from %s:%d for "
|
||||
"service %s.",
|
||||
port->address,
|
||||
port->port,
|
||||
service->name)));
|
||||
hashtable_free(service->users->data);
|
||||
free(service->users);
|
||||
dcb_free(port->listener);
|
||||
port->listener = NULL;
|
||||
goto retblock;
|
||||
}
|
||||
/* At service start last update is set to USERS_REFRESH_TIME seconds earlier.
|
||||
* This way MaxScale could try reloading users' just after startup
|
||||
*/
|
||||
|
||||
service->rate_limit.last=time(NULL) - USERS_REFRESH_TIME;
|
||||
service->rate_limit.nloads=1;
|
||||
|
||||
@ -219,14 +237,21 @@ GWPROTOCOL *funcs;
|
||||
LOGFILE_MESSAGE,
|
||||
"Loaded %d MySQL Users for service [%s].",
|
||||
loaded, service->name)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Generic users table */
|
||||
service->users = users_alloc();
|
||||
}
|
||||
|
||||
if ((funcs =
|
||||
(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL)) == NULL)
|
||||
if ((funcs=(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL))
|
||||
== NULL)
|
||||
{
|
||||
if (service->users->data)
|
||||
{
|
||||
hashtable_free(service->users->data);
|
||||
}
|
||||
free(service->users);
|
||||
dcb_free(port->listener);
|
||||
port->listener = NULL;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
@ -235,34 +260,60 @@ GWPROTOCOL *funcs;
|
||||
"for service %s not started.",
|
||||
port->protocol,
|
||||
service->name)));
|
||||
return 0;
|
||||
goto retblock;
|
||||
}
|
||||
memcpy(&(port->listener->func), funcs, sizeof(GWPROTOCOL));
|
||||
port->listener->session = NULL;
|
||||
|
||||
if (port->address)
|
||||
sprintf(config_bind, "%s:%d", port->address, port->port);
|
||||
else
|
||||
sprintf(config_bind, "0.0.0.0:%d", port->port);
|
||||
|
||||
if (port->listener->func.listen(port->listener, config_bind)) {
|
||||
if (port->listener->func.listen(port->listener, config_bind))
|
||||
{
|
||||
port->listener->session = session_alloc(service, port->listener);
|
||||
|
||||
if (port->listener->session != NULL) {
|
||||
if (port->listener->session != NULL)
|
||||
{
|
||||
port->listener->session->state = SESSION_STATE_LISTENER;
|
||||
listeners += 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to create session to service %s.",
|
||||
service->name)));
|
||||
|
||||
if (service->users->data)
|
||||
{
|
||||
hashtable_free(service->users->data);
|
||||
}
|
||||
free(service->users);
|
||||
dcb_close(port->listener);
|
||||
port->listener = NULL;
|
||||
goto retblock;
|
||||
}
|
||||
} else {
|
||||
dcb_close(port->listener);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to start to listen port %d for %s %s.",
|
||||
port->port,
|
||||
port->protocol,
|
||||
service->name)));
|
||||
if (service->users->data)
|
||||
{
|
||||
hashtable_free(service->users->data);
|
||||
}
|
||||
free(service->users);
|
||||
dcb_close(port->listener);
|
||||
port->listener = NULL;
|
||||
}
|
||||
|
||||
retblock:
|
||||
return listeners;
|
||||
}
|
||||
|
||||
|
@ -1898,6 +1898,10 @@ static int routeQuery(
|
||||
/** Lock router session */
|
||||
if (!rses_begin_locked_router_action(router_cli_ses))
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Route query aborted! Routing session is closed <")));
|
||||
ret = 0;
|
||||
goto retblock;
|
||||
}
|
||||
/**
|
||||
|
Reference in New Issue
Block a user