diff --git a/server/core/config.cc b/server/core/config.cc index 9b3712fbd..ee12fe4bf 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -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)) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 969368736..7b8d7d204 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -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[] = diff --git a/server/core/resource.cc b/server/core/resource.cc index ea18daf8e..b0dff7332 100644 --- a/server/core/resource.cc +++ b/server/core/resource.cc @@ -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) diff --git a/server/core/server.cc b/server/core/server.cc index caaca3ed2..fbbec7799 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -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);