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.
This commit is contained in:
Max Kellermann 2009-02-24 18:36:31 +01:00
parent 739c23cca5
commit d40c439424

View File

@ -29,6 +29,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#ifdef WIN32 #ifdef WIN32
#include <ws2tcpip.h> #include <ws2tcpip.h>
@ -333,7 +334,9 @@ listen_add_config_param(unsigned int port,
const struct config_param *param, const struct config_param *param,
GError **error) GError **error)
{ {
if (!param || 0 == strcmp(param->value, "any")) { assert(param != NULL);
if (0 == strcmp(param->value, "any")) {
return listen_add_port(port, error); return listen_add_port(port, error);
#ifdef HAVE_UN #ifdef HAVE_UN
} else if (param->value[0] == '/') { } else if (param->value[0] == '/') {
@ -352,18 +355,30 @@ void listen_global_init(void)
bool success; bool success;
GError *error = NULL; GError *error = NULL;
do { if (param != NULL) {
success = listen_add_config_param(port, param, &error); /* "bind_to_address" is configured, create listeners
if (!success) { for all values */
if (param != NULL)
do {
success = listen_add_config_param(port, param, &error);
if (!success)
g_error("Failed to listen on %s (line %i): %s", g_error("Failed to listen on %s (line %i): %s",
param->value, param->line, param->value, param->line,
error->message); error->message);
else
g_error("Failed to listen on *:%d: %s", param = config_get_next_param(CONF_BIND_TO_ADDRESS,
port, error->message); param);
} } while (param != NULL);
} while ((param = config_get_next_param(CONF_BIND_TO_ADDRESS, param))); } 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; listen_port = port;
} }