Merge branch 'collectd-4.5' into collectd-4.6
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 28 Feb 2009 09:35:04 +0000 (10:35 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 28 Feb 2009 09:35:04 +0000 (10:35 +0100)
src/collectd-unixsock.pod
src/common.c
src/dns.c

index ca00a6d..ac4a1b1 100644 (file)
@@ -17,11 +17,11 @@ collectd-unixsock - Documentation of collectd's C<unixsock plugin>
 
 The C<unixsock plugin> opens an UNIX-socket over which one can interact with
 the daemon. This can be used to use the values collected by collectd in other
-applications, such as monitoring, or submit externally collected values to
-collectd.
+applications, such as monitoring solutions, or submit externally collected
+values to collectd.
 
-This plugin is used by L<collectd-nagios(1)> to check if some value is in a
-certain range and exit with a Nagios-compatible exit code.
+For example, this plugin is used by L<collectd-nagios(1)> to check if some
+value is in a certain range and exit with a Nagios-compatible exit code.
 
 =head1 COMMANDS
 
index 9a20f78..b654719 100644 (file)
@@ -469,7 +469,8 @@ int check_create_dir (const char *file_orig)
                 */
                if (fields[i][0] == '.')
                {
-                       ERROR ("Cowardly refusing to create a directory that begins with a `.' (dot): `%s'", file_orig);
+                       ERROR ("Cowardly refusing to create a directory that "
+                                       "begins with a `.' (dot): `%s'", file_orig);
                        return (-2);
                }
 
@@ -484,32 +485,42 @@ int check_create_dir (const char *file_orig)
                        return (-1);
                }
 
-               if (stat (dir, &statbuf) == -1)
-               {
-                       if (errno == ENOENT)
+               while (42) {
+                       if (stat (dir, &statbuf) == -1)
                        {
-                               if (mkdir (dir, 0755) == -1)
+                               if (errno == ENOENT)
                                {
+                                       if (mkdir (dir, 0755) == 0)
+                                               break;
+
+                                       /* this might happen, if a different thread created
+                                        * the directory in the meantime
+                                        * => call stat() again to check for S_ISDIR() */
+                                       if (EEXIST == errno)
+                                               continue;
+
                                        char errbuf[1024];
                                        ERROR ("check_create_dir: mkdir (%s): %s", dir,
                                                        sstrerror (errno,
                                                                errbuf, sizeof (errbuf)));
                                        return (-1);
                                }
+                               else
+                               {
+                                       char errbuf[1024];
+                                       ERROR ("check_create_dir: stat (%s): %s", dir,
+                                                       sstrerror (errno, errbuf,
+                                                               sizeof (errbuf)));
+                                       return (-1);
+                               }
                        }
-                       else
+                       else if (!S_ISDIR (statbuf.st_mode))
                        {
-                               char errbuf[1024];
-                               ERROR ("stat (%s): %s", dir,
-                                               sstrerror (errno, errbuf,
-                                                       sizeof (errbuf)));
+                               ERROR ("check_create_dir: `%s' exists but is not "
+                                               "a directory!", dir);
                                return (-1);
                        }
-               }
-               else if (!S_ISDIR (statbuf.st_mode))
-               {
-                       ERROR ("stat (%s): Not a directory!", dir);
-                       return (-1);
+                       break;
                }
        }
 
index ab38789..476b6dd 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -212,7 +212,7 @@ static void *dns_child_loop (void __attribute__((unused)) *dummy)
 
        /* Passing `pcap_device == NULL' is okay and the same as passign "any" */
        DEBUG ("Creating PCAP object..");
-       pcap_obj = pcap_open_live (pcap_device,
+       pcap_obj = pcap_open_live ((pcap_device != NULL) ? pcap_device : "any",
                        PCAP_SNAPLEN,
                        0 /* Not promiscuous */,
                        interval_g,