Skip to content

Commit

Permalink
Listener: pass ListenerConfig to ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Oct 23, 2023
1 parent 283cc2a commit a113848
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Instance.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <cassert>

#include <sys/socket.h>
#include <signal.h>
#include <unistd.h>

Expand Down Expand Up @@ -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();
Expand Down
10 changes: 7 additions & 3 deletions src/Listener.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/socket.h>

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,
Expand Down
3 changes: 2 additions & 1 deletion src/Listener.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "event/net/ServerSocket.hxx"

struct ListenerConfig;
class Instance;
class RootLogger;

Expand All @@ -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;

Expand Down

0 comments on commit a113848

Please sign in to comment.