Merge PR #27619 into master

* refs/pull/27619/head:
	mgr/BaseMgrModule: run MonCommandCompletion on the finisher
	mgr/BaseMgrModule: fix leak

Reviewed-by: Mykola Golub <mgolub@suse.com>
Reviewed-by: Tim Serong <tserong@suse.com>
This commit is contained in:
Sage Weil 2019-04-20 08:48:30 -05:00
commit df9d1b92a9
3 changed files with 13 additions and 5 deletions

View File

@ -46,9 +46,11 @@ ActivePyModules::ActivePyModules(PyModuleConfig &module_config_,
: module_config(module_config_), daemon_state(ds), cluster_state(cs),
monc(mc), clog(clog_), audit_clog(audit_clog_), objecter(objecter_),
client(client_), finisher(f),
cmd_finisher(g_ceph_context, "cmd_finisher", "cmdfin"),
server(server), py_module_registry(pmr), lock("ActivePyModules")
{
store_cache = std::move(store_data);
cmd_finisher.start();
}
ActivePyModules::~ActivePyModules() = default;
@ -434,6 +436,9 @@ void ActivePyModules::shutdown()
lock.Lock();
}
cmd_finisher.wait_for_empty();
cmd_finisher.stop();
modules.clear();
}

View File

@ -47,6 +47,9 @@ class ActivePyModules
Objecter &objecter;
Client &client;
Finisher &finisher;
public:
Finisher cmd_finisher;
private:
DaemonServer &server;
PyModuleRegistry &py_module_registry;

View File

@ -154,7 +154,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args)
auto c = new FunctionContext([command_c, self](int command_r){
self->py_modules->get_objecter().wait_for_latest_osdmap(
new FunctionContext([command_c, command_r](int wait_r){
command_c->finish(command_r);
command_c->complete(command_r);
})
);
});
@ -165,7 +165,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args)
{},
&command_c->outbl,
&command_c->outs,
c);
new C_OnFinisher(c, &self->py_modules->cmd_finisher));
} else if (std::string(type) == "osd") {
std::string err;
uint64_t osd_id = strict_strtoll(name, 10, &err);
@ -186,7 +186,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args)
&tid,
&command_c->outbl,
&command_c->outs,
command_c);
new C_OnFinisher(command_c, &self->py_modules->cmd_finisher));
} else if (std::string(type) == "mds") {
int r = self->py_modules->get_client().mds_command(
name,
@ -194,7 +194,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args)
{},
&command_c->outbl,
&command_c->outs,
command_c);
new C_OnFinisher(command_c, &self->py_modules->cmd_finisher));
if (r != 0) {
string msg("failed to send command to mds: ");
msg.append(cpp_strerror(r));
@ -221,7 +221,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args)
&tid,
&command_c->outbl,
&command_c->outs,
command_c);
new C_OnFinisher(command_c, &self->py_modules->cmd_finisher));
PyEval_RestoreThread(tstate);
return nullptr;
} else {