diff options
Diffstat (limited to 'storage/perfschema')
-rw-r--r-- | storage/perfschema/pfs.cc | 29 | ||||
-rw-r--r-- | storage/perfschema/unittest/pfs-t.cc | 75 |
2 files changed, 58 insertions, 46 deletions
diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc index 3cd637ffa66..f0e2e5574fc 100644 --- a/storage/perfschema/pfs.cc +++ b/storage/perfschema/pfs.cc @@ -1093,7 +1093,8 @@ static void delete_thread_v1(PSI_thread *thread) } static PSI_mutex_locker* -get_thread_mutex_locker_v1(PSI_mutex *mutex, PSI_mutex_operation op) +get_thread_mutex_locker_v1(PSI_mutex_locker_state *state, + PSI_mutex *mutex, PSI_mutex_operation op) { PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex*> (mutex); DBUG_ASSERT((int) op >= 0); @@ -1138,7 +1139,8 @@ get_thread_mutex_locker_v1(PSI_mutex *mutex, PSI_mutex_operation op) } static PSI_rwlock_locker* -get_thread_rwlock_locker_v1(PSI_rwlock *rwlock, PSI_rwlock_operation op) +get_thread_rwlock_locker_v1(PSI_rwlock_locker_state *state, + PSI_rwlock *rwlock, PSI_rwlock_operation op) { PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock*> (rwlock); DBUG_ASSERT(static_cast<int> (op) >= 0); @@ -1184,7 +1186,8 @@ get_thread_rwlock_locker_v1(PSI_rwlock *rwlock, PSI_rwlock_operation op) } static PSI_cond_locker* -get_thread_cond_locker_v1(PSI_cond *cond, PSI_mutex * /* unused: mutex */, +get_thread_cond_locker_v1(PSI_cond_locker_state *state, + PSI_cond *cond, PSI_mutex * /* unused: mutex */, PSI_cond_operation op) { /* @@ -1242,7 +1245,8 @@ get_thread_cond_locker_v1(PSI_cond *cond, PSI_mutex * /* unused: mutex */, } static PSI_table_locker* -get_thread_table_locker_v1(PSI_table *table) +get_thread_table_locker_v1(PSI_table_locker_state *state, + PSI_table *table) { PFS_table *pfs_table= reinterpret_cast<PFS_table*> (table); DBUG_ASSERT(pfs_table != NULL); @@ -1284,7 +1288,8 @@ get_thread_table_locker_v1(PSI_table *table) } static PSI_file_locker* -get_thread_file_name_locker_v1(PSI_file_key key, +get_thread_file_name_locker_v1(PSI_file_locker_state *state, + PSI_file_key key, PSI_file_operation op, const char *name, const void *identity) { @@ -1341,7 +1346,8 @@ get_thread_file_name_locker_v1(PSI_file_key key, } static PSI_file_locker* -get_thread_file_stream_locker_v1(PSI_file *file, PSI_file_operation op) +get_thread_file_stream_locker_v1(PSI_file_locker_state *state, + PSI_file *file, PSI_file_operation op) { PFS_file *pfs_file= reinterpret_cast<PFS_file*> (file); @@ -1392,7 +1398,8 @@ get_thread_file_stream_locker_v1(PSI_file *file, PSI_file_operation op) } static PSI_file_locker* -get_thread_file_descriptor_locker_v1(File file, PSI_file_operation op) +get_thread_file_descriptor_locker_v1(PSI_file_locker_state *state, + File file, PSI_file_operation op) { int index= static_cast<int> (file); @@ -1462,7 +1469,7 @@ get_thread_file_descriptor_locker_v1(File file, PSI_file_operation op) return NULL; } -static void unlock_mutex_v1(PSI_thread * thread, PSI_mutex *mutex) +static void unlock_mutex_v1(PSI_mutex *mutex) { PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex*> (mutex); DBUG_ASSERT(pfs_mutex != NULL); @@ -1501,7 +1508,7 @@ static void unlock_mutex_v1(PSI_thread * thread, PSI_mutex *mutex) #endif } -static void unlock_rwlock_v1(PSI_thread *thread, PSI_rwlock *rwlock) +static void unlock_rwlock_v1(PSI_rwlock *rwlock) { PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock*> (rwlock); DBUG_ASSERT(pfs_rwlock != NULL); @@ -1577,7 +1584,7 @@ static void unlock_rwlock_v1(PSI_thread *thread, PSI_rwlock *rwlock) #endif } -static void signal_cond_v1(PSI_thread *thread, PSI_cond* cond) +static void signal_cond_v1(PSI_cond* cond) { PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond); DBUG_ASSERT(pfs_cond != NULL); @@ -1585,7 +1592,7 @@ static void signal_cond_v1(PSI_thread *thread, PSI_cond* cond) pfs_cond->m_cond_stat.m_signal_count++; } -static void broadcast_cond_v1(PSI_thread *thread, PSI_cond* cond) +static void broadcast_cond_v1(PSI_cond* cond) { PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond); DBUG_ASSERT(pfs_cond != NULL); diff --git a/storage/perfschema/unittest/pfs-t.cc b/storage/perfschema/unittest/pfs-t.cc index 2f3fb2792fc..238111ecaee 100644 --- a/storage/perfschema/unittest/pfs-t.cc +++ b/storage/perfschema/unittest/pfs-t.cc @@ -941,9 +941,13 @@ void test_locker_disabled() ok(file_A1 != NULL, "instrumented"); PSI_mutex_locker *mutex_locker; + PSI_mutex_locker_state mutex_state; PSI_rwlock_locker *rwlock_locker; + PSI_rwlock_locker_state rwlock_state; PSI_cond_locker *cond_locker; + PSI_cond_locker_state cond_state; PSI_file_locker *file_locker; + PSI_file_locker_state file_state; /* Pretend thread T-1 is disabled */ /* ------------------------------ */ @@ -955,17 +959,17 @@ void test_locker_disabled() cond_class_A->m_enabled= true; file_class_A->m_enabled= true; - mutex_locker= psi->get_thread_mutex_locker(mutex_A1, PSI_MUTEX_LOCK); + mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK); ok(mutex_locker == NULL, "no locker"); - rwlock_locker= psi->get_thread_rwlock_locker(rwlock_A1, PSI_RWLOCK_READLOCK); + rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK); ok(rwlock_locker == NULL, "no locker"); - cond_locker= psi->get_thread_cond_locker(cond_A1, mutex_A1, PSI_COND_WAIT); + cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT); ok(cond_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_name_locker(file_key_A, PSI_FILE_OPEN, "xxx", NULL); + file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_stream_locker(file_A1, PSI_FILE_READ); + file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_READ); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); /* Pretend the consumer is disabled */ @@ -978,17 +982,17 @@ void test_locker_disabled() cond_class_A->m_enabled= true; file_class_A->m_enabled= true; - mutex_locker= psi->get_thread_mutex_locker(mutex_A1, PSI_MUTEX_LOCK); + mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK); ok(mutex_locker == NULL, "no locker"); - rwlock_locker= psi->get_thread_rwlock_locker(rwlock_A1, PSI_RWLOCK_READLOCK); + rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK); ok(rwlock_locker == NULL, "no locker"); - cond_locker= psi->get_thread_cond_locker(cond_A1, mutex_A1, PSI_COND_WAIT); + cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT); ok(cond_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_name_locker(file_key_A, PSI_FILE_OPEN, "xxx", NULL); + file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_stream_locker(file_A1, PSI_FILE_READ); + file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_READ); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); /* Pretend the instrument is disabled */ @@ -1001,17 +1005,17 @@ void test_locker_disabled() cond_class_A->m_enabled= false; file_class_A->m_enabled= false; - mutex_locker= psi->get_thread_mutex_locker(mutex_A1, PSI_MUTEX_LOCK); + mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK); ok(mutex_locker == NULL, "no locker"); - rwlock_locker= psi->get_thread_rwlock_locker(rwlock_A1, PSI_RWLOCK_READLOCK); + rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK); ok(rwlock_locker == NULL, "no locker"); - cond_locker= psi->get_thread_cond_locker(cond_A1, mutex_A1, PSI_COND_WAIT); + cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT); ok(cond_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_name_locker(file_key_A, PSI_FILE_OPEN, "xxx", NULL); + file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_stream_locker(file_A1, PSI_FILE_READ); + file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_READ); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); /* Pretend everything is enabled */ @@ -1024,27 +1028,27 @@ void test_locker_disabled() cond_class_A->m_enabled= true; file_class_A->m_enabled= true; - mutex_locker= psi->get_thread_mutex_locker(mutex_A1, PSI_MUTEX_LOCK); + mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK); ok(mutex_locker != NULL, "locker"); psi->start_mutex_wait(mutex_locker, __FILE__, __LINE__); psi->end_mutex_wait(mutex_locker, 0); - rwlock_locker= psi->get_thread_rwlock_locker(rwlock_A1, PSI_RWLOCK_READLOCK); + rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK); ok(rwlock_locker != NULL, "locker"); psi->start_rwlock_rdwait(rwlock_locker, __FILE__, __LINE__); psi->end_rwlock_rdwait(rwlock_locker, 0); - cond_locker= psi->get_thread_cond_locker(cond_A1, mutex_A1, PSI_COND_WAIT); + cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT); ok(cond_locker != NULL, "locker"); psi->start_cond_wait(cond_locker, __FILE__, __LINE__); psi->end_cond_wait(cond_locker, 0); - file_locker= psi->get_thread_file_name_locker(file_key_A, PSI_FILE_OPEN, "xxx", NULL); + file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL); ok(file_locker != NULL, "locker"); psi->start_file_open_wait(file_locker, __FILE__, __LINE__); psi->end_file_open_wait(file_locker); - file_locker= psi->get_thread_file_stream_locker(file_A1, PSI_FILE_READ); + file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ); ok(file_locker != NULL, "locker"); psi->start_file_wait(file_locker, 10, __FILE__, __LINE__); psi->end_file_wait(file_locker, 10); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_READ); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ); ok(file_locker != NULL, "locker"); psi->start_file_wait(file_locker, 10, __FILE__, __LINE__); psi->end_file_wait(file_locker, 10); @@ -1059,17 +1063,17 @@ void test_locker_disabled() cond_class_A->m_enabled= true; file_class_A->m_enabled= true; - mutex_locker= psi->get_thread_mutex_locker(mutex_A1, PSI_MUTEX_LOCK); + mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK); ok(mutex_locker == NULL, "no locker"); - rwlock_locker= psi->get_thread_rwlock_locker(rwlock_A1, PSI_RWLOCK_READLOCK); + rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK); ok(rwlock_locker == NULL, "no locker"); - cond_locker= psi->get_thread_cond_locker(cond_A1, mutex_A1, PSI_COND_WAIT); + cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT); ok(cond_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_name_locker(file_key_A, PSI_FILE_OPEN, "xxx", NULL); + file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_stream_locker(file_A1, PSI_FILE_READ); + file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_READ); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ); ok(file_locker == NULL, "no locker"); shutdown_performance_schema(); @@ -1102,6 +1106,7 @@ void test_file_instrumentation_leak() PFS_file_class *file_class_A; PFS_file_class *file_class_B; + PSI_file_locker_state file_state; PSI_thread *thread_1; /* Preparation */ @@ -1130,24 +1135,24 @@ void test_file_instrumentation_leak() /* Simulate OPEN + READ of 100 bytes + CLOSE on descriptor 12 */ - file_locker= psi->get_thread_file_name_locker(file_key_A, PSI_FILE_OPEN, "AAA", NULL); + file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "AAA", NULL); ok(file_locker != NULL, "locker"); psi->start_file_open_wait(file_locker, __FILE__, __LINE__); psi->end_file_open_wait_and_bind_to_descriptor(file_locker, 12); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_READ); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ); ok(file_locker != NULL, "locker"); psi->start_file_wait(file_locker, 100, __FILE__, __LINE__); psi->end_file_wait(file_locker, 100); - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_CLOSE); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_CLOSE); ok(file_locker != NULL, "locker"); psi->start_file_wait(file_locker, 0, __FILE__, __LINE__); psi->end_file_wait(file_locker, 0); /* Simulate uninstrumented-OPEN + WRITE on descriptor 24 */ - file_locker= psi->get_thread_file_descriptor_locker((File) 24, PSI_FILE_WRITE); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 24, PSI_FILE_WRITE); ok(file_locker == NULL, "no locker, since the open was not instrumented"); /* @@ -1155,7 +1160,7 @@ void test_file_instrumentation_leak() the instrumentation should not leak (don't charge the file io on unknown B to "AAA") */ - file_locker= psi->get_thread_file_descriptor_locker((File) 12, PSI_FILE_WRITE); + file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_WRITE); ok(file_locker == NULL, "no locker, no leak"); shutdown_performance_schema(); |