From: Loic Dachary Date: Sat, 25 Jan 2014 21:35:34 +0000 (+0100) Subject: erasure-code: allow loading a plugin from factory() X-Git-Tag: v0.79~80^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12d4f382d6d822dad61887386ff20978c7dcf83c;p=ceph.git erasure-code: allow loading a plugin from factory() The Mutex scope is restricted to only protect the load() method and not the factory() method. This allows a plugin to load another plugin from within the factory() method. Reviewed-By: Christophe Courtaut Signed-off-by: Loic Dachary --- diff --git a/src/erasure-code/ErasureCodePlugin.cc b/src/erasure-code/ErasureCodePlugin.cc index a76d6140cca..63494415de6 100644 --- a/src/erasure-code/ErasureCodePlugin.cc +++ b/src/erasure-code/ErasureCodePlugin.cc @@ -68,15 +68,18 @@ int ErasureCodePluginRegistry::factory(const std::string &plugin_name, ErasureCodeInterfaceRef *erasure_code, ostream &ss) { - Mutex::Locker l(lock); - ErasureCodePlugin *plugin = get(plugin_name); - if (plugin == 0) { + ErasureCodePlugin *plugin; + { + Mutex::Locker l(lock); int r = 0; - loading = true; - r = load(plugin_name, parameters, &plugin, ss); - loading = false; - if (r != 0) - return r; + plugin = get(plugin_name); + if (plugin == 0) { + loading = true; + r = load(plugin_name, parameters, &plugin, ss); + loading = false; + if (r != 0) + return r; + } } return plugin->factory(parameters, erasure_code);