Instance: flush input cache on SIGHUP
This commit is contained in:
parent
29d05cdb8e
commit
d1cc73775f
|
@ -295,6 +295,8 @@ The following table lists the input options valid for all plugins:
|
|||
|
||||
More information can be found in the :ref:`input_plugins` reference.
|
||||
|
||||
.. _input_cache:
|
||||
|
||||
Configuring the Input Cache
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -327,6 +329,9 @@ configuration file:
|
|||
This allocates a cache of 1 GB. If the cache grows larger than that,
|
||||
older files will be evicted.
|
||||
|
||||
You flush the cache at any time by sending ``SIGHUP`` to the
|
||||
:program:`MPD` process, see :ref:`signals`.
|
||||
|
||||
|
||||
Configuring decoder plugins
|
||||
---------------------------
|
||||
|
@ -878,6 +883,7 @@ To auto-start :program:`MPD` upon login, type:
|
|||
|
||||
systemctl --user enable mpd
|
||||
|
||||
.. _signals:
|
||||
|
||||
Signals
|
||||
-------
|
||||
|
@ -885,7 +891,8 @@ Signals
|
|||
:program:`MPD` understands the following UNIX signals:
|
||||
|
||||
- ``SIGTERM``, ``SIGINT``: shut down MPD
|
||||
- ``SIGHUP``: reopen log files (send this after log rotation)
|
||||
- ``SIGHUP``: reopen log files (send this after log rotation) and
|
||||
flush caches (see :ref:`input_cache`)
|
||||
|
||||
|
||||
The client
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -209,6 +209,8 @@ struct Instance final
|
|||
}
|
||||
#endif
|
||||
|
||||
void FlushCaches() noexcept;
|
||||
|
||||
private:
|
||||
#ifdef ENABLE_DATABASE
|
||||
/* virtual methods from class DatabaseListener */
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue