Merge pull request #2837 from abays/fix-collectd-tg-dtime
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Tue, 26 Jun 2018 14:08:22 +0000 (16:08 +0200)
committerGitHub <noreply@github.com>
Tue, 26 Jun 2018 14:08:22 +0000 (16:08 +0200)
Use CLOCK_REALTIME for collectd-tg times (fixes issue 2219)

1  2 
src/collectd-tg.c

diff --combined src/collectd-tg.c
@@@ -35,7 -35,6 +35,7 @@@
  #include <errno.h>
  #include <math.h>
  #include <signal.h>
 +#include <stdbool.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
@@@ -62,12 -61,12 +62,12 @@@ static const char *conf_service = NET_D
  
  static lcc_network_t *net;
  
 -static c_heap_t *values_heap = NULL;
 +static c_heap_t *values_heap;
  
  static struct sigaction sigint_action;
  static struct sigaction sigterm_action;
  
 -static _Bool loop = 1;
 +static bool loop = true;
  
  __attribute__((noreturn)) static void exit_usage(int exit_status) /* {{{ */
  {
@@@ -95,9 -94,9 +95,9 @@@
    exit(exit_status);
  } /* }}} void exit_usage */
  
 -static void signal_handler(int signal) /* {{{ */
 +static void signal_handler(int __attribute__((unused)) signal) /* {{{ */
  {
 -  loop = 0;
 +  loop = false;
  } /* }}} void signal_handler */
  
  #if HAVE_CLOCK_GETTIME
@@@ -105,7 -104,7 +105,7 @@@ static double dtime(void) /* {{{ *
  {
    struct timespec ts = {0};
  
-   if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
+   if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
      perror("clock_gettime");
  
    return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9;
@@@ -147,8 -146,7 +147,8 @@@ static int get_boundet_random(int min, 
  
    range = max - min;
  
 -  return min + ((int)(((double)range) * ((double)random()) / (((double)RAND_MAX) + 1.0)));
 +  return min + ((int)(((double)range) * ((double)random()) /
 +                      (((double)RAND_MAX) + 1.0)));
  } /* }}} int get_boundet_random */
  
  static lcc_value_list_t *create_value_list(void) /* {{{ */