service->user is now set to NULL after the users are freed.
This commit is contained in:
Markus Makela
2015-10-17 18:01:58 +03:00
parent 040587c828
commit 06f6b28048
2 changed files with 23 additions and 10 deletions

View File

@ -258,8 +258,8 @@ GWPROTOCOL *funcs;
} }
if (loaded == -1) if (loaded == -1)
{ {
hashtable_free(service->users->data); users_free(service->users);
free(service->users); service->users = NULL;
dcb_close(port->listener); dcb_close(port->listener);
port->listener = NULL; port->listener = NULL;
goto retblock; goto retblock;
@ -346,6 +346,7 @@ GWPROTOCOL *funcs;
== NULL) == NULL)
{ {
users_free(service->users); users_free(service->users);
service->users = NULL;
dcb_close(port->listener); dcb_close(port->listener);
port->listener = NULL; port->listener = NULL;
LOGIF(LE, (skygw_log_write_flush( LOGIF(LE, (skygw_log_write_flush(
@ -380,7 +381,8 @@ GWPROTOCOL *funcs;
service->name))); service->name)));
users_free(service->users); users_free(service->users);
dcb_close(port->listener); service->users = NULL;
dcb_close(port->listener);
port->listener = NULL; port->listener = NULL;
goto retblock; goto retblock;
} }
@ -394,6 +396,7 @@ GWPROTOCOL *funcs;
port->protocol, port->protocol,
service->name))); service->name)));
users_free(service->users); users_free(service->users);
service->users = NULL;
dcb_close(port->listener); dcb_close(port->listener);
port->listener = NULL; port->listener = NULL;
} }

View File

@ -678,13 +678,14 @@ static struct {
* Convert a string argument to a numeric, observing prefixes * Convert a string argument to a numeric, observing prefixes
* for number bases, e.g. 0x for hex, 0 for octal * for number bases, e.g. 0x for hex, 0 for octal
* *
* @param dcb The client DCB
* @param mode The CLI mode * @param mode The CLI mode
* @param arg The string representation of the argument * @param arg The string representation of the argument
* @param arg_type The target type for the argument * @param arg_type The target type for the argument
* @return The argument as a long integer * @return The argument as a long integer
*/ */
static unsigned long static unsigned long
convert_arg(int mode, char *arg, int arg_type) convert_arg(DCB* dcb, int mode, char *arg, int arg_type)
{ {
unsigned long rval; unsigned long rval;
SERVICE *service; SERVICE *service;
@ -710,9 +711,18 @@ SERVICE *service;
{ {
service = service_find(arg); service = service_find(arg);
if (service) if (service)
{
if(service->users == NULL)
{
dcb_printf(dcb, "The dbusers for service %s are not loaded. "
"Reload the dbusers and try again.\n", service->name);
}
return (unsigned long)(service->users); return (unsigned long)(service->users);
}
else else
{
return 0; return 0;
}
} }
return rval; return rval;
case ARG_TYPE_DCB: case ARG_TYPE_DCB:
@ -927,7 +937,7 @@ int nskip = 0;
cmds[i].options[j].fn(dcb); cmds[i].options[j].fn(dcb);
break; break;
case 1: case 1:
arg1 = convert_arg(cli->mode, args[2],cmds[i].options[j].arg_types[0]); arg1 = convert_arg(dcb, cli->mode, args[2],cmds[i].options[j].arg_types[0]);
if (arg1) if (arg1)
cmds[i].options[j].fn(dcb, arg1); cmds[i].options[j].fn(dcb, arg1);
@ -936,8 +946,8 @@ int nskip = 0;
args[2]); args[2]);
break; break;
case 2: case 2:
arg1 = convert_arg(cli->mode, args[2],cmds[i].options[j].arg_types[0]); arg1 = convert_arg(dcb, cli->mode, args[2],cmds[i].options[j].arg_types[0]);
arg2 = convert_arg(cli->mode, args[3],cmds[i].options[j].arg_types[1]); arg2 = convert_arg(dcb, cli->mode, args[3],cmds[i].options[j].arg_types[1]);
if (arg1 && arg2) if (arg1 && arg2)
cmds[i].options[j].fn(dcb, arg1, arg2); cmds[i].options[j].fn(dcb, arg1, arg2);
else if (arg1 == 0) else if (arg1 == 0)
@ -948,9 +958,9 @@ int nskip = 0;
args[3]); args[3]);
break; break;
case 3: case 3:
arg1 = convert_arg(cli->mode, args[2],cmds[i].options[j].arg_types[0]); arg1 = convert_arg(dcb, cli->mode, args[2],cmds[i].options[j].arg_types[0]);
arg2 = convert_arg(cli->mode, args[3],cmds[i].options[j].arg_types[1]); arg2 = convert_arg(dcb, cli->mode, args[3],cmds[i].options[j].arg_types[1]);
arg3 = convert_arg(cli->mode, args[4],cmds[i].options[j].arg_types[2]); arg3 = convert_arg(dcb, cli->mode, args[4],cmds[i].options[j].arg_types[2]);
if (arg1 && arg2 && arg3) if (arg1 && arg2 && arg3)
cmds[i].options[j].fn(dcb, arg1, arg2, arg3); cmds[i].options[j].fn(dcb, arg1, arg2, arg3);
else if (arg1 == 0) else if (arg1 == 0)