MXS-1220: Fix minor bugs
Destroyed servers were still shown as a part of the servers resource collection. If a parameter defined in persisted configurations was replaced, the value would be appended to itself after it was replaced. Return correct error codes for internal errors. The server check was checking for old parameter locations.
This commit is contained in:
parent
d248c7e081
commit
fdf279265a
@ -476,9 +476,12 @@ ini_handler(void *userdata, const char *section, const char *name, const char *v
|
||||
{
|
||||
/** The values in the persisted configurations are updated versions of
|
||||
* the ones in the main configuration file. */
|
||||
if (is_persisted_config && !config_replace_param(ptr, name, value))
|
||||
if (is_persisted_config)
|
||||
{
|
||||
return 0;
|
||||
if (!config_replace_param(ptr, name, value))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/** Multi-line parameter */
|
||||
else if (!config_append_param(ptr, name, value))
|
||||
|
@ -819,11 +819,23 @@ static inline const char* string_or_null(json_t* json, const char* name)
|
||||
|
||||
static bool server_contains_required_fields(json_t* json)
|
||||
{
|
||||
bool rval = false;
|
||||
json_t* value;
|
||||
|
||||
return (value = json_object_get(json, CN_NAME)) && json_is_string(value) &&
|
||||
(value = json_object_get(json, CN_ADDRESS)) && json_is_string(value) &&
|
||||
(value = json_object_get(json, CN_PORT)) && json_is_integer(value);
|
||||
if ((value = json_object_get(json, CN_NAME)) && json_is_string(value))
|
||||
{
|
||||
/** Object has a name field */
|
||||
json_t* param = json_object_get(json, CN_PARAMETERS);
|
||||
|
||||
if (param &&
|
||||
(value = json_object_get(param, CN_ADDRESS)) && json_is_string(value) &&
|
||||
(value = json_object_get(param, CN_PORT)) && json_is_integer(value))
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
const char* server_relation_types[] =
|
||||
|
@ -206,7 +206,7 @@ HttpResponse cb_get_server(const HttpRequest& request)
|
||||
return HttpResponse(MHD_HTTP_OK, server_to_json(server, request.host()));
|
||||
}
|
||||
|
||||
return HttpResponse(MHD_HTTP_NOT_FOUND);
|
||||
return HttpResponse(MHD_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
HttpResponse cb_all_services(const HttpRequest& request)
|
||||
@ -223,7 +223,7 @@ HttpResponse cb_get_service(const HttpRequest& request)
|
||||
return HttpResponse(MHD_HTTP_OK, service_to_json(service, request.host()));
|
||||
}
|
||||
|
||||
return HttpResponse(MHD_HTTP_NOT_FOUND);
|
||||
return HttpResponse(MHD_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
HttpResponse cb_all_filters(const HttpRequest& request)
|
||||
@ -240,7 +240,7 @@ HttpResponse cb_get_filter(const HttpRequest& request)
|
||||
return HttpResponse(MHD_HTTP_OK, filter_to_json(filter, request.host()));
|
||||
}
|
||||
|
||||
return HttpResponse(MHD_HTTP_NOT_FOUND);
|
||||
return HttpResponse(MHD_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
HttpResponse cb_all_monitors(const HttpRequest& request)
|
||||
@ -257,7 +257,7 @@ HttpResponse cb_get_monitor(const HttpRequest& request)
|
||||
return HttpResponse(MHD_HTTP_OK, monitor_to_json(monitor, request.host()));
|
||||
}
|
||||
|
||||
return HttpResponse(MHD_HTTP_NOT_FOUND);
|
||||
return HttpResponse(MHD_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
HttpResponse cb_all_sessions(const HttpRequest& request)
|
||||
|
@ -1370,16 +1370,19 @@ json_t* server_list_to_json(const char* host)
|
||||
|
||||
for (SERVER* server = allServers; server; server = server->next)
|
||||
{
|
||||
json_t* srv_json = server_to_json(server, host);
|
||||
|
||||
if (srv_json == NULL)
|
||||
if (SERVER_IS_ACTIVE(server))
|
||||
{
|
||||
json_decref(rval);
|
||||
rval = NULL;
|
||||
break;
|
||||
}
|
||||
json_t* srv_json = server_to_json(server, host);
|
||||
|
||||
json_array_append_new(rval, srv_json);
|
||||
if (srv_json == NULL)
|
||||
{
|
||||
json_decref(rval);
|
||||
rval = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
json_array_append_new(rval, srv_json);
|
||||
}
|
||||
}
|
||||
|
||||
spinlock_release(&server_spin);
|
||||
|
Loading…
x
Reference in New Issue
Block a user