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( {
LOGFILE_ERROR, LOGIF(LE, (skygw_log_write_flush(
"Error : Unable to load users from %s:%d for " LOGFILE_ERROR,
"service %s.", "Error : Unable to load users from %s:%d for "
port->address, "service %s.",
port->port, port->address,
service->name))); port->port,
hashtable_free(service->users->data); service->name)));
free(service->users); hashtable_free(service->users->data);
dcb_free(port->listener); free(service->users);
port->listener = NULL; dcb_free(port->listener);
goto retblock; 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 /* 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; service->rate_limit.last=time(NULL) - USERS_REFRESH_TIME;
service->rate_limit.nloads=1;
LOGIF(LM, (skygw_log_write( LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE, LOGFILE_MESSAGE,
"Loaded %d MySQL Users for service [%s].", "Loaded %d MySQL Users for service [%s].",
loaded, service->name))); 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))