From 2b9ae522eee5b78ff39a31a0594f91dbd17c27da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Michel=20Vourg=C3=A8re?= Date: Wed, 19 Aug 2015 16:20:09 +0200 Subject: [PATCH] Allow NULL socket addr, as created by systemd This fixes an error when rrdcached is started using systemd. Thanks to Denis Bychkov for the diagnostic and the first version of the patch. --- src/rrd_daemon.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index b8e64c05..4a2fb1c5 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3595,7 +3595,7 @@ static int close_listen_sockets (void) /* {{{ */ { close (listen_fds[i].fd); - if (listen_fds[i].family == PF_UNIX) + if (listen_fds[i].family == PF_UNIX && listen_fds[i].addr != NULL) unlink(listen_fds[i].addr); free(listen_fds[i].addr); } @@ -3681,12 +3681,15 @@ static void *listen_thread_main (void UNUSED(*args)) /* {{{ */ continue; } memcpy(client_sock, &listen_fds[i], sizeof(listen_fds[0])); - client_sock->addr = strdup(listen_fds[i].addr); - if (client_sock->addr == NULL) + if (listen_fds[i].addr) { - RRDD_LOG (LOG_ERR, "listen_thread_main: strdup failed."); - continue; - } + client_sock->addr = strdup(listen_fds[i].addr); + if (client_sock->addr == NULL) + { + RRDD_LOG (LOG_ERR, "listen_thread_main: strdup failed."); + continue; + } + } // else, the socket is comming from systemd client_sa_size = sizeof (client_sa); client_sock->fd = accept (pollfds[i].fd, -- 2.47.2