OpRequest: use OpRequestRef for OpHistory

Signed-off-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
Samuel Just 2013-03-20 11:49:03 -07:00
parent 210ecc5871
commit 51ae509800
2 changed files with 7 additions and 9 deletions

View File

@ -30,11 +30,11 @@ void OpHistory::insert(utime_t now, OpRequest *op)
void OpHistory::cleanup(utime_t now)
{
while (arrived.size() &&
now - arrived.begin()->first > (double)(g_conf->osd_op_history_duration)) {
(now - arrived.begin()->first >
(double)(g_conf->osd_op_history_duration))) {
duration.erase(make_pair(
arrived.begin()->second->get_duration(),
arrived.begin()->second));
delete arrived.begin()->second;
arrived.erase(arrived.begin());
}
@ -42,7 +42,6 @@ void OpHistory::cleanup(utime_t now)
arrived.erase(make_pair(
duration.begin()->second->get_arrived(),
duration.begin()->second));
delete duration.begin()->second;
duration.erase(duration.begin());
}
}
@ -55,7 +54,7 @@ void OpHistory::dump_ops(utime_t now, Formatter *f)
f->dump_int("duration to keep", g_conf->osd_op_history_duration);
{
f->open_array_section("Ops");
for (set<pair<utime_t, const OpRequest *> >::const_iterator i =
for (set<pair<utime_t, OpRequestRef> >::const_iterator i =
arrived.begin();
i != arrived.end();
++i) {

View File

@ -26,18 +26,17 @@
#include "osd/osd_types.h"
class OpRequest;
typedef std::tr1::shared_ptr<OpRequest> OpRequestRef;
class OpHistory {
set<pair<utime_t, const OpRequest *> > arrived;
set<pair<double, const OpRequest *> > duration;
set<pair<utime_t, OpRequestRef> > arrived;
set<pair<double, OpRequestRef> > duration;
void cleanup(utime_t now);
public:
void insert(utime_t now, OpRequest *op);
void insert(utime_t now, OpRequestRef op);
void dump_ops(utime_t now, Formatter *f);
};
class OpRequest;
typedef std::tr1::shared_ptr<OpRequest> OpRequestRef;
class OpTracker {
class RemoveOnDelete {
OpTracker *tracker;