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

Function plugin_lock

sql/sql_plugin.cc:1031–1064  ·  view source on GitHub ↗

Notes on lifetime: If THD is passed as non-NULL (and with a non-NULL thd->lex), an entry is made in the thd->lex which will cause an automatic unlock of the plugin in the LEX destructor. In this case, no manual unlock must be done. Otherwise, when passing a NULL THD, the caller must arrange that plugin unlock happens later. */

Source from the content-addressed store, hash-verified

1029 unlock happens later.
1030*/
1031plugin_ref plugin_lock(THD *thd, plugin_ref ptr)
1032{
1033 LEX *lex= thd ? thd->lex : 0;
1034 plugin_ref rc;
1035 DBUG_ENTER("plugin_lock");
1036
1037#ifdef DBUG_OFF
1038 /*
1039 In optimized builds we don't do reference counting for built-in
1040 (plugin->plugin_dl == 0) plugins.
1041
1042 Note that we access plugin->plugin_dl outside of LOCK_plugin, and for
1043 dynamic plugins a 'plugin' could correspond to plugin that was unloaded
1044 meanwhile! But because st_plugin_int is always allocated on
1045 plugin_mem_root, the pointer can never be invalid - the memory is never
1046 freed.
1047 Of course, the memory that 'plugin' points to can be overwritten by
1048 another plugin being loaded, but plugin->plugin_dl can never change
1049 from zero to non-zero or vice versa.
1050 That is, it's always safe to check for plugin->plugin_dl==0 even
1051 without a mutex.
1052 */
1053 if (! plugin_dlib(ptr))
1054 {
1055 plugin_ref_to_int(ptr)->locks_total++;
1056 DBUG_RETURN(ptr);
1057 }
1058#endif
1059 mysql_mutex_lock(&LOCK_plugin);
1060 plugin_ref_to_int(ptr)->locks_total++;
1061 rc= intern_plugin_lock(lex, ptr);
1062 mysql_mutex_unlock(&LOCK_plugin);
1063 DBUG_RETURN(rc);
1064}
1065
1066
1067/*

Callers 4

tp_foreachFunction · 0.85
mysql_rm_table_no_locksFunction · 0.85

Calls 1

intern_plugin_lockFunction · 0.85

Tested by

no test coverage detected