Skip to content

Commit

Permalink
master,stats: Use time_t instead of unsigned long to count seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
mrannanj authored and Timo Sirainen committed Oct 6, 2017
1 parent 2f14f9b commit eb7f74b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/master/main.c
Expand Up @@ -584,7 +584,7 @@ static const char *get_full_config_path(struct service_list *list)

static void master_time_moved(time_t old_time, time_t new_time)
{
unsigned long secs;
time_t secs;

if (new_time >= old_time)
return;
Expand All @@ -595,9 +595,9 @@ static void master_time_moved(time_t old_time, time_t new_time)
if (secs > SERVICE_TIME_MOVED_BACKWARDS_MAX_THROTTLE_SECS)
secs = SERVICE_TIME_MOVED_BACKWARDS_MAX_THROTTLE_SECS;
services_throttle_time_sensitives(services, secs);
i_warning("Time moved backwards by %lu seconds, "
"waiting for %lu secs until new services are launched again.",
(unsigned long)(old_time - new_time), secs);
i_warning("Time moved backwards by %"PRIdTIME_T" seconds, waiting for "
"%"PRIdTIME_T" secs until new services are launched again.",
old_time - new_time, secs);
}

static void daemonize(void)
Expand Down
16 changes: 8 additions & 8 deletions src/stats/mail-stats.c
Expand Up @@ -19,27 +19,27 @@ mail_global_stats_sent(void *ctx)
static void
mail_global_stats_send(void *u0 ATTR_UNUSED)
{
unsigned long ts = (unsigned long)ioloop_time;
time_t ts = ioloop_time;
if (*stats_settings->carbon_name != '\0' &&
*stats_settings->carbon_server != '\0') {
string_t *str = t_str_new(256);
const char *prefix = t_strdup_printf("dovecot.%s.global",
stats_settings->carbon_name);
str_printfa(str, "%s.logins %u %lu\r\n", prefix,
str_printfa(str, "%s.logins %u %"PRIdTIME_T"\r\n", prefix,
mail_global_stats.num_logins, ts);
str_printfa(str, "%s.cmds %u %lu\r\n", prefix,
str_printfa(str, "%s.cmds %u %"PRIdTIME_T"\r\n", prefix,
mail_global_stats.num_cmds, ts);
str_printfa(str, "%s.connected_sessions %u %lu\r\n", prefix,
mail_global_stats.num_connected_sessions,
str_printfa(str, "%s.connected_sessions %u %"PRIdTIME_T"\r\n",
prefix, mail_global_stats.num_connected_sessions,
ts);
str_printfa(str, "%s.last_reset %lu %lu\r\n", prefix,
mail_global_stats.reset_timestamp, ts);
str_printfa(str, "%s.last_reset %"PRIdTIME_T" %"PRIdTIME_T"\r\n",
prefix, mail_global_stats.reset_timestamp, ts);
/* then export rest of the stats */
for(size_t i = 0; i < stats_field_count(); i++) {
str_printfa(str, "%s.%s ", prefix,
stats_field_name(i));
stats_field_value(str, mail_global_stats.stats, i);
str_printfa(str, " %lu\r\n", ts);
str_printfa(str, " %"PRIdTIME_T"\r\n", ts);
}

/* and send them along */
Expand Down

0 comments on commit eb7f74b

Please sign in to comment.