mgrc: reset send_report timer on session change

Signed-off-by: John Spray <john.spray@redhat.com>
This commit is contained in:
John Spray 2016-07-15 16:48:32 +01:00
parent 7845f8d757
commit 1643a7fc60
2 changed files with 16 additions and 3 deletions

View File

@ -32,7 +32,8 @@ MgrClient::MgrClient(CephContext *cct_, Messenger *msgr_)
: Dispatcher(cct_), cct(cct_), msgr(msgr_),
session(nullptr),
lock("mgrc"),
timer(cct_, lock)
timer(cct_, lock),
report_callback(nullptr)
{
assert(cct != nullptr);
}
@ -95,6 +96,10 @@ bool MgrClient::handle_mgr_map(MMgrMap *m)
<< session->con->get_peer_addr() << dendl;
delete session;
session = nullptr;
if (report_callback != nullptr) {
timer.cancel_event(report_callback);
report_callback = nullptr;
}
std::vector<ceph_tid_t> erase_cmds;
auto commands = command_table.get_commands();
@ -166,6 +171,7 @@ void MgrClient::send_report()
{
assert(lock.is_locked_by_me());
assert(session);
report_callback = nullptr;
auto report = new MMgrReport();
auto pcc = cct->get_perfcounters_collection();
@ -221,8 +227,8 @@ void MgrClient::send_report()
session->con->send_message(report);
if (stats_period != 0) {
auto c = new C_StdFunction([this](){send_report();});
timer.add_event_after(stats_period, c);
report_callback = new C_StdFunction([this](){send_report();});
timer.add_event_after(stats_period, report_callback);
}
}
@ -230,6 +236,12 @@ bool MgrClient::handle_mgr_configure(MMgrConfigure *m)
{
assert(lock.is_locked_by_me());
if (session == nullptr) {
lderr(cct) << "dropping unexpected configure message" << dendl;
m->put();
return true;
}
ldout(cct, 4) << "stats_period=" << m->stats_period << dendl;
bool starting = (stats_period == 0) && (m->stats_period != 0);

View File

@ -65,6 +65,7 @@ protected:
void signal_cond_list(list<Cond*>& ls);
list<Cond*> waiting_for_session;
Context *report_callback;
public:
MgrClient(CephContext *cct_, Messenger *msgr_);