Use a single timerfd_manager for all timers

trace-sqes
Vitaliy Filippov 2020-04-24 01:07:19 +03:00
parent 4f42e9659e
commit 0f2b8dbf6f
3 changed files with 3 additions and 16 deletions

15
osd.cpp
View File

@ -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);

2
osd.h
View File

@ -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;

View File

@ -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();
});