Merge branch 'collectd-4.10' into collectd-5.1
authorFlorian Forster <octo@collectd.org>
Sun, 7 Apr 2013 03:44:38 +0000 (05:44 +0200)
committerFlorian Forster <octo@collectd.org>
Sun, 7 Apr 2013 03:44:38 +0000 (05:44 +0200)
Conflicts:
configure.in
src/mysql.c
src/network.c
src/thermal.c

configure.in
src/filter_chain.c
src/mysql.c
src/network.c
src/thermal.c
src/utils_parse_option.c

index 5e812a1..b75386d 100644 (file)
@@ -582,7 +582,7 @@ AC_CACHE_CHECK([for strtok_r],
       saveptr = NULL;
       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
       {
-       dummy = NULL;
+        dummy = NULL;
         printf ("token = %s;\n", token);
       }
 ]]]
@@ -615,7 +615,7 @@ then
         saveptr = NULL;
         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
         {
-         dummy = NULL;
+          dummy = NULL;
           printf ("token = %s;\n", token);
         }
 ]]]
@@ -1983,31 +1983,31 @@ then
        if test -d "$with_java_home"
        then
                AC_MSG_CHECKING([for jni.h])
-               TMPDIR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
-               if test "x$TMPDIR" != "x"
+               TMPVAR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
+               if test "x$TMPVAR" != "x"
                then
