From 175d2c6d2936d914423271e124aa0f18185c063f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 22 Jun 2021 20:31:09 +0200 Subject: [PATCH] Main: use AtScopeExit() to call ZeroconfDeinit() Make sure that ZeroconfDeinit() gets called even if startup fails with an exception. Fixes an assertion failure because an Avahi TimerEvent is still active. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1192 --- src/Main.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Main.cxx b/src/Main.cxx index 9d9a3430b..1a2a94ef5 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -477,6 +477,7 @@ MainConfigured(const struct options &options, const ConfigData &raw_config) #endif ZeroconfInit(raw_config, instance.event_loop); + AtScopeExit() { ZeroconfDeinit(); }; #ifdef ENABLE_DATABASE if (create_db) { @@ -537,9 +538,6 @@ MainConfigured(const struct options &options, const ConfigData &raw_config) instance.state_file->Write(); instance.BeginShutdownUpdate(); - - ZeroconfDeinit(); - instance.BeginShutdownPartitions(); }