From 7fa462ef1dcd53765d63c0bafe7f569c9eaabf99 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Sat, 15 Aug 2020 00:53:34 +0200 Subject: [PATCH] add: logging and NULL-check --- CMakeLists.txt | 2 +- src/cache.c | 7 +++++-- src/models/relay.c | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) 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);