add: logging and NULL-check

This commit is contained in:
Tobias Reisinger 2020-08-15 00:53:34 +02:00
parent 6ab71ca316
commit 7fa462ef1d
3 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project(core project(core
VERSION 0.2.10 VERSION 0.2.11
LANGUAGES C) LANGUAGES C)
add_executable(core src/main.c) add_executable(core src/main.c)

View file

@ -170,8 +170,11 @@ cache_invalidate_relay(int relay_id)
cache_invalidate(key); cache_invalidate(key);
relay_t *relay = relay_get_by_id(relay_id); relay_t *relay = relay_get_by_id(relay_id);
cache_invalidate_controller(relay->controller_id); if(relay)
relay_free(relay); {
cache_invalidate_controller(relay->controller_id);
relay_free(relay);
}
} }

View file

@ -157,8 +157,11 @@ relay_save(relay_t *relay)
} }
} }
LOGGER_DEBUG("rebuilding relay_schedule junction\n");
LOGGER_DEBUG("cleaning relay_schedule junction\n");
junction_relay_schedule_remove_for_relay(relay->id); junction_relay_schedule_remove_for_relay(relay->id);
LOGGER_DEBUG("rebuilding relay_schedule junction\n");
for(int i = 0; i < 7; ++i) for(int i = 0; i < 7; ++i)
{ {
junction_relay_schedule_insert(i, relay->id, relay->schedules[i]->id); junction_relay_schedule_insert(i, relay->id, relay->schedules[i]->id);