From 0f2b8dbf6fc1d1f1a4918531d9ce858def7d7df0 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 24 Apr 2020 01:07:19 +0300 Subject: [PATCH] Use a single timerfd_manager for all timers --- osd.cpp | 15 ++------------- osd.h | 2 -- osd_cluster.cpp | 2 +- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/osd.cpp b/osd.cpp index a1eacae0..01266915 100644 --- a/osd.cpp +++ b/osd.cpp @@ -42,13 +42,12 @@ osd_t::osd_t(blockstore_config_t & config, blockstore_t *bs, ring_loop_t *ringlo throw std::runtime_error(std::string("epoll_create: ") + strerror(errno)); } - this->stats_tfd = new timerfd_interval(ringloop, print_stats_interval, [this]() + this->tfd = new timerfd_manager_t(ringloop); + this->tfd->set_timer(print_stats_interval*1000, true, [this](int timer_id) { print_stats(); }); - this->tfd = new timerfd_manager_t(ringloop); - init_cluster(); consumer.loop = [this]() { loop(); }; @@ -62,16 +61,6 @@ osd_t::~osd_t() delete tfd; tfd = NULL; } - if (stats_tfd) - { - delete stats_tfd; - stats_tfd = NULL; - } - if (sync_tfd) - { - delete sync_tfd; - sync_tfd = NULL; - } ringloop->unregister_consumer(&consumer); close(epoll_fd); close(listen_fd); diff --git a/osd.h b/osd.h index 7b6113cb..55734b3b 100644 --- a/osd.h +++ b/osd.h @@ -15,7 +15,6 @@ #include "blockstore.h" #include "ringloop.h" -#include "timerfd_interval.h" #include "timerfd_manager.h" #include "osd_ops.h" #include "osd_peering_pg.h" @@ -246,7 +245,6 @@ class osd_t uint32_t bs_block_size, bs_disk_alignment; uint64_t pg_stripe_size = 4*1024*1024; // 4 MB by default ring_loop_t *ringloop; - timerfd_interval *stats_tfd = NULL, *sync_tfd = NULL; timerfd_manager_t *tfd = NULL; int wait_state = 0; diff --git a/osd_cluster.cpp b/osd_cluster.cpp index e83322ed..c64309f7 100644 --- a/osd_cluster.cpp +++ b/osd_cluster.cpp @@ -61,7 +61,7 @@ void osd_t::init_primary() } if (autosync_interval > 0) { - this->sync_tfd = new timerfd_interval(ringloop, autosync_interval, [this]() + this->tfd->set_timer(autosync_interval*1000, true, [this](int timer_id) { autosync(); });