Many plugins and files: Convert "interval_g" and "vl->interval" to cdtime_t.
[collectd.git] / src / network.c
index 1544ecf..43193cf 100644 (file)
@@ -1377,8 +1377,8 @@ static int parse_packet (sockent_t *se, /* {{{ */
                                        &tmp);
                        if (status == 0)
                        {
-                               vl.time = (time_t) tmp;
-                               n.time = (time_t) tmp;
+                               vl.time = TIME_T_TO_CDTIME_T (tmp);
+                               n.time = TIME_T_TO_CDTIME_T (tmp);
                        }
                }
                else if (pkg_type == TYPE_INTERVAL)
@@ -1387,7 +1387,7 @@ static int parse_packet (sockent_t *se, /* {{{ */
                        status = parse_part_number (&buffer, &buffer_size,
                                        &tmp);
                        if (status == 0)
-                               vl.interval = (int) tmp;
+                               vl.interval = TIME_T_TO_CDTIME_T (tmp);
                }
                else if (pkg_type == TYPE_HOST)
                {
@@ -2583,16 +2583,18 @@ static int add_to_buffer (char *buffer, int buffer_size, /* {{{ */
 
        if (vl_def->time != vl->time)
        {
+               time_t tmp = CDTIME_T_TO_TIME_T (vl->time);
                if (write_part_number (&buffer, &buffer_size, TYPE_TIME,
-                                       (uint64_t) vl->time))
+                                       (uint64_t) tmp))
                        return (-1);
                vl_def->time = vl->time;
        }
 
        if (vl_def->interval != vl->interval)
        {
+               /* TODO: Create a new type for sub-second intervals. */
                if (write_part_number (&buffer, &buffer_size, TYPE_INTERVAL,
-                                       (uint64_t) vl->interval))
+                                       (uint64_t) CDTIME_T_TO_TIME_T (vl->interval)))
                        return (-1);
                vl_def->interval = vl->interval;
        }
@@ -3070,12 +3072,14 @@ static int network_notification (const notification_t *n,
   char *buffer_ptr = buffer;
   int   buffer_free = sizeof (buffer);
   int   status;
+  time_t tmp;
 
   memset (buffer, '\0', sizeof (buffer));
 
 
+  tmp = CDTIME_T_TO_TIME_T (n->time);
   status = write_part_number (&buffer_ptr, &buffer_free, TYPE_TIME,
-      (uint64_t) n->time);
+      (uint64_t) tmp);
   if (status != 0)
     return (-1);
 
@@ -3348,9 +3352,9 @@ static int network_init (void)
  * just send the buffer if `flush'  is called - if the requested value was in
  * there, good. If not, well, then there is nothing to flush.. -octo
  */
-static int network_flush (int timeout,
-               const char __attribute__((unused)) *identifier,
-               user_data_t __attribute__((unused)) *user_data)
+static int network_flush (__attribute__((unused)) cdtime_t timeout,
+               __attribute__((unused)) const char *identifier,
+               __attribute__((unused)) user_data_t *user_data)
 {
        pthread_mutex_lock (&send_buffer_lock);