| 1362 | } |
| 1363 | |
| 1364 | static void intern_plugin_unlock(LEX *lex, plugin_ref plugin) |
| 1365 | { |
| 1366 | ssize_t i; |
| 1367 | st_plugin_int *pi; |
| 1368 | DBUG_ENTER("intern_plugin_unlock"); |
| 1369 | |
| 1370 | mysql_mutex_assert_owner(&LOCK_plugin); |
| 1371 | |
| 1372 | if (!plugin) |
| 1373 | DBUG_VOID_RETURN; |
| 1374 | |
| 1375 | pi= plugin_ref_to_int(plugin); |
| 1376 | |
| 1377 | #ifdef DBUG_OFF |
| 1378 | if (!pi->plugin_dl) |
| 1379 | DBUG_VOID_RETURN; |
| 1380 | #else |
| 1381 | my_free(plugin); |
| 1382 | #endif |
| 1383 | |
| 1384 | if (lex) |
| 1385 | { |
| 1386 | /* |
| 1387 | Remove one instance of this plugin from the use list. |
| 1388 | We are searching backwards so that plugins locked last |
| 1389 | could be unlocked faster - optimizing for LIFO semantics. |
| 1390 | */ |
| 1391 | for (i= lex->plugins.elements - 1; i >= 0; i--) |
| 1392 | if (plugin == *dynamic_element(&lex->plugins, i, plugin_ref*)) |
| 1393 | { |
| 1394 | delete_dynamic_element(&lex->plugins, i); |
| 1395 | break; |
| 1396 | } |
| 1397 | DBUG_ASSERT(i >= 0); |
| 1398 | } |
| 1399 | |
| 1400 | DBUG_ASSERT(pi->ref_count); |
| 1401 | pi->ref_count--; |
| 1402 | |
| 1403 | DBUG_PRINT("lock",("thd: %p plugin: \"%s\" UNLOCK ref_count: %d", |
| 1404 | current_thd, pi->name.str, pi->ref_count)); |
| 1405 | |
| 1406 | if (pi->state == PLUGIN_IS_DELETED && !pi->ref_count) |
| 1407 | reap_needed= true; |
| 1408 | |
| 1409 | DBUG_VOID_RETURN; |
| 1410 | } |
| 1411 | |
| 1412 | |
| 1413 | void plugin_unlock(THD *thd, plugin_ref plugin) |
no test coverage detected