summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 877672d)
raw | patch | inline | side by side (parent: 877672d)
author | Maryam Tahhan <maryam.tahhan@intel.com> | |
Wed, 8 Feb 2017 13:48:12 +0000 (13:48 +0000) | ||
committer | Maryam Tahhan <maryam.tahhan@intel.com> | |
Wed, 8 Feb 2017 13:48:12 +0000 (13:48 +0000) |
Fix the configuration to stop collectd bombing out and deal with configuration
errors gracefully. Otherwise collectd will fail at the configuration phase
with: "Error: Reading the config file failed!".
Signed-off-by: Tahhan, Maryam <maryam.tahhan@intel.com>
errors gracefully. Otherwise collectd will fail at the configuration phase
with: "Error: Reading the config file failed!".
Signed-off-by: Tahhan, Maryam <maryam.tahhan@intel.com>
src/intel_rdt.c | patch | blob | history |
diff --git a/src/intel_rdt.c b/src/intel_rdt.c
index 2ef65f57f8737c02158a6bf52131dfa230646a1e..7328836694dee755dbdeaa38c51413286dfa6c52 100644 (file)
--- a/src/intel_rdt.c
+++ b/src/intel_rdt.c
#define RDT_MAX_SOCKET_CORES 64
#define RDT_MAX_CORES (RDT_MAX_SOCKET_CORES * RDT_MAX_SOCKETS)
+typedef enum {
+ UNKNOWN = 0,
+ CONFIGURATION_ERROR,
+} rdt_config_status;
+
struct rdt_core_group_s {
char *desc;
size_t num_cores;
static rdt_ctx_t *g_rdt = NULL;
+static rdt_config_status g_state = UNKNOWN;
+
static int isdup(const uint64_t *nums, size_t size, uint64_t val) {
for (size_t i = 0; i < size; i++)
if (nums[i] == val)
int ret = 0;
ret = rdt_preinit();
- if (ret != 0)
- return ret;
+ if (ret != 0) {
+ g_state = CONFIGURATION_ERROR;
+ /* if we return -1 at this point collectd
+ reports a failure in configuration and
+ aborts
+ */
+ goto exit;
+ }
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (strcasecmp("Cores", child->key) == 0) {
ret = rdt_config_cgroups(child);
- if (ret != 0)
- return ret;
+ if (ret != 0) {
+ g_state = CONFIGURATION_ERROR;
+ /* if we return -1 at this point collectd
+ reports a failure in configuration and
+ aborts
+ */
+ goto exit;
+ }
#if COLLECT_DEBUG
rdt_dump_cgroups();
}
}
+exit:
return (0);
}
static int rdt_init(void) {
int ret;
+ if(g_state == CONFIGURATION_ERROR)
+ return (-1);
+
ret = rdt_preinit();
if (ret != 0)
return ret;