Code

email plugin: Unlock mutexes before submitting the data.
[collectd.git] / src / hddtemp.c
index bba96d8bb6b0bbbf0fff8202dc2ab2d68a59e7ee..80b3419bee76d3e96efacb242bdba4f946efc5be 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/hddtemp.c
- * Copyright (C) 2005-2006  Vincent StehlĂ©
+ * Copyright (C) 2005,2006  Vincent StehlĂ©
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -55,7 +55,7 @@ static char *filename_format = "hddtemp-%s.rrd";
 
 static char *ds_def[] =
 {
-       "DS:value:GAUGE:25:U:U",
+       "DS:value:GAUGE:"COLLECTD_HEARTBEAT":U:U",
        NULL
 };
 static int ds_num = 1;
@@ -158,6 +158,10 @@ static int hddtemp_query_daemon (char *buffer, int buffer_size)
                        fd = -1;
                        continue;
                }
+
+               /* A socket could be opened and connecting succeeded. We're
+                * done. */
+               break;
        }
 
        freeaddrinfo (ai_list);
@@ -181,6 +185,7 @@ static int hddtemp_query_daemon (char *buffer, int buffer_size)
 
                        syslog (LOG_ERR, "hddtemp: Error reading from socket: %s",
                                                strerror (errno));
+                       close (fd);
                        return (-1);
                }
                buffer_fill += status;
@@ -346,7 +351,8 @@ static void hddtemp_init (void)
 
                        if ((entry = (hddname_t *) malloc (sizeof (hddname_t))) == NULL)
                        {
-                               syslog (LOG_ERR, "hddtemp: malloc (%u) == NULL", sizeof (hddname_t));
+                               syslog (LOG_ERR, "hddtemp: malloc (%u) == NULL",
+                                               (unsigned int) sizeof (hddname_t));
                                free (name);
                                continue;
                        }
@@ -368,6 +374,7 @@ static void hddtemp_init (void)
                                first_hddname = entry;
                        }
                }
+               fclose (fh);
        }
        else
                DBG ("Could not open /proc/partitions: %s",