diff options
author | Max Kellermann <max@musicpd.org> | 2020-02-16 20:38:56 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-02-17 15:23:05 +0100 |
commit | d1cc73775fe96a3c42108a01aad00056060df564 (patch) | |
tree | 967412fa7dd03809c0581fb05de77d28fa82f398 /src | |
parent | 29d05cdb8ecde61ba04cbd8c67c11dd4e76abd53 (diff) |
Instance: flush input cache on SIGHUP
Diffstat (limited to 'src')
-rw-r--r-- | src/Instance.cxx | 7 | ||||
-rw-r--r-- | src/Instance.hxx | 2 | ||||
-rw-r--r-- | src/unix/SignalHandlers.cxx | 10 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/Instance.cxx b/src/Instance.cxx index 2d8003f42..cf25ca201 100644 --- a/src/Instance.cxx +++ b/src/Instance.cxx @@ -198,3 +198,10 @@ Instance::OnIdle(unsigned flags) noexcept for (auto &partition : partitions) partition.EmitIdle(flags); } + +void +Instance::FlushCaches() noexcept +{ + if (input_cache) + input_cache->Flush(); +} diff --git a/src/Instance.hxx b/src/Instance.hxx index 0baebcc26..509610d2a 100644 --- a/src/Instance.hxx +++ b/src/Instance.hxx @@ -209,6 +209,8 @@ struct Instance final } #endif + void FlushCaches() noexcept; + private: #ifdef ENABLE_DATABASE /* virtual methods from class DatabaseListener */ diff --git a/src/unix/SignalHandlers.cxx b/src/unix/SignalHandlers.cxx index 873025ec0..5dbb47778 100644 --- a/src/unix/SignalHandlers.cxx +++ b/src/unix/SignalHandlers.cxx @@ -47,10 +47,14 @@ x_sigaction(int signum, const struct sigaction *act) } static void -handle_reload_event(void *) noexcept +handle_reload_event(void *ctx) noexcept { - LogDebug(signal_handlers_domain, "got SIGHUP, reopening log files"); + auto &instance = *(Instance *)ctx; + + LogDebug(signal_handlers_domain, "got SIGHUP, reopening log files and flushing caches"); cycle_log_files(); + + instance.FlushCaches(); } #endif @@ -73,7 +77,7 @@ SignalHandlersInit(Instance &instance) SignalMonitorRegister(SIGINT, {&loop, HandleShutdownSignal}); SignalMonitorRegister(SIGTERM, {&loop, HandleShutdownSignal}); - SignalMonitorRegister(SIGHUP, {nullptr, handle_reload_event}); + SignalMonitorRegister(SIGHUP, {&instance, handle_reload_event}); #endif } |