From: Jean-Michel Vourgère Date: Wed, 19 Aug 2015 14:20:09 +0000 (+0200) Subject: Allow NULL socket addr, as created by systemd X-Git-Tag: v1.6.0~25^2~14^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F664%2Fhead;p=thirdparty%2Frrdtool-1.x.git 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. --- 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,