}
}
-void BuildCpusetWithCallback(
+int BuildCpusetWithCallback(
const char *name, SCConfNode *node, void (*Callback)(int i, void *data), void *data)
{
SCConfNode *lnode;
char *sep = strchr(lnode->val, '-');
if (StringParseUint32(&a, 10, sep - lnode->val, lnode->val) < 0) {
SCLogError("%s: invalid cpu range (start invalid): \"%s\"", name, lnode->val);
- exit(EXIT_FAILURE);
+ return -1;
}
if (StringParseUint32(&b, 10, strlen(sep) - 1, sep + 1) < 0) {
SCLogError("%s: invalid cpu range (end invalid): \"%s\"", name, lnode->val);
- exit(EXIT_FAILURE);
+ return -1;
}
if (a > b) {
SCLogError("%s: invalid cpu range (bad order): \"%s\"", name, lnode->val);
- exit(EXIT_FAILURE);
+ return -1;
}
if (b > max) {
SCLogError("%s: upper bound (%d) of cpu set is too high, only %d cpu(s)", name, b,
} else {
if (StringParseUint32(&a, 10, strlen(lnode->val), lnode->val) < 0) {
SCLogError("%s: invalid cpu range (not an integer): \"%s\"", name, lnode->val);
- exit(EXIT_FAILURE);
+ return -1;
}
b = a;
}
break;
}
}
+ return 0;
}
static void AffinityCallback(int i, void *data)
CPU_SET(i, (cpu_set_t *)data);
}
-static void BuildCpuset(const char *name, SCConfNode *node, cpu_set_t *cpu)
+static int BuildCpuset(const char *name, SCConfNode *node, cpu_set_t *cpu)
{
- BuildCpusetWithCallback(name, node, AffinityCallback, (void *) cpu);
+ return BuildCpusetWithCallback(name, node, AffinityCallback, (void *)cpu);
}
/**
CPU_ZERO(&taf->cpu_set);
SCConfNode *cpu_node = SCConfNodeLookupChild(affinity, "cpu");
if (cpu_node != NULL) {
- BuildCpuset(setname, cpu_node, &taf->cpu_set);
+ if (BuildCpuset(setname, cpu_node, &taf->cpu_set) < 0) {
+ SCLogWarning("Failed to parse CPU set for %s", setname);
+ }
} else {
SCLogWarning("Unable to find 'cpu' node for set %s", setname);
}
{
SCConfNode *node = SCConfNodeLookupChild(prio_node, priority);
if (node != NULL) {
- BuildCpuset(setname, node, cpuset);
+ if (BuildCpuset(setname, node, cpuset) < 0) {
+ SCLogWarning("Failed to parse %s priority CPU set for %s", priority, setname);
+ }
} else {
SCLogDebug("Unable to find '%s' priority for set %s", priority, setname);
}