summaryrefslogtreecommitdiffstats
path: root/src/mgr
diff options
context:
space:
mode:
authorJohn Spray <john.spray@redhat.com>2016-09-19 21:35:28 +0200
committerJohn Spray <john.spray@redhat.com>2016-09-29 18:27:05 +0200
commit2210772ed87ca281a60549ec40b1a1abe271d6e7 (patch)
tree04687777227ee9e25262ceaf9acefd25c8f90658 /src/mgr
parentpackaging: add boost-python dependency (diff)
downloadceph-2210772ed87ca281a60549ec40b1a1abe271d6e7.tar.xz
ceph-2210772ed87ca281a60549ec40b1a1abe271d6e7.zip
common: refactor CommandTable
Avoid handling out raw pointers to the ops, which are in fact owned by the table. Signed-off-by: John Spray <john.spray@redhat.com>
Diffstat (limited to 'src/mgr')
-rw-r--r--src/mgr/MgrClient.cc34
-rw-r--r--src/mgr/MgrClient.h1
2 files changed, 18 insertions, 17 deletions
diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc
index d0baeb4d374..bc272d34381 100644
--- a/src/mgr/MgrClient.cc
+++ b/src/mgr/MgrClient.cc
@@ -109,8 +109,8 @@ bool MgrClient::handle_mgr_map(MMgrMap *m)
auto commands = command_table.get_commands();
for (const auto &i : commands) {
// FIXME be nicer, retarget command on new mgr?
- if (i.second->on_finish != nullptr) {
- i.second->on_finish->complete(-ETIMEDOUT);
+ if (i.second.on_finish != nullptr) {
+ i.second.on_finish->complete(-ETIMEDOUT);
}
erase_cmds.push_back(i.first);
}
@@ -296,15 +296,15 @@ int MgrClient::start_command(const vector<string>& cmd, const bufferlist& inbl,
assert(map.epoch > 0);
- MgrCommand *op = command_table.start_command();
- op->cmd = cmd;
- op->inbl = inbl;
- op->outbl = outbl;
- op->outs = outs;
- op->on_finish = onfinish;
+ auto &op = command_table.start_command();
+ op.cmd = cmd;
+ op.inbl = inbl;
+ op.outbl = outbl;
+ op.outs = outs;
+ op.on_finish = onfinish;
// Leaving fsid argument null because it isn't used.
- MCommand *m = op->get_message({});
+ MCommand *m = op.get_message({});
assert(session);
assert(session->con);
session->con->send_message(m);
@@ -319,24 +319,24 @@ bool MgrClient::handle_command_reply(MCommandReply *m)
ldout(cct, 20) << *m << dendl;
const auto tid = m->get_tid();
- const auto op = command_table.get_command(tid);
- if (op == nullptr) {
+ if (!command_table.exists(tid)) {
ldout(cct, 4) << "handle_command_reply tid " << m->get_tid()
<< " not found" << dendl;
m->put();
return true;
}
- if (op->outbl) {
- op->outbl->claim(m->get_data());
+ auto &op = command_table.get_command(tid);
+ if (op.outbl) {
+ op.outbl->claim(m->get_data());
}
- if (op->outs) {
- *(op->outs) = m->rs;
+ if (op.outs) {
+ *(op.outs) = m->rs;
}
- if (op->on_finish) {
- op->on_finish->complete(m->r);
+ if (op.on_finish) {
+ op.on_finish->complete(m->r);
}
command_table.erase(tid);
diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h
index 705dea8c4ef..396bb7473b0 100644
--- a/src/mgr/MgrClient.h
+++ b/src/mgr/MgrClient.h
@@ -44,6 +44,7 @@ class MgrCommand : public CommandOp
public:
MgrCommand(ceph_tid_t t) : CommandOp(t) {}
+ MgrCommand() : CommandOp() {}
};
class MgrClient : public Dispatcher