~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/loader.cc

  • Committer: Eric Day
  • Date: 2010-03-25 19:28:37 UTC
  • mfrom: (1405 staging)
  • mto: This revision was merged to the branch mainline in revision 1409.
  • Revision ID: eday@oddments.org-20100325192837-4exmacbrywjovsqp
Merged trunk, rsolved conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
                              const vector<string> &plugins_to_remove);
155
155
static bool plugin_load_list(plugin::Registry &registry,
156
156
                             memory::Root *tmp_root, int *argc, char **argv,
157
 
                             const vector<string> &plugin_list);
 
157
                             const set<string> &plugin_list);
158
158
static int test_plugin_options(memory::Root *, plugin::Module *,
159
159
                               int *, char **);
160
160
static void unlock_variables(Session *session, struct system_variables *vars);
281
281
}
282
282
 
283
283
 
284
 
static void delete_module(plugin::Registry &registry, plugin::Module *module)
 
284
static void delete_module(plugin::Module *module)
285
285
{
286
 
  plugin::Manifest manifest= module->getManifest();
287
 
 
288
 
  if (module->isInited)
289
 
  {
290
 
    if (manifest.deinit)
291
 
      manifest.deinit(registry);
292
 
  }
293
 
 
294
286
  /* Free allocated strings before deleting the plugin. */
295
287
  plugin_vars_free_values(module->system_vars);
296
288
  module->isInited= false;
303
295
 
304
296
static void reap_plugins(plugin::Registry &registry)
305
297
{
306
 
  plugin::Module *module;
307
 
 
308
298
  std::map<std::string, plugin::Module *>::const_iterator modules=
309
299
    registry.getModulesMap().begin();
310
 
    
 
300
 
311
301
  while (modules != registry.getModulesMap().end())
312
302
  {
313
 
    module= (*modules).second;
314
 
    delete_module(registry, module);
 
303
    plugin::Module *module= (*modules).second;
 
304
    delete_module(module);
315
305
    ++modules;
316
306
  }
 
307
 
317
308
  drizzle_del_plugin_sysvar();
318
309
}
319
310
 
343
334
{
344
335
  assert(module->isInited == false);
345
336
 
346
 
  registry.setCurrentModule(module);
 
337
  plugin::Context loading_context(registry, module);
347
338
  if (module->getManifest().init)
348
339
  {
349
 
    if (module->getManifest().init(registry))
 
340
    if (module->getManifest().init(loading_context))
350
341
    {
351
342
      errmsg_printf(ERRMSG_LVL_ERROR,
352
343
                    _("Plugin '%s' init function returned error.\n"),
354
345
      return true;
355
346
    }
356
347
  }
357
 
  registry.clearCurrentModule();
358
348
  module->isInited= true;
359
349
 
360
350
 
456
446
    tokenize(opt_plugin_remove, plugins_to_remove, ",", true);
457
447
    plugin_prune_list(plugin_list, plugins_to_remove);
458
448
  }
 
449
 
 
450
  /* Uniquify the list */
 
451
  const set<string> plugin_list_set(plugin_list.begin(), plugin_list.end());
459
452
  
460
453
  /* Register all dynamic plugins */
461
454
  load_failed= plugin_load_list(registry, &tmp_root, argc, argv,
462
 
                                plugin_list);
 
455
                                plugin_list_set);
463
456
  if (load_failed)
464
457
  {
465
458
    free_root(&tmp_root, MYF(0));
487
480
      plugin_initialize_vars(module);
488
481
 
489
482
      if (plugin_initialize(registry, module))
490
 
        delete_module(registry, module);
 
483
        delete_module(module);
491
484
    }
492
485
  }
493
486
 
533
526
*/
534
527
static bool plugin_load_list(plugin::Registry &registry,
535
528
                             memory::Root *tmp_root, int *argc, char **argv,
536
 
                             const vector<string> &plugin_list)
 
529
                             const set<string> &plugin_list)
537
530
{
538
531
  plugin::Library *library= NULL;
539
532
 
540
 
  for (vector<string>::const_iterator iter= plugin_list.begin();
 
533
  for (set<string>::const_iterator iter= plugin_list.begin();
541
534
       iter != plugin_list.end();
542
535
       ++iter)
543
536
  {