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 <christophe.courtaut@gmail.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
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);