Listen: simplify code flow in listen_global_init()
This commit is contained in:
parent
56bfff5a57
commit
524a7f4560
@ -82,27 +82,24 @@ void
|
|||||||
listen_global_init(ClientListener &listener)
|
listen_global_init(ClientListener &listener)
|
||||||
{
|
{
|
||||||
int port = config_get_positive(ConfigOption::PORT, DEFAULT_PORT);
|
int port = config_get_positive(ConfigOption::PORT, DEFAULT_PORT);
|
||||||
const auto *param = config_get_param(ConfigOption::BIND_TO_ADDRESS);
|
|
||||||
|
|
||||||
#ifdef ENABLE_SYSTEMD_DAEMON
|
#ifdef ENABLE_SYSTEMD_DAEMON
|
||||||
if (listen_systemd_activation(listener))
|
if (listen_systemd_activation(listener))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (param != nullptr) {
|
for (const auto *param = config_get_param(ConfigOption::BIND_TO_ADDRESS);
|
||||||
/* "bind_to_address" is configured, create listeners
|
param != nullptr; param = param->next) {
|
||||||
for all values */
|
try {
|
||||||
|
listen_add_config_param(listener, port, param);
|
||||||
|
} catch (...) {
|
||||||
|
std::throw_with_nested(FormatRuntimeError("Failed to listen on %s (line %i)",
|
||||||
|
param->value.c_str(),
|
||||||
|
param->line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
if (listener.IsEmpty()) {
|
||||||
try {
|
|
||||||
listen_add_config_param(listener, port, param);
|
|
||||||
} catch (...) {
|
|
||||||
std::throw_with_nested(FormatRuntimeError("Failed to listen on %s (line %i)",
|
|
||||||
param->value.c_str(),
|
|
||||||
param->line));
|
|
||||||
}
|
|
||||||
} while ((param = param->next) != nullptr);
|
|
||||||
} else {
|
|
||||||
/* no "bind_to_address" configured, bind the
|
/* no "bind_to_address" configured, bind the
|
||||||
configured port on all interfaces */
|
configured port on all interfaces */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user