From 0595b466085313982e8bc796d4a061cf7d0e9bf2 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 10 Aug 2022 11:15:49 +0200 Subject: dlt-daemon-connection: Start up even if not all bindings are valid (#380) dlt-daemon allows configuration of multiple addresses. Before this commit the daemon exits when the first binding fails. This commit changes the behavior so that the daemon only exits if none of the configured addresses can be opened. Signed-off-by: Alexander Mohr --- src/daemon/dlt-daemon.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index b7aac0d..8e3e646 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1621,6 +1621,7 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon, } } else { + bool any_open = false; while (head != NULL) { /* open socket for each IP in the bindAddress list */ if (dlt_daemon_socket_open(&fd, daemon_local->flags.port, head->ip) == DLT_RETURN_OK) { @@ -1629,17 +1630,22 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon, fd, POLLIN, DLT_CONNECTION_CLIENT_CONNECT)) { - dlt_log(LOG_ERR, "Could not initialize main socket.\n"); - return DLT_RETURN_ERROR; + dlt_vlog(LOG_ERR, "Could not create connection, for binding %s\n", head->ip); + } else { + any_open = true; } } else { - dlt_log(LOG_ERR, "Could not initialize main socket.\n"); - return DLT_RETURN_ERROR; + dlt_vlog(LOG_ERR, "Could not open main socket, for binding %s\n", head->ip); } head = head->next; } + + if (!any_open) { + dlt_vlog(LOG_ERR, "Failed create main socket for any configured binding\n"); + return DLT_RETURN_ERROR; + } } #ifdef UDP_CONNECTION_SUPPORT -- cgit v1.2.1