1 /* 2 Copyright (c) 2011, 2021, Oracle and/or its affiliates. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef NDB_MUTEX_DEADLOCK_DETECTOR_H 26 #define NDB_MUTEX_DEADLOCK_DETECTOR_H 27 28 #include <NdbMutex.h> 29 30 struct nmdd_mask 31 { 32 unsigned char * m_mask; 33 unsigned m_len; 34 }; 35 36 struct nmdd_mutex_array 37 { 38 NdbMutex ** m_array; 39 unsigned m_used; 40 unsigned m_array_len; 41 }; 42 43 struct ndb_mutex_state 44 { 45 struct nmdd_mask m_locked_before_mask; /* mutexes held when locking this mutex */ 46 struct nmdd_mutex_array m_locked_before_list; /* mutexes held when locking this mutex */ 47 48 struct nmdd_mutex_array m_locked_after_list; /* mutexes locked when holding this mutex*/ 49 struct nmdd_mask m_locked_after_mask; /* mask (for quick check) */ 50 51 unsigned m_no; /* my mutex "id" (for access in masks) */ 52 }; 53 54 struct ndb_mutex_thr_state 55 { 56 struct nmdd_mutex_array m_mutexes_locked; 57 }; 58 59 #ifdef __cplusplus 60 extern "C" { 61 #endif 62 63 void NdbMutex_DeadlockDetectorInit(); 64 void NdbMutex_DeadlockDetectorEnd(); 65 66 void ndb_mutex_created(NdbMutex*); 67 void ndb_mutex_destoyed(NdbMutex*); 68 void ndb_mutex_locked(NdbMutex*); 69 void ndb_mutex_unlocked(NdbMutex*); 70 void ndb_mutex_try_locked(NdbMutex*); 71 72 void ndb_mutex_thread_init(struct ndb_mutex_thr_state*); 73 void ndb_mutex_thread_exit(); 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 80 #endif 81