From a113848993c483672e9402814ec3c9afeb5127b8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Oct 2023 08:16:38 +0200 Subject: [PATCH] Listener: pass ListenerConfig to ctor --- src/Instance.cxx | 3 +-- src/Listener.cxx | 10 +++++++--- src/Listener.hxx | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Instance.cxx b/src/Instance.cxx index 105260a..13556e0 100644 --- a/src/Instance.cxx +++ b/src/Instance.cxx @@ -23,7 +23,6 @@ #include -#include #include #include @@ -90,7 +89,7 @@ Instance::DisableZeroconf() noexcept void Instance::AddListener(const ListenerConfig &config) { - listeners.emplace_front(*this, config.Create(SOCK_STREAM)); + listeners.emplace_front(*this, config); #ifdef HAVE_AVAHI auto &listener = listeners.front(); diff --git a/src/Listener.cxx b/src/Listener.cxx index 55a58e5..9b3f5c8 100644 --- a/src/Listener.cxx +++ b/src/Listener.cxx @@ -4,11 +4,15 @@ #include "Listener.hxx" #include "Instance.hxx" +#include "Config.hxx" #include "net/SocketAddress.hxx" -Listener::Listener(Instance &_instance, UniqueSocketDescriptor &&_fd) - :ServerSocket(_instance.GetEventLoop(), std::move(_fd)), - instance(_instance), logger(instance.GetLogger()) {} +#include + +Listener::Listener(Instance &_instance, const ListenerConfig &config) + :ServerSocket(_instance.GetEventLoop(), config.Create(SOCK_STREAM)), + instance(_instance), + logger(instance.GetLogger()) {} void Listener::OnAccept(UniqueSocketDescriptor &&connection_fd, diff --git a/src/Listener.hxx b/src/Listener.hxx index bd27eb3..f9fdb57 100644 --- a/src/Listener.hxx +++ b/src/Listener.hxx @@ -6,6 +6,7 @@ #include "event/net/ServerSocket.hxx" +struct ListenerConfig; class Instance; class RootLogger; @@ -14,7 +15,7 @@ class Listener final : ServerSocket { const RootLogger &logger; public: - Listener(Instance &_instance, UniqueSocketDescriptor &&fd); + Listener(Instance &_instance, const ListenerConfig &_config); using ServerSocket::GetLocalAddress;