Main: move log_deinit() call to mpd_main()

Deinitialize the logging library after the last exception handler,
because that one could still need it.

Use `AtScopeExit()` to ensure it's always called, even if an exception
was thrown.
This commit is contained in:
Max Kellermann 2018-08-01 20:14:31 +02:00
parent 271e49db5d
commit 6ffbb151a0
1 changed files with 3 additions and 2 deletions

View File

@ -59,6 +59,7 @@
#include "config/Option.hxx"
#include "config/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "util/ScopeExit.hxx"
#ifdef ENABLE_DAEMON
#include "unix/Daemon.hxx"
@ -534,6 +535,8 @@ static inline
#endif
int mpd_main(int argc, char *argv[])
{
AtScopeExit() { log_deinit(); };
try {
return MainOrThrow(argc, argv);
} catch (const std::exception &e) {
@ -717,8 +720,6 @@ try {
IcuFinish();
log_deinit();
return EXIT_SUCCESS;
} catch (const std::exception &e) {
LogError(e);