From: Florian Forster Date: Sun, 7 Apr 2013 03:44:38 +0000 (+0200) Subject: Merge branch 'collectd-4.10' into collectd-5.1 X-Git-Tag: collectd-5.1.3~4 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=9cbc0fe63abd2bd3658b42f19ee144f803b658fa;hp=d21cf7f8376b6ce5dd3bbeb41da3aff0e85c6e28 Merge branch 'collectd-4.10' into collectd-5.1 Conflicts: configure.in src/mysql.c src/network.c src/thermal.c --- diff --git a/configure.in b/configure.in index 5e812a10..b75386d0 100644 --- a/configure.in +++ b/configure.in @@ -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]) diff --git a/src/filter_chain.c b/src/filter_chain.c index ed2df61c..7d8369b9 100644 --- a/src/filter_chain.c +++ b/src/filter_chain.c @@ -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!"); } diff --git a/src/mysql.c b/src/mysql.c index 6f2d69ab..d2d0b4bf 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -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 : "", (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 : "", - 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 : "", + 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) diff --git a/src/network.c b/src/network.c index 3f0c6fa1..4a542460 100644 --- a/src/network.c +++ b/src/network.c @@ -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 + * Florian octo Forster * Aman Gupta **/ @@ -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) diff --git a/src/thermal.c b/src/thermal.c index 0ad0d90a..603f85bb 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -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, diff --git a/src/utils_parse_option.c b/src/utils_parse_option.c index 2168cd1a..820f14f5 100644 --- a/src/utils_parse_option.c +++ b/src/utils_parse_option.c @@ -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);