summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Instance.cxx4
-rw-r--r--src/Instance.hxx2
-rw-r--r--src/Main.cxx12
-rw-r--r--src/command/NeighborCommands.cxx2
4 files changed, 9 insertions, 11 deletions
diff --git a/src/Instance.cxx b/src/Instance.cxx
index 986d4dfed..f9aca0038 100644
--- a/src/Instance.cxx
+++ b/src/Instance.cxx
@@ -34,6 +34,10 @@
#include "db/update/Service.hxx"
#include "storage/StorageInterface.hxx"
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+#include "neighbor/Glue.hxx"
+#endif
+
#ifdef ENABLE_SQLITE
#include "sticker/Database.hxx"
#include "sticker/SongSticker.hxx"
diff --git a/src/Instance.hxx b/src/Instance.hxx
index 78e9ffb09..5626ceb33 100644
--- a/src/Instance.hxx
+++ b/src/Instance.hxx
@@ -101,7 +101,7 @@ struct Instance final
MaskMonitor idle_monitor;
#ifdef ENABLE_NEIGHBOR_PLUGINS
- NeighborGlue *neighbors;
+ std::unique_ptr<NeighborGlue> neighbors;
#endif
#ifdef ENABLE_DATABASE
diff --git a/src/Main.cxx b/src/Main.cxx
index 1c0608360..d51a2c2bf 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -448,15 +448,13 @@ MainOrThrow(int argc, char *argv[])
};
#ifdef ENABLE_NEIGHBOR_PLUGINS
- instance->neighbors = new NeighborGlue();
+ instance->neighbors = std::make_unique<NeighborGlue>();
instance->neighbors->Init(raw_config,
instance->io_thread.GetEventLoop(),
*instance);
- if (instance->neighbors->IsEmpty()) {
- delete instance->neighbors;
- instance->neighbors = nullptr;
- }
+ if (instance->neighbors->IsEmpty())
+ instance->neighbors.reset();
#endif
const unsigned max_clients =
@@ -625,10 +623,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
delete instance->client_list;
-#ifdef ENABLE_NEIGHBOR_PLUGINS
- delete instance->neighbors;
-#endif
-
return EXIT_SUCCESS;
}
diff --git a/src/command/NeighborCommands.cxx b/src/command/NeighborCommands.cxx
index b1fcac369..d529ad580 100644
--- a/src/command/NeighborCommands.cxx
+++ b/src/command/NeighborCommands.cxx
@@ -37,7 +37,7 @@ CommandResult
handle_listneighbors(Client &client, gcc_unused Request args, Response &r)
{
const NeighborGlue *const neighbors =
- client.GetInstance().neighbors;
+ client.GetInstance().neighbors.get();
if (neighbors == nullptr) {
r.Error(ACK_ERROR_UNKNOWN, "No neighbor plugin configured");
return CommandResult::ERROR;