aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-29 18:32:28 +0100
committerMax Kellermann <max@duempel.org>2014-01-29 18:32:28 +0100
commitaeaf64b46757e64bf32e945d52df2c4d447e5aa4 (patch)
treebde0bbef6e3e94f65c75c0f17f9b3664e35260d9
parenta137f817f5e569211afdef0134c2179fdbad507f (diff)
downloadmpd-aeaf64b46757e64bf32e945d52df2c4d447e5aa4.tar.gz
mpd-aeaf64b46757e64bf32e945d52df2c4d447e5aa4.tar.xz
mpd-aeaf64b46757e64bf32e945d52df2c4d447e5aa4.zip
Listen: pass EventLoop to listen_global_init()
Don't use global variables.
Diffstat (limited to '')
-rw-r--r--src/Listen.cxx10
-rw-r--r--src/Listen.hxx3
-rw-r--r--src/Main.cxx2
3 files changed, 7 insertions, 8 deletions
diff --git a/src/Listen.cxx b/src/Listen.cxx
index faa3e0db1..731f51196 100644
--- a/src/Listen.cxx
+++ b/src/Listen.cxx
@@ -44,12 +44,12 @@ static constexpr Domain listen_domain("listen");
class ClientListener final : public ServerSocket {
public:
- ClientListener():ServerSocket(*main_loop) {}
+ ClientListener(EventLoop &_loop):ServerSocket(_loop) {}
private:
virtual void OnAccept(int fd, const sockaddr &address,
size_t address_length, int uid) {
- client_new(*main_loop, *instance->partition,
+ client_new(GetEventLoop(), *instance->partition,
fd, &address, address_length, uid);
}
};
@@ -101,16 +101,14 @@ listen_systemd_activation(Error &error_r)
}
bool
-listen_global_init(Error &error)
+listen_global_init(EventLoop &loop, Error &error)
{
- assert(main_loop != nullptr);
-
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();
+ listen_socket = new ClientListener(loop);
if (listen_systemd_activation(error))
return true;
diff --git a/src/Listen.hxx b/src/Listen.hxx
index f14ec665c..8be0999ea 100644
--- a/src/Listen.hxx
+++ b/src/Listen.hxx
@@ -20,12 +20,13 @@
#ifndef MPD_LISTEN_HXX
#define MPD_LISTEN_HXX
+class EventLoop;
class Error;
extern int listen_port;
bool
-listen_global_init(Error &error);
+listen_global_init(EventLoop &loop, Error &error);
void listen_global_finish(void);
diff --git a/src/Main.cxx b/src/Main.cxx
index 87a35eca2..86ac7fc7a 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -413,7 +413,7 @@ 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(error)) {
+ if (!listen_global_init(*main_loop, error)) {
LogError(error);
return EXIT_FAILURE;
}