|
1 | | -/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. |
| 1 | +/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 2 |
|
3 | 3 | This program is free software; you can redistribute it and/or modify |
4 | 4 | it under the terms of the GNU General Public License as published by |
|
27 | 27 | #include "stub_print_error.h" |
28 | 28 | #include "stub_pfs_defaults.h" |
29 | 29 |
|
| 30 | +void unload_performance_schema(); |
| 31 | + |
30 | 32 | /* test helpers, to simulate the setup */ |
31 | 33 |
|
32 | 34 | void setup_thread(PSI_thread *t, bool enabled) |
@@ -126,7 +128,7 @@ void test_bootstrap() |
126 | 128 | psi_2= boot->get_interface(PSI_VERSION_2); |
127 | 129 | ok(psi_2 == NULL, "version 2"); |
128 | 130 |
|
129 | | - shutdown_performance_schema(); |
| 131 | + unload_performance_schema(); |
130 | 132 | } |
131 | 133 |
|
132 | 134 | /* |
@@ -183,6 +185,28 @@ PSI * load_perfschema() |
183 | 185 | return (PSI*) psi; |
184 | 186 | } |
185 | 187 |
|
| 188 | +void unload_performance_schema() |
| 189 | +{ |
| 190 | + cleanup_table_share(); |
| 191 | + cleanup_instruments(); |
| 192 | + cleanup_sync_class(); |
| 193 | + cleanup_thread_class(); |
| 194 | + cleanup_table_share(); |
| 195 | + cleanup_file_class(); |
| 196 | + cleanup_stage_class(); |
| 197 | + cleanup_statement_class(); |
| 198 | + cleanup_socket_class(); |
| 199 | + cleanup_events_waits_history_long(); |
| 200 | + cleanup_events_stages_history_long(); |
| 201 | + cleanup_events_statements_history_long(); |
| 202 | + cleanup_table_share_hash(); |
| 203 | + cleanup_file_hash(); |
| 204 | + cleanup_digest(); |
| 205 | + PFS_atomic::cleanup(); |
| 206 | + |
| 207 | + shutdown_performance_schema(); |
| 208 | +} |
| 209 | + |
186 | 210 | void test_bad_registration() |
187 | 211 | { |
188 | 212 | PSI *psi; |
@@ -581,8 +605,7 @@ void test_bad_registration() |
581 | 605 | psi->register_socket("X", bad_socket_3, 1); |
582 | 606 | ok(dummy_socket_key == 2, "assigned key"); |
583 | 607 |
|
584 | | - |
585 | | - shutdown_performance_schema(); |
| 608 | + unload_performance_schema(); |
586 | 609 | } |
587 | 610 |
|
588 | 611 | void test_init_disabled() |
@@ -1016,7 +1039,7 @@ void test_init_disabled() |
1016 | 1039 | socket_A1= psi->init_socket(99, NULL, NULL, 0); |
1017 | 1040 | ok(socket_A1 == NULL, "broken socket key not instrumented"); |
1018 | 1041 |
|
1019 | | - shutdown_performance_schema(); |
| 1042 | + unload_performance_schema(); |
1020 | 1043 | } |
1021 | 1044 |
|
1022 | 1045 | void test_locker_disabled() |
@@ -1322,8 +1345,9 @@ void test_locker_disabled() |
1322 | 1345 | ok(socket_A1 != NULL, "instrumented"); |
1323 | 1346 | /* Socket thread owner has not been set */ |
1324 | 1347 | socket_locker= psi->start_socket_wait(&socket_state, socket_A1, PSI_SOCKET_SEND, 12, "foo.cc", 12); |
1325 | | - ok(socket_locker == NULL, "no locker (no thread owner)"); |
1326 | | - |
| 1348 | + ok(socket_locker != NULL, "locker (owner not used)"); |
| 1349 | + psi->end_socket_wait(socket_locker, 10); |
| 1350 | + |
1327 | 1351 | /* Pretend the running thread is not instrumented */ |
1328 | 1352 | /* ---------------------------------------------- */ |
1329 | 1353 |
|
@@ -1351,7 +1375,7 @@ void test_locker_disabled() |
1351 | 1375 | socket_locker= psi->start_socket_wait(&socket_state, socket_A1, PSI_SOCKET_SEND, 12, "foo.cc", 12); |
1352 | 1376 | ok(socket_locker == NULL, "no locker"); |
1353 | 1377 |
|
1354 | | - shutdown_performance_schema(); |
| 1378 | + unload_performance_schema(); |
1355 | 1379 | } |
1356 | 1380 |
|
1357 | 1381 | void test_file_instrumentation_leak() |
@@ -1438,7 +1462,7 @@ void test_file_instrumentation_leak() |
1438 | 1462 | file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_WRITE); |
1439 | 1463 | ok(file_locker == NULL, "no locker, no leak"); |
1440 | 1464 |
|
1441 | | - shutdown_performance_schema(); |
| 1465 | + unload_performance_schema(); |
1442 | 1466 | } |
1443 | 1467 |
|
1444 | 1468 | void test_enabled() |
@@ -1474,7 +1498,7 @@ void test_enabled() |
1474 | 1498 | { & cond_key_B, "C-B", 0} |
1475 | 1499 | }; |
1476 | 1500 |
|
1477 | | - shutdown_performance_schema(); |
| 1501 | + unload_performance_schema(); |
1478 | 1502 | #endif |
1479 | 1503 | } |
1480 | 1504 |
|
@@ -1644,5 +1668,5 @@ int main(int argc, char **argv) |
1644 | 1668 | MY_INIT(argv[0]); |
1645 | 1669 | do_all_tests(); |
1646 | 1670 | my_end(0); |
1647 | | - return exit_status(); |
| 1671 | + return (exit_status()); |
1648 | 1672 | } |
0 commit comments