MCPcopy Create free account
hub / github.com/MariaDB/server / plugin_foreach_with_mask

Function plugin_foreach_with_mask

sql/sql_plugin.cc:2525–2577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2523
2524
2525bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
2526 int type, uint state_mask, void *arg)
2527{
2528 size_t idx, total= 0;
2529 struct st_plugin_int *plugin;
2530 plugin_ref *plugins;
2531 my_bool res= FALSE;
2532 DBUG_ENTER("plugin_foreach_with_mask");
2533
2534 if (!initialized)
2535 DBUG_RETURN(FALSE);
2536
2537 mysql_mutex_lock(&LOCK_plugin);
2538 /*
2539 Do the alloca out here in case we do have a working alloca:
2540 leaving the nested stack frame invalidates alloca allocation.
2541 */
2542 if (type == MYSQL_ANY_PLUGIN)
2543 {
2544 plugins= (plugin_ref*) my_alloca(plugin_array.elements * sizeof(plugin_ref));
2545 for (idx= 0; idx < plugin_array.elements; idx++)
2546 {
2547 plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
2548 if ((plugins[total]= intern_plugin_lock(0, plugin_int_to_ref(plugin),
2549 state_mask)))
2550 total++;
2551 }
2552 }
2553 else
2554 {
2555 HASH *hash= plugin_hash + type;
2556 plugins= (plugin_ref*) my_alloca(hash->records * sizeof(plugin_ref));
2557 for (idx= 0; idx < hash->records; idx++)
2558 {
2559 plugin= (struct st_plugin_int *) my_hash_element(hash, idx);
2560 if ((plugins[total]= intern_plugin_lock(0, plugin_int_to_ref(plugin),
2561 state_mask)))
2562 total++;
2563 }
2564 }
2565 mysql_mutex_unlock(&LOCK_plugin);
2566
2567 for (idx= 0; idx < total; idx++)
2568 {
2569 /* It will stop iterating on first engine error when "func" returns TRUE */
2570 if ((res= func(thd, plugins[idx], arg)))
2571 break;
2572 }
2573
2574 plugin_unlock_list(0, plugins, total);
2575 my_afree(plugins);
2576 DBUG_RETURN(res);
2577}
2578
2579
2580static bool plugin_dl_foreach_internal(THD *thd, st_plugin_dl *plugin_dl,

Callers 6

fill_plugin_versionFunction · 0.85
ha_prepare_for_backupFunction · 0.85
ha_end_backupFunction · 0.85
ha_pre_shutdownFunction · 0.85
fill_pluginsFunction · 0.85
fill_schema_enginesFunction · 0.85

Calls 3

intern_plugin_lockFunction · 0.85
my_hash_elementFunction · 0.85
plugin_unlock_listFunction · 0.85

Tested by

no test coverage detected