aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-24 18:36:31 +0100
committerMax Kellermann <max@duempel.org>2009-02-24 18:36:31 +0100
commitd40c439424ef763d511031744d0df69c26f1461f (patch)
treea22ed5c0d81a220554568793710ef2c9c6ec31e0 /src
parent739c23cca53f2dc28ed2376b0215fe92c16b5d89 (diff)
downloadmpd-d40c439424ef763d511031744d0df69c26f1461f.tar.gz
mpd-d40c439424ef763d511031744d0df69c26f1461f.tar.xz
mpd-d40c439424ef763d511031744d0df69c26f1461f.zip
listen: don't call listen_add_config_param(NULL)
For default bind_to_address settings, don't call listen_add_config_param(NULL), use listen_add_port() directly.
Diffstat (limited to 'src')
-rw-r--r--src/listen.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/listen.c b/src/listen.c
index a75f7fc15..3fa167cd1 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <assert.h>
#ifdef WIN32
#include <ws2tcpip.h>
@@ -333,7 +334,9 @@ listen_add_config_param(unsigned int port,
const struct config_param *param,
GError **error)
{
- if (!param || 0 == strcmp(param->value, "any")) {
+ assert(param != NULL);
+
+ if (0 == strcmp(param->value, "any")) {
return listen_add_port(port, error);
#ifdef HAVE_UN
} else if (param->value[0] == '/') {
@@ -352,18 +355,30 @@ void listen_global_init(void)
bool success;
GError *error = NULL;
- do {
- success = listen_add_config_param(port, param, &error);
- if (!success) {
- if (param != NULL)
+ if (param != NULL) {
+ /* "bind_to_address" is configured, create listeners
+ for all values */
+
+ do {
+ success = listen_add_config_param(port, param, &error);
+ if (!success)
g_error("Failed to listen on %s (line %i): %s",
param->value, param->line,
error->message);
- else
- g_error("Failed to listen on *:%d: %s",
- port, error->message);
- }
- } while ((param = config_get_next_param(CONF_BIND_TO_ADDRESS, param)));
+
+ param = config_get_next_param(CONF_BIND_TO_ADDRESS,
+ param);
+ } while (param != NULL);
+ } else {
+ /* no "bind_to_address" configured, bind the
+ configured port on all interfaces */
+
+ success = listen_add_port(port, &error);
+ if (!success)
+ g_error("Failed to listen on *:%d: %s",
+ port, error->message);
+ }
+
listen_port = port;
}