diff --git a/CMakeLists.txt b/CMakeLists.txt index 874188e..15c8afa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project(core - VERSION 0.2.10 + VERSION 0.2.11 LANGUAGES C) add_executable(core src/main.c) diff --git a/src/cache.c b/src/cache.c index fe968d5..e1ec911 100644 --- a/src/cache.c +++ b/src/cache.c @@ -170,8 +170,11 @@ cache_invalidate_relay(int relay_id) cache_invalidate(key); relay_t *relay = relay_get_by_id(relay_id); - cache_invalidate_controller(relay->controller_id); - relay_free(relay); + if(relay) + { + cache_invalidate_controller(relay->controller_id); + relay_free(relay); + } } diff --git a/src/models/relay.c b/src/models/relay.c index b0ed160..d6c1f3b 100644 --- a/src/models/relay.c +++ b/src/models/relay.c @@ -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); + + LOGGER_DEBUG("rebuilding relay_schedule junction\n"); for(int i = 0; i < 7; ++i) { junction_relay_schedule_insert(i, relay->id, relay->schedules[i]->id);