]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Allow NULL socket addr, as created by systemd 664/head
authorJean-Michel Vourgère <nirgal@debian.org>
Wed, 19 Aug 2015 14:20:09 +0000 (16:20 +0200)
committerJean-Michel Vourgère <nirgal@debian.org>
Wed, 19 Aug 2015 14:20:09 +0000 (16:20 +0200)
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

index b8e64c05b0899f6b64c765ec8fefc6be49aeadc1..4a2fb1c52246b2918bd03ac8c3bfcdad2a7fec73 100644 (file)
@@ -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,