From: Ruben Kerkhof Date: Fri, 5 Aug 2016 11:17:32 +0000 (+0200) Subject: Merge branch 'collectd-5.5' X-Git-Tag: collectd-5.6.0~111 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=958f7776a2daaa1a8664aded0a2c1d717c2f5909;p=collectd.git Merge branch 'collectd-5.5' Conflicts: src/pyvalues.c --- 958f7776a2daaa1a8664aded0a2c1d717c2f5909 diff --cc src/daemon/plugin.c index 2ccc68c2,1deabba3..1bee8cdd --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@@ -1969,15 -1846,14 +1969,15 @@@ int plugin_flush (const char *plugin, c return (0); } /* int plugin_flush */ -void plugin_shutdown_all (void) +int plugin_shutdown_all (void) { llentry_t *le; + int ret = 0; // Assume success. - stop_read_threads (); - destroy_all_callbacks (&list_init); + stop_read_threads (); + pthread_mutex_lock (&read_lock); llist_destroy (read_list); read_list = NULL; diff --cc src/network.c index 1b560c47,c6845eb9..58ddb225 --- a/src/network.c +++ b/src/network.c @@@ -3434,10 -3564,14 +3450,14 @@@ static int network_init (void have_init = 1; #if HAVE_LIBGCRYPT - network_init_gcrypt (); + if (network_init_gcrypt () < 0) + { + ERROR ("network plugin: Failed to initialize crypto library."); + return (-1); + } #endif - if (network_config_stats != 0) + if (network_config_stats) plugin_register_read ("network", network_stats_read); plugin_register_shutdown ("network", network_shutdown); diff --cc src/pyvalues.c index bd2088dc,0ea81f8c..a7cb7923 --- a/src/pyvalues.c +++ b/src/pyvalues.c @@@ -543,16 -542,17 +543,17 @@@ static PyObject *Values_dispatch(Value PyErr_Format(PyExc_TypeError, "meta must be a dict"); return NULL; } - size = (int) PySequence_Length(values); + size = (size_t) PySequence_Length(values); if (size != ds->ds_num) { - PyErr_Format(PyExc_RuntimeError, "type %s needs %d values, got %i", value_list.type, ds->ds_num, size); + PyErr_Format(PyExc_RuntimeError, "type %s needs %zu values, got %zu", value_list.type, ds->ds_num, size); return NULL; } - value = malloc(size * sizeof(*value)); - for (i = 0; i < size; ++i) { + value = calloc(size, sizeof(*value)); + for (size_t i = 0; i < size; ++i) { PyObject *item, *num; - item = PySequence_Fast_GET_ITEM(values, i); /* Borrowed reference. */ + item = PySequence_Fast_GET_ITEM(values, (int) i); /* Borrowed reference. */ - if (ds->ds->type == DS_TYPE_COUNTER) { + switch (ds->ds[i].type) { + case DS_TYPE_COUNTER: num = PyNumber_Long(item); /* New reference. */ if (num != NULL) { value[i].counter = PyLong_AsUnsignedLongLong(num); @@@ -647,16 -651,17 +652,17 @@@ static PyObject *Values_write(Values *s PyErr_Format(PyExc_TypeError, "values must be list or tuple"); return NULL; } - size = (int) PySequence_Length(values); + size = (size_t) PySequence_Length(values); if (size != ds->ds_num) { - PyErr_Format(PyExc_RuntimeError, "type %s needs %d values, got %i", value_list.type, ds->ds_num, size); + PyErr_Format(PyExc_RuntimeError, "type %s needs %zu values, got %zu", value_list.type, ds->ds_num, size); return NULL; } - value = malloc(size * sizeof(*value)); - for (i = 0; i < size; ++i) { + value = calloc(size, sizeof(*value)); + for (size_t i = 0; i < size; ++i) { PyObject *item, *num; item = PySequence_Fast_GET_ITEM(values, i); /* Borrowed reference. */ - if (ds->ds->type == DS_TYPE_COUNTER) { + switch (ds->ds[i].type) { + case DS_TYPE_COUNTER: num = PyNumber_Long(item); /* New reference. */ if (num != NULL) { value[i].counter = PyLong_AsUnsignedLongLong(num);