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 Merge branch 'collectd-4.10' into collectd-5.1 Conflicts: configure.in src/mysql.c src/network.c src/thermal.c --- 9cbc0fe63abd2bd3658b42f19ee144f803b658fa diff --cc configure.in index 5e812a10,0b126301..b75386d0 --- a/configure.in +++ b/configure.in @@@ -582,11 -533,10 +582,11 @@@ AC_CACHE_CHECK([for strtok_r] saveptr = NULL; while ((token = strtok_r (dummy, ",", &saveptr)) != NULL) { - dummy = NULL; + dummy = NULL; printf ("token = %s;\n", token); } - ]]])], +]]] + )], [c_cv_have_strtok_r_default="yes"], [c_cv_have_strtok_r_default="no"] ) @@@ -615,11 -565,10 +615,11 @@@ the saveptr = NULL; while ((token = strtok_r (dummy, ",", &saveptr)) != NULL) { - dummy = NULL; + dummy = NULL; printf ("token = %s;\n", token); } - ]]])], +]]] + )], [c_cv_have_strtok_r_reentrant="yes"], [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])] ) diff --cc src/mysql.c index 6f2d69ab,8b3cd210..d2d0b4bf --- a/src/mysql.c +++ b/src/mysql.c @@@ -50,15 -51,15 +50,15 @@@ struct mysql_database_s /* {{{ * char *socket; int port; - int master_stats; - int slave_stats; + _Bool master_stats; + _Bool slave_stats; - int slave_notif; - int slave_io_running; - int slave_sql_running; + _Bool slave_notif; + _Bool slave_io_running; + _Bool slave_sql_running; MYSQL *con; - int state; + _Bool is_connected; }; typedef struct mysql_database_s mysql_database_t; /* }}} */ @@@ -237,30 -359,31 +237,28 @@@ static int mysql_config (oconfig_item_ 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 != NULL) - ? db->instance - : "", - mysql_error (db->con)); ++ 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, diff --cc src/network.c index 3f0c6fa1,d0ff6bca..4a542460 --- a/src/network.c +++ b/src/network.c @@@ -3368,20 -3368,10 +3386,10 @@@ static int network_init (void * nothing more to do (for now, that is). */ if (have_init) return (0); - have_init = true; + 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 --cc src/thermal.c index 0ad0d90a,5d3da892..603f85bb --- a/src/thermal.c +++ b/src/thermal.c @@@ -49,18 -45,19 +49,21 @@@ enum dev_type static void thermal_submit (const char *plugin_instance, enum dev_type dt, gauge_t value) { - value_list_t vl = (dt == TEMP) ? vl_temp_template : vl_state_template; - value_t vt; + value_list_t vl = VALUE_LIST_INIT; + value_t v; - vt.gauge = value; + v.gauge = value; + vl.values = &v; - vl.values = &vt; + vl.values_len = 1; + + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin)); - sstrncpy (vl.plugin_instance, plugin_instance, - sizeof(vl.plugin_instance)); - sstrncpy (vl.type, (dt == TEMP) ? "temperature" : "gauge", + if (plugin_instance != NULL) + sstrncpy (vl.plugin_instance, plugin_instance, + sizeof (vl.plugin_instance)); + sstrncpy (vl.type, + (dt == TEMP) ? "temperature" : "gauge", sizeof (vl.type)); plugin_dispatch_values (&vl);