gluon-mesh-babel: respondd: Do not create neighbour watcher thread when unable to allocate memory for neighbour json

We don't need a thread parsing babeld if there is not enough memory to store the results. Print an error message in this case andcontinue without neighbour information in respondd data
This commit is contained in:
Christof Schulze 2020-01-05 11:53:55 +01:00
parent 005b8bd5f0
commit ed191a2789

View File

@ -477,8 +477,13 @@ __attribute__((constructor)) static void init(void) {
model = gluonutil_read_line("/tmp/sysinfo/model");
if (pthread_create(&babelmonitor, NULL, &babeld_monitor_thread_start, NULL) < 0 ) {
perror("error on pthread_create for babel monitor");
if (neighbours) {
if (pthread_create(&babelmonitor, NULL, &babeld_monitor_thread_start, NULL) < 0 ) {
perror("error on pthread_create for babel monitor");
}
}
else {
fprintf(stderr, "Unable to allocate json object >neighbours< - not creating neighbour watcher thread. The neighbour structure will always be empty.\n");
}
}