X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetwork.c;h=6b43ae75b47982609ffbeb702488c1d554e1e049;hb=9d9678b9e753ea0936612021f4f87f8092ab4e31;hp=1458a0ae88f66c5665bce965bec01ca0674cd5cf;hpb=e1d4681088e33d3ec256c296dff4dbaeb70b883a;p=collectd.git diff --git a/src/network.c b/src/network.c index 1458a0ae..6b43ae75 100644 --- a/src/network.c +++ b/src/network.c @@ -29,7 +29,6 @@ #include "plugin.h" #include "common.h" -#include "configfile.h" #include "utils_fbhash.h" #include "utils_cache.h" #include "utils_complain.h" @@ -304,7 +303,7 @@ static char *send_buffer; static char *send_buffer_ptr; static int send_buffer_fill; static cdtime_t send_buffer_last_update; -static value_list_t send_buffer_vl = VALUE_LIST_STATIC; +static value_list_t send_buffer_vl = VALUE_LIST_INIT; static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER; /* XXX: These counters are incremented from one place only. The spot in which @@ -2086,33 +2085,28 @@ static int sockent_init_crypto (sockent_t *se) /* {{{ */ } else /* (se->type == SOCKENT_TYPE_SERVER) */ { - if (se->data.server.security_level > SECURITY_LEVEL_NONE) + if ((se->data.server.security_level > SECURITY_LEVEL_NONE) + && (se->data.server.auth_file == NULL)) + { + ERROR ("network plugin: Server socket with security requested, " + "but no \"AuthFile\" is configured."); + return (-1); + } + if (se->data.server.auth_file != NULL) { if (network_init_gcrypt () < 0) { - ERROR ("network plugin: Cannot configure server socket with " - "security: Failed to initialize crypto library."); + ERROR ("network plugin: Cannot configure server socket with security: " + "Failed to initialize crypto library."); return (-1); } - if (se->data.server.auth_file == NULL) - { - ERROR ("network plugin: Server socket with " - "security requested, but no " - "password file is configured."); - return (-1); - } - } - if (se->data.server.auth_file != NULL) - { se->data.server.userdb = fbh_create (se->data.server.auth_file); if (se->data.server.userdb == NULL) { - ERROR ("network plugin: Reading password file " - "`%s' failed.", + ERROR ("network plugin: Reading password file \"%s\" failed.", se->data.server.auth_file); - if (se->data.server.security_level > SECURITY_LEVEL_NONE) - return (-1); + return (-1); } } } @@ -3392,7 +3386,6 @@ static int network_stats_read (void) /* {{{ */ vl.values = values; vl.values_len = 2; vl.time = 0; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "network", sizeof (vl.plugin)); /* Octets received / sent */ @@ -3450,14 +3443,6 @@ static int network_init (void) return (0); have_init = 1; -#if HAVE_LIBGCRYPT - if (network_init_gcrypt () < 0) - { - ERROR ("network plugin: Failed to initialize crypto library."); - return (-1); - } -#endif - if (network_config_stats) plugin_register_read ("network", network_stats_read); @@ -3492,7 +3477,7 @@ static int network_init (void) status = plugin_thread_create (&dispatch_thread_id, NULL /* no attributes */, dispatch_thread, - NULL /* no argument */); + NULL /* no argument */, "network dispatch"); if (status != 0) { char errbuf[1024]; @@ -3512,7 +3497,7 @@ static int network_init (void) status = plugin_thread_create (&receive_thread_id, NULL /* no attributes */, receive_thread, - NULL /* no argument */); + NULL /* no argument */, "network recv"); if (status != 0) { char errbuf[1024];