1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. |
4 | Copyright (c) 2017, MariaDB Corporation. |
5 | |
6 | Portions of this file contain modifications contributed and copyrighted by |
7 | Google, Inc. Those modifications are gratefully acknowledged and are described |
8 | briefly in the InnoDB documentation. The contributions by Google are |
9 | incorporated with their permission, and subject to the conditions contained in |
10 | the file COPYING.Google. |
11 | |
12 | This program is free software; you can redistribute it and/or modify it under |
13 | the terms of the GNU General Public License as published by the Free Software |
14 | Foundation; version 2 of the License. |
15 | |
16 | This program is distributed in the hope that it will be useful, but WITHOUT |
17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
18 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License along with |
21 | this program; if not, write to the Free Software Foundation, Inc., |
22 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
23 | |
24 | *****************************************************************************/ |
25 | |
26 | /**************************************************//** |
27 | @file include/sync0debug.h |
28 | Debug checks for latches, header file |
29 | |
30 | Created 2012-08-21 Sunny Bains |
31 | *******************************************************/ |
32 | |
33 | #ifndef sync0debug_h |
34 | #define sync0debug_h |
35 | |
36 | #include "univ.i" |
37 | #include "sync0types.h" |
38 | |
39 | /** Initializes the synchronization data structures. */ |
40 | void |
41 | sync_check_init(); |
42 | |
43 | /** Free the InnoDB synchronization data structures. */ |
44 | void |
45 | sync_check_close(); |
46 | |
47 | #ifdef UNIV_DEBUG |
48 | /** Enable sync order checking. */ |
49 | void |
50 | sync_check_enable(); |
51 | |
52 | /** Check if it is OK to acquire the latch. |
53 | @param[in] latch latch type */ |
54 | void |
55 | sync_check_lock_validate(const latch_t* latch); |
56 | |
57 | /** Note that the lock has been granted |
58 | @param[in] latch latch type */ |
59 | void |
60 | sync_check_lock_granted(const latch_t* latch); |
61 | |
62 | /** Check if it is OK to acquire the latch. |
63 | @param[in] latch latch type |
64 | @param[in] level the level of the mutex */ |
65 | void |
66 | sync_check_lock(const latch_t* latch, latch_level_t level); |
67 | |
68 | /** |
69 | Check if it is OK to re-acquire the lock. */ |
70 | void |
71 | sync_check_relock(const latch_t* latch); |
72 | |
73 | /** Removes a latch from the thread level array if it is found there. |
74 | @param[in] latch to unlock */ |
75 | void |
76 | sync_check_unlock(const latch_t* latch); |
77 | |
78 | /** Checks if the level array for the current thread contains a |
79 | mutex or rw-latch at the specified level. |
80 | @param[in] level to find |
81 | @return a matching latch, or NULL if not found */ |
82 | const latch_t* |
83 | sync_check_find(latch_level_t level); |
84 | |
85 | /** Checks that the level array for the current thread is empty. |
86 | Terminate iteration if the functor returns true. |
87 | @param[in] functor called for each element. |
88 | @return true if the functor returns true for any element */ |
89 | bool |
90 | sync_check_iterate(const sync_check_functor_t& functor); |
91 | |
92 | /** Acquires the debug mutex. We cannot use the mutex defined in sync0sync, |
93 | because the debug mutex is also acquired in sync0arr while holding the OS |
94 | mutex protecting the sync array, and the ordinary mutex_enter might |
95 | recursively call routines in sync0arr, leading to a deadlock on the OS |
96 | mutex. */ |
97 | void |
98 | rw_lock_debug_mutex_enter(); |
99 | |
100 | /** Releases the debug mutex. */ |
101 | void |
102 | rw_lock_debug_mutex_exit(); |
103 | |
104 | #endif /* UNIV_DEBUG */ |
105 | |
106 | #endif /* !sync0debug_h */ |
107 | |