summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_init.c9
-rw-r--r--mysys/my_static.c22
-rw-r--r--mysys/my_thr_init.c4
-rw-r--r--mysys/mysys_priv.h6
-rw-r--r--mysys/thr_lock.c23
5 files changed, 36 insertions, 28 deletions
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 324f0f86f4d..2c06425f6fb 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -26,7 +26,7 @@
#ifdef _MSC_VER
#include <locale.h>
#include <crtdbg.h>
-/* WSAStartup needs winsock library*/
+/* WSAStartup needs winsock library*/
#pragma comment(lib, "ws2_32")
#endif
my_bool have_tcpip=0;
@@ -441,11 +441,10 @@ static my_bool win32_init_tcp_ip()
}
#endif /* __WIN__ */
-#ifdef HAVE_PSI_INTERFACE
-
PSI_stage_info stage_waiting_for_table_level_lock=
{0, "Waiting for table level lock", 0};
+#ifdef HAVE_PSI_INTERFACE
#if !defined(HAVE_PREAD) && !defined(_WIN32)
PSI_mutex_key key_my_file_info_mutex;
#endif /* !defined(HAVE_PREAD) && !defined(_WIN32) */
@@ -457,7 +456,7 @@ PSI_mutex_key key_LOCK_localtime_r;
PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
- key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
+ key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
key_THR_LOCK_open, key_THR_LOCK_threads,
key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap, key_LOCK_uuid_generator;
@@ -478,7 +477,6 @@ static PSI_mutex_info all_mysys_mutexes[]=
{ &key_my_thread_var_mutex, "my_thread_var::mutex", 0},
{ &key_THR_LOCK_charset, "THR_LOCK_charset", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_heap, "THR_LOCK_heap", PSI_FLAG_GLOBAL},
- { &key_THR_LOCK_isam, "THR_LOCK_isam", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_lock, "THR_LOCK_lock", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_malloc, "THR_LOCK_malloc", PSI_FLAG_GLOBAL},
{ &key_THR_LOCK_mutex, "THR_LOCK::mutex", 0},
@@ -566,3 +564,4 @@ void my_init_mysys_psi_keys()
mysql_stage_register(category, all_mysys_stages, count);
}
#endif /* HAVE_PSI_INTERFACE */
+
diff --git a/mysys/my_static.c b/mysys/my_static.c
index f9d019c8dc1..b40ea8e3f0c 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2012, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -78,18 +77,19 @@ void (*error_handler_hook)(uint error, const char *str, myf MyFlags)=
void (*fatal_error_handler_hook)(uint error, const char *str, myf MyFlags)=
my_message_stderr;
-static const char *proc_info_dummy(void *a __attribute__((unused)),
- const char *b __attribute__((unused)),
- const char *c __attribute__((unused)),
- const char *d __attribute__((unused)),
- const unsigned int e __attribute__((unused)))
+static void proc_info_dummy(void *a __attribute__((unused)),
+ const PSI_stage_info *b __attribute__((unused)),
+ PSI_stage_info *c __attribute__((unused)),
+ const char *d __attribute__((unused)),
+ const char *e __attribute__((unused)),
+ const unsigned int f __attribute__((unused)))
{
- return 0;
+ return;
}
/* this is to be able to call set_thd_proc_info from the C code */
-const char *(*proc_info_hook)(void *, const char *, const char *, const char *,
- const unsigned int)= proc_info_dummy;
+void (*proc_info_hook)(void *, const PSI_stage_info *, PSI_stage_info *,
+ const char *, const char *, const unsigned int)= proc_info_dummy;
void (*debug_sync_C_callback_ptr)(MYSQL_THD, const char *, size_t)= 0;
/* How to disable options */
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index ac16189f3a7..7c64faa7a28 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -25,7 +25,7 @@
pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open,
- THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_myisam, THR_LOCK_heap,
+ THR_LOCK_lock, THR_LOCK_myisam, THR_LOCK_heap,
THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads,
THR_LOCK_myisam_mmap;
@@ -73,7 +73,6 @@ static void my_thread_init_common_mutex(void)
{
mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_THR_LOCK_lock, &THR_LOCK_lock, MY_MUTEX_INIT_FAST);
- mysql_mutex_init(key_THR_LOCK_isam, &THR_LOCK_isam, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_THR_LOCK_myisam_mmap, &THR_LOCK_myisam_mmap, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST);
@@ -88,7 +87,6 @@ void my_thread_destroy_common_mutex(void)
{
mysql_mutex_destroy(&THR_LOCK_open);
mysql_mutex_destroy(&THR_LOCK_lock);
- mysql_mutex_destroy(&THR_LOCK_isam);
mysql_mutex_destroy(&THR_LOCK_myisam);
mysql_mutex_destroy(&THR_LOCK_myisam_mmap);
mysql_mutex_destroy(&THR_LOCK_heap);
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index f5d2f301837..400135c9aaa 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -39,7 +39,7 @@ extern PSI_mutex_key key_LOCK_localtime_r;
extern PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
- key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
+ key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
key_THR_LOCK_open, key_THR_LOCK_threads, key_LOCK_uuid_generator,
key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap;
@@ -56,8 +56,10 @@ extern PSI_rwlock_key key_SAFEHASH_mutex;
#endif /* HAVE_PSI_INTERFACE */
+extern PSI_stage_info stage_waiting_for_table_level_lock;
+
extern mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
-extern mysql_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net;
+extern mysql_mutex_t THR_LOCK_lock, THR_LOCK_net;
extern mysql_mutex_t THR_LOCK_charset;
#include <mysql/psi/mysql_file.h>
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index a7cbfa07db2..60e01974320 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2000, 2011, Oracle and/or its affiliates
- Copyright (c) 2012, Monty Program Ab
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2012, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -88,6 +87,7 @@ be any number of TL_WRITE_CONCURRENT_INSERT locks aktive at the same time.
#include "mysys_priv.h"
#include "thr_lock.h"
+#include "mysql/psi/mysql_table.h"
#include <m_string.h>
#include <errno.h>
@@ -504,7 +504,7 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
mysql_cond_t *cond= &thread_var->suspend;
struct timespec wait_timeout;
enum enum_thr_lock_result result= THR_LOCK_ABORTED;
- const char *old_proc_info;
+ PSI_stage_info old_stage;
my_bool use_wait_callbacks= FALSE;
DBUG_ENTER("wait_for_lock");
@@ -544,7 +544,8 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
thread_var->current_cond= cond;
data->cond= cond;
- old_proc_info= proc_info_hook(NULL, "Waiting for table level lock",
+ proc_info_hook(NULL, &stage_waiting_for_table_level_lock,
+ &old_stage,
__func__, __FILE__, __LINE__);
/*
@@ -640,7 +641,7 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
thread_var->current_cond= 0;
mysql_mutex_unlock(&thread_var->mutex);
- proc_info_hook(NULL, old_proc_info, __func__, __FILE__, __LINE__);
+ proc_info_hook(NULL, &old_stage, NULL, __func__, __FILE__, __LINE__);
DBUG_RETURN(result);
}
@@ -653,12 +654,17 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
enum enum_thr_lock_result result= THR_LOCK_SUCCESS;
struct st_lock_list *wait_queue;
enum thr_lock_type lock_type= data->type;
+ MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
DBUG_ENTER("thr_lock");
data->next=0;
data->cond=0; /* safety */
data->owner= owner; /* Must be reset ! */
data->priority&= ~THR_LOCK_LATE_PRIV;
+
+ MYSQL_START_TABLE_LOCK_WAIT(locker, &state, data->m_psi,
+ PSI_TABLE_LOCK, lock_type);
+
mysql_mutex_lock(&lock->mutex);
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d",
(long) data, data->owner->thread_id,
@@ -888,9 +894,12 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
wait_queue= &lock->write_wait;
}
/* Can't get lock yet; Wait for it */
- DBUG_RETURN(wait_for_lock(wait_queue, data, 0, lock_wait_timeout));
+ result= wait_for_lock(wait_queue, data, 0, lock_wait_timeout);
+ MYSQL_END_TABLE_LOCK_WAIT(locker);
+ DBUG_RETURN(result);
end:
mysql_mutex_unlock(&lock->mutex);
+ MYSQL_END_TABLE_LOCK_WAIT(locker);
DBUG_RETURN(result);
}