From 308b3f2337f100b5d27fa2af50bf929caff4a7d4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 24 Sep 2009 21:40:04 +0200 Subject: listen: handle fatal errors with GError Don't call g_error(), which will abort the process and dump core. --- src/listen.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/listen.c') diff --git a/src/listen.c b/src/listen.c index 98108d9da..4728e7c7a 100644 --- a/src/listen.c +++ b/src/listen.c @@ -347,7 +347,8 @@ listen_add_config_param(unsigned int port, } } -void listen_global_init(void) +bool +listen_global_init(GError **error_r) { int port = config_get_positive(CONF_PORT, DEFAULT_PORT); const struct config_param *param = @@ -361,10 +362,12 @@ void listen_global_init(void) 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); + if (!success) { + g_propagate_prefixed_error(error_r, error, + "Failed to listen on %s (line %i): ", + param->value, param->line); + return false; + } param = config_get_next_param(CONF_BIND_TO_ADDRESS, param); @@ -374,12 +377,16 @@ void listen_global_init(void) configured port on all interfaces */ success = listen_add_port(port, &error); - if (!success) - g_error("Failed to listen on *:%d: %s", - port, error->message); + if (!success) { + g_propagate_prefixed_error(error_r, error, + "Failed to listen on *:%d: ", + port); + return false; + } } listen_port = port; + return true; } void listen_global_finish(void) -- cgit v1.2.3