Removed leak for service with more listeners

Removed leak for service with more listeners:

users are allocated once in service
This commit is contained in:
MassimilianoPinto
2014-11-10 11:08:12 +01:00
parent 37fa9668a9
commit 071e15048d

View File

@ -213,42 +213,46 @@ GWPROTOCOL *funcs;
if (strcmp(port->protocol, "MySQLClient") == 0) { if (strcmp(port->protocol, "MySQLClient") == 0) {
int loaded; int loaded;
/* if (service->users == NULL) {
* Allocate specific data for MySQL users /*
* including hosts and db names * Allocate specific data for MySQL users
*/ * including hosts and db names
service->users = mysql_users_alloc(); */
service->users = mysql_users_alloc();
if ((loaded = load_mysql_users(service)) < 0) if ((loaded = load_mysql_users(service)) < 0)
{ {
LOGIF(LE, (skygw_log_write_flush( LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"Error : Unable to load users from %s:%d for " "Error : Unable to load users from %s:%d for "
"service %s.", "service %s.",
port->address, port->address,
port->port, port->port,
service->name))); service->name)));
hashtable_free(service->users->data); hashtable_free(service->users->data);
free(service->users); free(service->users);
dcb_free(port->listener); dcb_free(port->listener);
port->listener = NULL; port->listener = NULL;
goto retblock; 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;
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Loaded %d MySQL Users for service [%s].",
loaded, service->name)));
} }
/* 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;
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Loaded %d MySQL Users for service [%s].",
loaded, service->name)));
} }
else else
{ {
/* Generic users table */ if (service->users == NULL) {
service->users = users_alloc(); /* Generic users table */
service->users = users_alloc();
}
} }
if ((funcs=(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL)) if ((funcs=(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL))