aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-05 23:16:50 +0100
committerMax Kellermann <max@duempel.org>2014-02-19 23:43:36 +0100
commitdf5f9f4a158c244006d1965a328779f284cae7d9 (patch)
tree39670541de93991e54811ba2e746c13d0a186c27 /src
parentd9466cad0e13cf56a5cff36df30cfb3411305c2b (diff)
downloadmpd-df5f9f4a158c244006d1965a328779f284cae7d9.tar.gz
mpd-df5f9f4a158c244006d1965a328779f284cae7d9.tar.xz
mpd-df5f9f4a158c244006d1965a328779f284cae7d9.zip
Listen: add Partition reference
Diffstat (limited to 'src')
-rw-r--r--src/Listen.cxx13
-rw-r--r--src/Listen.hxx3
-rw-r--r--src/Main.cxx3
3 files changed, 11 insertions, 8 deletions
diff --git a/src/Listen.cxx b/src/Listen.cxx
index 731f51196..85a7f1c41 100644
--- a/src/Listen.cxx
+++ b/src/Listen.cxx
@@ -19,8 +19,6 @@
#include "config.h"
#include "Listen.hxx"
-#include "Main.hxx"
-#include "Instance.hxx"
#include "client/Client.hxx"
#include "config/ConfigData.hxx"
#include "config/ConfigGlobal.hxx"
@@ -43,13 +41,16 @@ static constexpr Domain listen_domain("listen");
#define DEFAULT_PORT 6600
class ClientListener final : public ServerSocket {
+ Partition &partition;
+
public:
- ClientListener(EventLoop &_loop):ServerSocket(_loop) {}
+ ClientListener(EventLoop &_loop, Partition &_partition)
+ :ServerSocket(_loop), partition(_partition) {}
private:
virtual void OnAccept(int fd, const sockaddr &address,
size_t address_length, int uid) {
- client_new(GetEventLoop(), *instance->partition,
+ client_new(GetEventLoop(), partition,
fd, &address, address_length, uid);
}
};
@@ -101,14 +102,14 @@ listen_systemd_activation(Error &error_r)
}
bool
-listen_global_init(EventLoop &loop, Error &error)
+listen_global_init(EventLoop &loop, Partition &partition, Error &error)
{
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
const struct config_param *param =
config_get_next_param(CONF_BIND_TO_ADDRESS, nullptr);
bool success;
- listen_socket = new ClientListener(loop);
+ listen_socket = new ClientListener(loop, partition);
if (listen_systemd_activation(error))
return true;
diff --git a/src/Listen.hxx b/src/Listen.hxx
index 8be0999ea..d74c1d233 100644
--- a/src/Listen.hxx
+++ b/src/Listen.hxx
@@ -22,11 +22,12 @@
class EventLoop;
class Error;
+struct Partition;
extern int listen_port;
bool
-listen_global_init(EventLoop &loop, Error &error);
+listen_global_init(EventLoop &loop, Partition &partition, Error &error);
void listen_global_finish(void);
diff --git a/src/Main.cxx b/src/Main.cxx
index 368f54caa..c9de56873 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -432,7 +432,8 @@ int mpd_main(int argc, char *argv[])
const unsigned max_clients = config_get_positive(CONF_MAX_CONN, 10);
instance->client_list = new ClientList(max_clients);
- if (!listen_global_init(*instance->event_loop, error)) {
+ if (!listen_global_init(*instance->event_loop, *instance->partition,
+ error)) {
LogError(error);
return EXIT_FAILURE;
}