Fix alteration of new router parameters
If a router parameter has no default value, the previous value would be returned as an empty string. A debug assertion would be triggered when a parameter of this type was altered. When a new router parameter is encountered and the alteration fails, the modified value in the service need to be removed. Previously, the new value would have been stored in the service with an empty value which would have caused problems.
This commit is contained in:
@ -1780,6 +1780,41 @@ void service_add_parameters(SERVICE *service, const char* key, const char* value
|
||||
service_add_parameters(service, &p);
|
||||
}
|
||||
|
||||
void service_remove_parameter(SERVICE *service, const char* key)
|
||||
{
|
||||
if (MXS_CONFIG_PARAMETER* params = service->svc_config_param)
|
||||
{
|
||||
MXS_CONFIG_PARAMETER* to_free = NULL;
|
||||
|
||||
if (strcasecmp(params->name, key) == 0)
|
||||
{
|
||||
service->svc_config_param = params->next;
|
||||
to_free = params;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (MXS_CONFIG_PARAMETER* p = params->next)
|
||||
{
|
||||
if (strcasecmp(p->name, key) == 0)
|
||||
{
|
||||
params->next = p->next;
|
||||
to_free = p;
|
||||
break;
|
||||
}
|
||||
|
||||
params = p;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_free)
|
||||
{
|
||||
// Set next pointer to null to prevent freeing of other parameters
|
||||
to_free->next = NULL;
|
||||
config_parameter_free(to_free);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void service_replace_parameter(SERVICE *service, const char* key, const char* value)
|
||||
{
|
||||
for (MXS_CONFIG_PARAMETER* p = service->svc_config_param; p; p = p->next)
|
||||
|
Reference in New Issue
Block a user