Listen: reduce overhead for builds without systemd

This commit is contained in:
Max Kellermann 2014-02-19 23:49:34 +01:00
parent e92a41fa3a
commit e609c88334
1 changed files with 6 additions and 5 deletions

View File

@ -77,10 +77,11 @@ listen_add_config_param(unsigned int port,
} }
} }
#ifdef ENABLE_SYSTEMD_DAEMON
static bool static bool
listen_systemd_activation(Error &error_r) listen_systemd_activation(Error &error_r)
{ {
#ifdef ENABLE_SYSTEMD_DAEMON
int n = sd_listen_fds(true); int n = sd_listen_fds(true);
if (n <= 0) { if (n <= 0) {
if (n < 0) if (n < 0)
@ -95,12 +96,10 @@ listen_systemd_activation(Error &error_r)
return false; return false;
return true; return true;
#else
(void)error_r;
return false;
#endif
} }
#endif
bool bool
listen_global_init(EventLoop &loop, Partition &partition, Error &error) listen_global_init(EventLoop &loop, Partition &partition, Error &error)
{ {
@ -111,11 +110,13 @@ listen_global_init(EventLoop &loop, Partition &partition, Error &error)
listen_socket = new ClientListener(loop, partition); listen_socket = new ClientListener(loop, partition);
#ifdef ENABLE_SYSTEMD_DAEMON
if (listen_systemd_activation(error)) if (listen_systemd_activation(error))
return true; return true;
if (error.IsDefined()) if (error.IsDefined())
return false; return false;
#endif
if (param != nullptr) { if (param != nullptr) {
/* "bind_to_address" is configured, create listeners /* "bind_to_address" is configured, create listeners