X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetwork.c;h=109289e3a76d62924be53dce9902cd2e21c2273f;hb=9c98fa31ef50a6ff849d36cac4f5297faa6f7909;hp=9f3cfd3ba1b66ca8b6f81f42519adf941dc2a87b;hpb=131eda63f8958e63fb317f9584776b1311e49552;p=collectd.git diff --git a/src/network.c b/src/network.c index 9f3cfd3b..109289e3 100644 --- a/src/network.c +++ b/src/network.c @@ -1,6 +1,7 @@ /** * collectd - src/network.c * Copyright (C) 2005-2009 Florian octo Forster + * Copyright (C) 2009 Aman Gupta * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,6 +18,7 @@ * * Authors: * Florian octo Forster + * Aman Gupta **/ #define _BSD_SOURCE /* For struct ip_mreq */ @@ -52,6 +54,7 @@ #if HAVE_LIBGCRYPT # include +GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif #ifndef IPV6_ADD_MEMBERSHIP @@ -2133,7 +2136,7 @@ static void *receive_thread (void __attribute__((unused)) *arg) static void network_init_buffer (void) { - memset (send_buffer, 0, sizeof (send_buffer)); + memset (send_buffer, 0, network_config_packet_size); send_buffer_ptr = send_buffer; send_buffer_fill = 0; @@ -2452,7 +2455,7 @@ static int network_write (const data_set_t *ds, const value_list_t *vl, pthread_mutex_lock (&send_buffer_lock); status = add_to_buffer (send_buffer_ptr, - sizeof (send_buffer) - (send_buffer_fill + BUFF_SIG_SIZE), + network_config_packet_size - (send_buffer_fill + BUFF_SIG_SIZE), &send_buffer_vl, ds, vl); if (status >= 0) @@ -2466,7 +2469,7 @@ static int network_write (const data_set_t *ds, const value_list_t *vl, flush_buffer (); status = add_to_buffer (send_buffer_ptr, - sizeof (send_buffer) - (send_buffer_fill + BUFF_SIG_SIZE), + network_config_packet_size - (send_buffer_fill + BUFF_SIG_SIZE), &send_buffer_vl, ds, vl); @@ -2482,7 +2485,7 @@ static int network_write (const data_set_t *ds, const value_list_t *vl, ERROR ("network plugin: Unable to append to the " "buffer for some weird reason"); } - else if ((sizeof (send_buffer) - send_buffer_fill) < 15) + else if ((network_config_packet_size - send_buffer_fill) < 15) { flush_buffer (); } @@ -2934,6 +2937,12 @@ static int network_init (void) return (0); have_init = true; +#if HAVE_LIBGCRYPT + gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); + gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0); + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); +#endif + plugin_register_shutdown ("network", network_shutdown); send_buffer = malloc (network_config_packet_size);