if (daemon->reconnect_holdoff > 60000000)
daemon->reconnect_holdoff = 60000000;
- // Destroy the stats timer
- if (daemon->stats_timer) {
- sd_event_source_unref(daemon->stats_timer);
- daemon->stats_timer = NULL;
+ // Disable sending stats until we are connected
+ r = sd_event_source_set_enabled(daemon->stats_timer, SD_EVENT_OFF);
+ if (r < 0) {
+ ERROR(daemon->ctx, "Could not disable the stats timer: %s\n", strerror(-r));
+ return r;
}
return 0;
// Reset the holdoff timer
daemon->reconnect_holdoff = 1000000;
- // Submit stats
- r = sd_event_add_time_relative(daemon->loop, &daemon->stats_timer,
- CLOCK_MONOTONIC, 0, 0, pakfire_daemon_submit_stats, daemon);
- if (r < 0) {
- ERROR(daemon->ctx, "Could not register the stat timer: %s\n", strerror(-r));
- return r;
- }
-
// Submit stats continuously
r = sd_event_source_set_enabled(daemon->stats_timer, SD_EVENT_ON);
if (r < 0) {
return r;
}
+ // Setup the stats timer
+ r = sd_event_add_time_relative(daemon->loop, &daemon->stats_timer,
+ CLOCK_MONOTONIC, 0, 0, pakfire_daemon_submit_stats, daemon);
+ if (r < 0) {
+ ERROR(daemon->ctx, "Could not register the stat timer: %s\n", strerror(-r));
+ return r;
+ }
+
+ // Disable sending stats until we are connected
+ r = sd_event_source_set_enabled(daemon->stats_timer, SD_EVENT_OFF);
+ if (r < 0) {
+ ERROR(daemon->ctx, "Could not disable the stats timer: %s\n", strerror(-r));
+ return r;
+ }
+
return 0;
}