-                       AC_MSG_RESULT([found in $TMPDIR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
                else
                        AC_MSG_RESULT([not found])
                fi
 
                AC_MSG_CHECKING([for jni_md.h])
-               TMPDIR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
-               if test "x$TMPDIR" != "x"
+               TMPVAR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
+               if test "x$TMPVAR" != "x"
                then
-                       AC_MSG_RESULT([found in $TMPDIR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
                else
                        AC_MSG_RESULT([not found])
                fi
 
                AC_MSG_CHECKING([for libjvm.so])
-               TMPDIR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
-               if test "x$TMPDIR" != "x"
+               TMPVAR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
+               if test "x$TMPVAR" != "x"
                then
-                       AC_MSG_RESULT([found in $TMPDIR])
-                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR"
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
                else
                        AC_MSG_RESULT([not found])
                fi
@@ -2015,10 +2015,10 @@ then
                if test "x$JAVAC" = "x"
                then
                        AC_MSG_CHECKING([for javac])
-                       TMPDIR=`find "$with_java_home" -name javac -type f | head -n 1`
-                       if test "x$TMPDIR" != "x"
+                       TMPVAR=`find "$with_java_home" -name javac -type f | head -n 1`
+                       if test "x$TMPVAR" != "x"
                        then
-                               JAVAC="$TMPDIR"
+                               JAVAC="$TMPVAR"
                                AC_MSG_RESULT([$JAVAC])
                        else
                                AC_MSG_RESULT([not found])
@@ -2027,10 +2027,10 @@ then
                if test "x$JAR" = "x"
                then
                        AC_MSG_CHECKING([for jar])
-                       TMPDIR=`find "$with_java_home" -name jar -type f | head -n 1`
-                       if test "x$TMPDIR" != "x"
+                       TMPVAR=`find "$with_java_home" -name jar -type f | head -n 1`
+                       if test "x$TMPVAR" != "x"
                        then
-                               JAR="$TMPDIR"
+                               JAR="$TMPVAR"
                                AC_MSG_RESULT([$JAR])
                        else
                                AC_MSG_RESULT([not found])
index ed2df61..7d8369b 100644 (file)
@@ -92,7 +92,7 @@ static void fc_free_matches (fc_match_t *m) /* {{{ */
     (*m->proc.destroy) (&m->user_data);
   else if (m->user_data != NULL)
   {
-    ERROR ("Filter sybsystem: fc_free_matches: There is user data, but no "
+    ERROR ("Filter subsystem: fc_free_matches: There is user data, but no "
         "destroy functions has been specified. "
         "Memory will probably be lost!");
   }
@@ -112,7 +112,7 @@ static void fc_free_targets (fc_target_t *t) /* {{{ */
     (*t->proc.destroy) (&t->user_data);
   else if (t->user_data != NULL)
   {
-    ERROR ("Filter sybsystem: fc_free_targets: There is user data, but no "
+    ERROR ("Filter subsystem: fc_free_targets: There is user data, but no "
         "destroy functions has been specified. "
         "Memory will probably be lost!");
   }
index 6f2d69a..d2d0b4b 100644 (file)
@@ -58,7 +58,7 @@ struct mysql_database_s /* {{{ */
        _Bool slave_sql_running;
 
        MYSQL *con;
-       int    state;
+       _Bool  is_connected;
 };
 typedef struct mysql_database_s mysql_database_t; /* }}} */
 
@@ -237,30 +237,28 @@ static int mysql_config (oconfig_item_t *ci) /* {{{ */
 
 static MYSQL *getconnection (mysql_database_t *db)
 {
-       if (db->state != 0)
+       if (db->is_connected)
        {
-               int err;
-               if ((err = mysql_ping (db->con)) != 0)
-               {
-                       /* Assured by "mysql_config_database" */
-                       assert (db->instance != NULL);
-                       WARNING ("mysql_ping failed for instance \"%s\": %s",
-                                       db->instance,
-                                       mysql_error (db->con));
-                       db->state = 0;
-               }
-               else
-               {
-                       db->state = 1;
+               int status;
+
+               status = mysql_ping (db->con);
+               if (status == 0)
                        return (db->con);
-               }
+
+               WARNING ("mysql plugin: Lost connection to instance \"%s\": %s",
+                               db->instance, mysql_error (db->con));
        }
+       db->is_connected = 0;
 
-       if ((db->con = mysql_init (db->con)) == NULL)
+       if (db->con == NULL)
        {
-               ERROR ("mysql_init failed: %s", mysql_error (db->con));
-               db->state = 0;
-               return (NULL);
+               db->con = mysql_init (NULL);
+               if (db->con == NULL)
+               {
+                       ERROR ("mysql plugin: mysql_init failed: %s",
+                                       mysql_error (db->con));
+                       return (NULL);
+               }
        }
 
        if (mysql_real_connect (db->con, db->host, db->user, db->pass,
@@ -271,20 +269,18 @@ static MYSQL *getconnection (mysql_database_t *db)
                                (db->database != NULL) ? db->database : "<none>",
                                (db->host != NULL) ? db->host : "localhost",
                                mysql_error (db->con));
-               db->state = 0;
                return (NULL);
        }
-       else
-       {
-               INFO ("mysql plugin: Successfully connected to database %s "
-                               "at server %s (server version: %s, protocol version: %d)",
-                               (db->database != NULL) ? db->database : "<none>",
-                               mysql_get_host_info (db->con),
-                               mysql_get_server_info (db->con),
-                               mysql_get_proto_info (db->con));
-               db->state = 1;
-               return (db->con);
-       }
+
+       INFO ("mysql plugin: Successfully connected to database %s "
+                       "at server %s (server version: %s, protocol version: %d)",
+                       (db->database != NULL) ? db->database : "<none>",
+                       mysql_get_host_info (db->con),
+                       mysql_get_server_info (db->con),
+                       mysql_get_proto_info (db->con));
+
+       db->is_connected = 1;
+       return (db->con);
 } /* static MYSQL *getconnection (mysql_database_t *db) */
 
 static void set_host (mysql_database_t *db, char *buf, size_t buflen)
index 3f0c6fa..4a54246 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/network.c
- * Copyright (C) 2005-2010  Florian octo Forster
+ * Copyright (C) 2005-2013  Florian octo Forster
  * Copyright (C) 2009       Aman Gupta
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * Authors:
- *   Florian octo Forster <octo at verplant.org>
+ *   Florian octo Forster <octo at collectd.org>
  *   Aman Gupta <aman at tmm1.net>
  **/
 
@@ -493,6 +493,20 @@ static int network_dispatch_notification (notification_t *n) /* {{{ */
 } /* }}} int network_dispatch_notification */
 
 #if HAVE_LIBGCRYPT
+static void network_init_gcrypt (void) /* {{{ */
+{
+  /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html
+   * Because you can't know in a library whether another library has
+   * already initialized the library */
+  if (gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
+    return;
+
+  gcry_check_version (NULL); /* before calling any other functions */
+  gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+  gcry_control (GCRYCTL_INIT_SECMEM, 32768);
+  gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
+} /* }}} void network_init_gcrypt */
+
 static gcry_cipher_hd_t network_get_aes256_cypher (sockent_t *se, /* {{{ */
     const void *iv, size_t iv_size, const char *username)
 {
@@ -2029,6 +2043,8 @@ static int sockent_open (sockent_t *se) /* {{{ */
        {
                if (se->data.client.security_level > SECURITY_LEVEL_NONE)
                {
+                       network_init_gcrypt ();
+
                        if ((se->data.client.username == NULL)
                                        || (se->data.client.password == NULL))
                        {
@@ -2047,6 +2063,8 @@ static int sockent_open (sockent_t *se) /* {{{ */
        {
                if (se->data.server.security_level > SECURITY_LEVEL_NONE)
                {
+                       network_init_gcrypt ();
+
                        if (se->data.server.auth_file == NULL)
                        {
                                ERROR ("network plugin: Server socket with "
@@ -3371,17 +3389,7 @@ static int network_init (void)
        have_init = 1;
 
 #if HAVE_LIBGCRYPT
-    /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html
-     * Because you can't know in a library whether another library has
-     * already initialized the library
-     */
-    if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
-    {
-        gcry_check_version(NULL); /* before calling any other functions */
-        gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-        gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
-        gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
-    }
+       network_init_gcrypt ();
 #endif
 
        if (network_config_stats != 0)
index 0ad0d90..603f85b 100644 (file)
@@ -55,6 +55,9 @@ static void thermal_submit (const char *plugin_instance, enum dev_type dt,
        v.gauge = value;
        vl.values = &v;
 
+       vl.values_len = 1;
+
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin));
        if (plugin_instance != NULL)
                sstrncpy (vl.plugin_instance, plugin_instance,
index 2168cd1..820f14f 100644 (file)
@@ -127,7 +127,7 @@ int parse_option (char **ret_buffer, char **ret_key, char **ret_value)
 
   /* Look for the equal sign */
   buffer = key;
-  while (isalnum ((int) *buffer))
+  while (isalnum ((int) *buffer) || *buffer == '_')
     buffer++;
   if ((*buffer != '=') || (buffer == key))
     return (1);