#At file:///home/malff/BZR-TREE/mysql-6.0-perf/
2694 Marc Alff 2008-10-10
Basic PSI instrumentation
added:
include/mysql/mysql_mutex.h
include/mysql/psi.h
include/mysql/psi_abi_v1.h
include/mysql/psi_abi_v1.h.pp
include/mysql/psi_abi_v2.h
include/mysql/psi_abi_v2.h.pp
storage/perfschema/
storage/perfschema/Makefile.am
storage/perfschema/ha_perfschema.cc
storage/perfschema/ha_perfschema.h
storage/perfschema/plug.in
storage/perfschema/pse_metadata.cc
storage/perfschema/pse_metadata.h
storage/perfschema/psm.cc
storage/perfschema/psm.h
storage/perfschema/psm_server.cc
storage/perfschema/psm_server.h
storage/perfschema/unittest/
storage/perfschema/unittest/Makefile.am
modified:
Makefile.am
configure.in
include/heap.h
include/keycache.h
include/maria.h
include/my_bitmap.h
include/my_no_pthread.h
include/my_pthread.h
include/my_sys.h
include/myisam.h
include/myisammrg.h
include/thr_lock.h
include/wqueue.h
mysys/charset.c
mysys/mf_iocache.c
mysys/mf_iocache2.c
mysys/mf_keycache.c
mysys/mf_tempdir.c
mysys/my_bitmap.c
mysys/my_fopen.c
mysys/my_gethostbyname.c
mysys/my_getsystime.c
mysys/my_lib.c
mysys/my_lockmem.c
mysys/my_net.c
mysys/my_open.c
mysys/my_pread.c
mysys/my_pthread.c
mysys/my_safehash.c
mysys/my_safehash.h
mysys/my_seek.c
mysys/my_static.c
mysys/my_thr_init.c
mysys/my_uuid.c
mysys/my_wincond.c
mysys/my_winthread.c
mysys/mysys_priv.h
mysys/safemalloc.c
mysys/thr_alarm.c
mysys/thr_lock.c
mysys/thr_rwlock.c
mysys/wqueue.c
sql/backup/backup_kernel.h
sql/backup/be_thread.cc
sql/backup/be_thread.h
sql/backup/kernel.cc
sql/ddl_blocker.cc
sql/ddl_blocker.h
sql/debug_sync.cc
sql/des_key_file.cc
sql/event_queue.cc
sql/event_queue.h
sql/event_scheduler.cc
sql/event_scheduler.h
sql/events.cc
sql/events.h
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.h
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_binlog.h
sql/ha_ndbcluster_connection.cc
sql/ha_partition.cc
sql/ha_partition.h
sql/handler.cc
sql/hash_filo.h
sql/hostname.cc
sql/item_func.cc
sql/item_strfunc.cc
sql/lock.cc
sql/log.cc
sql/log.h
sql/log_event.cc
sql/log_event.h
sql/mdl.cc
sql/mdl.h
sql/mysql_priv.h
sql/mysqld.cc
sql/net_serv.cc
sql/repl_failsafe.cc
sql/repl_failsafe.h
sql/rpl_mi.cc
sql/rpl_mi.h
sql/rpl_rli.cc
sql/rpl_rli.h
sql/scheduler.cc
sql/set_var.cc
sql/set_var.h
sql/si_objects.cc
sql/slave.cc
sql/slave.h
sql/sp_cache.cc
sql/sp_head.cc
sql/sql_acl.cc
sql/sql_audit.cc
sql/sql_base.cc
sql/sql_cache.cc
sql/sql_cache.h
sql/sql_class.cc
sql/sql_class.h
sql/sql_connect.cc
sql/sql_db.cc
sql/sql_delete.cc
sql/sql_handler.cc
sql/sql_insert.cc
sql/sql_manager.cc
sql/sql_map.cc
sql/sql_parse.cc
sql/sql_partition.cc
sql/sql_plugin.cc
sql/sql_rename.cc
sql/sql_repl.cc
sql/sql_servers.cc
sql/sql_show.cc
sql/sql_table.cc
sql/sql_test.cc
sql/sql_trigger.cc
sql/sql_udf.cc
sql/sql_view.cc
sql/table.cc
sql/table.h
sql/tztime.cc
sql/udf_example.c
storage/federated/ha_federated.cc
storage/federated/ha_federated.h
storage/maria/ha_maria.cc
storage/maria/lockman.c
storage/maria/lockman.h
storage/maria/ma_bitmap.c
storage/maria/ma_blockrec.c
storage/maria/ma_check.c
storage/maria/ma_checkpoint.c
storage/maria/ma_close.c
storage/maria/ma_create.c
storage/maria/ma_dynrec.c
storage/maria/ma_extra.c
storage/maria/ma_info.c
storage/maria/ma_init.c
storage/maria/ma_key_recover.c
storage/maria/ma_keycache.c
storage/maria/ma_locking.c
storage/maria/ma_loghandler.c
storage/maria/ma_open.c
storage/maria/ma_page.c
storage/maria/ma_pagecache.h
storage/maria/ma_panic.c
storage/maria/ma_range.c
storage/maria/ma_recovery.c
storage/maria/ma_rkey.c
storage/maria/ma_rnext.c
storage/maria/ma_rnext_same.c
storage/maria/ma_rprev.c
storage/maria/ma_rsame.c
storage/maria/ma_sort.c
storage/maria/ma_state.c
storage/maria/ma_static.c
storage/maria/ma_write.c
storage/maria/maria_def.h
storage/maria/tablockman.c
storage/maria/tablockman.h
storage/maria/trnman.c
storage/maria/trnman_public.h
storage/myisam/ha_myisam.cc
storage/myisam/mi_check.c
storage/myisam/mi_close.c
storage/myisam/mi_create.c
storage/myisam/mi_dbug.c
storage/myisam/mi_dynrec.c
storage/myisam/mi_extra.c
storage/myisam/mi_info.c
storage/myisam/mi_keycache.c
storage/myisam/mi_locking.c
storage/myisam/mi_log.c
storage/myisam/mi_open.c
storage/myisam/mi_panic.c
storage/myisam/mi_range.c
storage/myisam/mi_rkey.c
storage/myisam/mi_rnext.c
storage/myisam/mi_rnext_same.c
storage/myisam/mi_rprev.c
storage/myisam/mi_rsame.c
storage/myisam/mi_write.c
storage/myisam/myisam_backup_engine.cc
storage/myisam/myisamdef.h
storage/myisam/sort.c
=== modified file 'Makefile.am'
--- a/Makefile.am 2008-09-11 18:36:05 +0000
+++ b/Makefile.am 2008-10-10 20:34:55 +0000
@@ -253,11 +253,12 @@ test-full-qa:
#
API_PREPROCESSOR_HEADER = $(top_srcdir)/include/mysql/plugin.h \
- $(top_srcdir)/include/mysql.h
+ $(top_srcdir)/include/mysql.h \
+ $(top_srcdir)/include/mysql/psi_abi_v1.h \
+ $(top_srcdir)/include/mysql/psi_abi_v2.h
-TEST_PREPROCESSOR_HEADER = $(top_srcdir)/include/mysql/plugin.h \
- $(top_srcdir)/sql/mysql_priv.h \
- $(top_srcdir)/include/mysql.h
+TEST_PREPROCESSOR_HEADER = $(API_PREPROCESSOR_HEADER) \
+ $(top_srcdir)/sql/mysql_priv.h
#
# Rules for checking that the abi/api has not changed.
=== modified file 'configure.in'
--- a/configure.in 2008-09-23 10:37:16 +0000
+++ b/configure.in 2008-10-10 20:34:55 +0000
@@ -1766,6 +1766,17 @@ case "$with_atomic_ops" in
*) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;
esac
+AC_ARG_WITH([performance-schema-interface],
+ AC_HELP_STRING([--with-performance-schema-interface],
+ [Compile with the performance schema interface mysql/psi.h (default is enabled)]),
+ [with_psi=$withval], [with_psi=yes])
+
+if test "$with_psi" != "no"
+then
+ AC_DEFINE([HAVE_PSI_INTERFACE], [1],
+ [Define to 1 if you want to use mysql/psi.h])
+fi
+
AC_CACHE_CHECK([whether the compiler provides atomic builtins],
[mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
int main()
=== modified file 'include/heap.h'
--- a/include/heap.h 2007-07-24 22:58:12 +0000
+++ b/include/heap.h 2008-10-10 20:34:55 +0000
@@ -148,7 +148,7 @@ typedef struct st_heap_share
char * name; /* Name of "memory-file" */
#ifdef THREAD
THR_LOCK lock;
- pthread_mutex_t intern_lock; /* Locking for use with _locking */
+ mysql_mutex_t intern_lock; /* Locking for use with _locking */
#endif
my_bool delete_on_close;
LIST open_list;
=== modified file 'include/keycache.h'
--- a/include/keycache.h 2008-07-09 07:12:43 +0000
+++ b/include/keycache.h 2008-10-10 20:34:55 +0000
@@ -77,7 +77,7 @@ typedef struct st_key_cache
uchar HUGE_PTR *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
- pthread_mutex_t cache_lock; /* to lock access to the cache structure */
+ mysql_mutex_t cache_lock; /* to lock access to the cache structure */
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
/*
Waiting for a zero resize count. Using a queue for symmetry though
=== modified file 'include/maria.h'
--- a/include/maria.h 2008-06-26 05:18:28 +0000
+++ b/include/maria.h 2008-10-10 20:34:55 +0000
@@ -346,8 +346,8 @@ typedef struct st_maria_sort_info
{
#ifdef THREAD
/* sync things */
- pthread_mutex_t mutex;
- pthread_cond_t cond;
+ mysql_mutex_t mutex;
+ mysql_cond_t cond;
#endif
MARIA_HA *info, *new_info;
HA_CHECK *param;
=== modified file 'include/my_bitmap.h'
--- a/include/my_bitmap.h 2007-12-12 10:14:59 +0000
+++ b/include/my_bitmap.h 2008-10-10 20:34:55 +0000
@@ -34,7 +34,7 @@ typedef struct st_bitmap
acquiring the mutex
*/
#ifdef THREAD
- pthread_mutex_t *mutex;
+ mysql_mutex_t *mutex;
#endif
} MY_BITMAP;
=== modified file 'include/my_no_pthread.h'
--- a/include/my_no_pthread.h 2006-12-23 19:20:40 +0000
+++ b/include/my_no_pthread.h 2008-10-10 20:34:55 +0000
@@ -47,4 +47,15 @@
#define rw_unlock(A)
#define rwlock_destroy(A)
+#define MYSQL_MUTEX_INIT(A,B,C)
+#define MYSQL_MUTEX_LOCK(A)
+#define MYSQL_MUTEX_UNLOCK(A)
+#define MYSQL_MUTEX_DESTROY(A)
+
+#define MYSQL_RWLOCK_INIT(A,B,C)
+#define MYSQL_RWLOCK_RDLOCK(A)
+#define MYSQL_RWLOCK_WRLOCK(A)
+#define MYSQL_RWLOCK_UNLOCK(A)
+#define MYSQL_RWLOCK_DESTROY(A)
+
#endif
=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h 2008-09-03 06:07:52 +0000
+++ b/include/my_pthread.h 2008-10-10 20:34:55 +0000
@@ -677,13 +677,15 @@ extern int pthread_dummy(int);
#define MY_PTHREAD_LOCK_READ 0
#define MY_PTHREAD_LOCK_WRITE 1
+#include "mysql/mysql_mutex.h"
+
struct st_my_thread_var
{
int thr_errno;
- pthread_cond_t suspend;
- pthread_mutex_t mutex;
- pthread_mutex_t * volatile current_mutex;
- pthread_cond_t * volatile current_cond;
+ mysql_cond_t suspend;
+ mysql_mutex_t mutex;
+ mysql_mutex_t * volatile current_mutex;
+ mysql_cond_t * volatile current_cond;
pthread_t pthread_self;
my_thread_id id;
int cmp_length;
@@ -735,16 +737,16 @@ extern uint thd_lib_detected;
#ifdef THREAD
#ifndef thread_safe_increment
#define thread_safe_increment(V,L) \
- (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
+ (MYSQL_MUTEX_LOCK((L)), (V)++, MYSQL_MUTEX_UNLOCK((L)))
#define thread_safe_decrement(V,L) \
- (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
+ (MYSQL_MUTEX_LOCK((L)), (V)--, MYSQL_MUTEX_UNLOCK((L)))
#endif
#ifndef thread_safe_add
#define thread_safe_add(V,C,L) \
- (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
+ (MYSQL_MUTEX_LOCK((L)), (V)+=(C), MYSQL_MUTEX_UNLOCK((L)))
#define thread_safe_sub(V,C,L) \
- (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
+ (MYSQL_MUTEX_LOCK((L)), (V)-=(C), MYSQL_MUTEX_UNLOCK((L)))
#endif
#endif
=== modified file 'include/my_sys.h'
--- a/include/my_sys.h 2008-08-24 16:12:12 +0000
+++ b/include/my_sys.h 2008-10-10 20:34:55 +0000
@@ -332,7 +332,7 @@ struct st_my_file_info
char * name;
enum file_type type;
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(__WIN__)
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
#endif
};
@@ -352,7 +352,7 @@ typedef struct st_my_tmpdir
char **list;
uint cur, max;
#ifdef THREAD
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
#endif
} MY_TMPDIR;
@@ -371,9 +371,9 @@ typedef int (*IO_CACHE_CALLBACK)(struct
#ifdef THREAD
typedef struct st_io_cache_share
{
- pthread_mutex_t mutex; /* To sync on reads into buffer. */
- pthread_cond_t cond; /* To wait for signals. */
- pthread_cond_t cond_writer; /* For a synchronized writer. */
+ mysql_mutex_t mutex; /* To sync on reads into buffer. */
+ mysql_cond_t cond; /* To wait for signals. */
+ mysql_cond_t cond_writer; /* For a synchronized writer. */
/* Offset in file corresponding to the first byte of buffer. */
my_off_t pos_in_file;
/* If a synchronized write cache is the source of the data. */
@@ -434,7 +434,7 @@ typedef struct st_io_cache /* Used when
The lock is for append buffer used in SEQ_READ_APPEND cache
need mutex copying from append buffer to read buffer.
*/
- pthread_mutex_t append_buffer_lock;
+ mysql_mutex_t append_buffer_lock;
/*
The following is used when several threads are reading the
same file in parallel. They are synchronized on disk
@@ -1032,5 +1032,11 @@ void netware_reg_user(const char *ip, co
const char *application);
#endif
+#ifdef HAVE_PSI_INTERFACE
+#include "mysql/psi.h"
+extern struct PSI_bootstrap *PSI_hook;
+extern PSI *PSI_server;
+#endif
+
C_MODE_END
#endif /* _my_sys_h */
=== modified file 'include/myisam.h'
--- a/include/myisam.h 2008-08-24 16:12:12 +0000
+++ b/include/myisam.h 2008-10-10 20:34:55 +0000
@@ -339,8 +339,8 @@ typedef struct st_sort_info
{
#ifdef THREAD
/* sync things */
- pthread_mutex_t mutex;
- pthread_cond_t cond;
+ mysql_mutex_t mutex;
+ mysql_cond_t cond;
#endif
MI_INFO *info;
HA_CHECK *param;
=== modified file 'include/myisammrg.h'
--- a/include/myisammrg.h 2008-04-25 21:45:58 +0000
+++ b/include/myisammrg.h 2008-10-10 20:34:55 +0000
@@ -74,7 +74,7 @@ typedef struct st_myrg_info
LIST open_list;
QUEUE by_key;
ulong *rec_per_key_part; /* for sql optimizing */
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
} MYRG_INFO;
=== added file 'include/mysql/mysql_mutex.h'
--- a/include/mysql/mysql_mutex.h 1970-01-01 00:00:00 +0000
+++ b/include/mysql/mysql_mutex.h 2008-10-10 20:34:55 +0000
@@ -0,0 +1,377 @@
+
+#ifndef MYSQL_MUTEX_H
+#define MYSQL_MUTEX_H
+
+#ifdef HAVE_PSI_INTERFACE
+#include "mysql/psi.h"
+extern PSI *PSI_server;
+#endif
+
+#define MYSQL_MUTEX_ASSERT_OWNER(M) safe_mutex_assert_owner(& (M)->m_mutex)
+#define MYSQL_MUTEX_ASSERT_NOT_OWNER(M) safe_mutex_assert_not_owner(&
(M)->m_mutex)
+
+#ifdef SAFE_MUTEX
+ #define MYSQL_MUTEX_INIT(M,K,A) mysql_mutex_init(M,K,A,__FILE__,__LINE__)
+ #define MYSQL_MUTEX_DESTROY(M) mysql_mutex_destroy(M,__FILE__,__LINE__)
+ #define MYSQL_MUTEX_LOCK(M) mysql_mutex_lock(M,__FILE__,__LINE__)
+ #define MYSQL_MUTEX_UNLOCK(M) mysql_mutex_unlock(M,__FILE__,__LINE__)
+#else
+ #define MYSQL_MUTEX_INIT(M,K,A) mysql_mutex_init(M,K,A)
+ #define MYSQL_MUTEX_DESTROY(M) mysql_mutex_destroy(M)
+ #define MYSQL_MUTEX_LOCK(M) mysql_mutex_lock(M)
+ #define MYSQL_MUTEX_UNLOCK(M) mysql_mutex_unlock(M)
+#endif
+
+#define MYSQL_RWLOCK_INIT(M,K,A) mysql_rwlock_init(M,K,A)
+#define MYSQL_RWLOCK_DESTROY(M) mysql_rwlock_destroy(M)
+#define MYSQL_RWLOCK_RDLOCK(M) mysql_rwlock_rdlock(M)
+#define MYSQL_RWLOCK_WRLOCK(M) mysql_rwlock_wrlock(M)
+#define MYSQL_RWLOCK_TRYRDLOCK(M) mysql_rwlock_tryrdlock(M)
+#define MYSQL_RWLOCK_TRYWRLOCK(M) mysql_rwlock_trywrlock(M)
+#define MYSQL_RWLOCK_UNLOCK(M) mysql_rwlock_unlock(M)
+
+#define MYSQL_COND_INIT(C,K,A) mysql_cond_init(C,K,A)
+#define MYSQL_COND_DESTROY(C) mysql_cond_destroy(C)
+#define MYSQL_COND_WAIT(C,M) mysql_cond_wait(C,M)
+#define MYSQL_COND_TIMEDWAIT(C,M,W) mysql_cond_timedwait(C,M,W)
+#define MYSQL_COND_SIGNAL(C) mysql_cond_signal(C)
+#define MYSQL_COND_BROADCAST(C) mysql_cond_broadcast(C)
+
+/*
+ Note: there are several orthogonal dimensions here.
+ - HAVE_PSI_INTERFACE, flag controlling the performance schema
+ instrumentation,
+
+ - SAFE_MUTEX, flag controlling internal debugging tools
+*/
+
+struct s_mysql_mutex
+{
+ pthread_mutex_t m_mutex;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_mutex *m_psi;
+#endif
+};
+typedef struct s_mysql_mutex mysql_mutex_t;
+
+static inline int mysql_mutex_init(
+ mysql_mutex_t *that,
+#ifdef HAVE_PSI_INTERFACE
+ PSI_mutex_key key,
+#endif
+ const pthread_mutexattr_t *attr
+#ifdef SAFE_MUTEX
+ , const char* file, int line
+#endif
+ )
+{
+#ifdef HAVE_PSI_INTERFACE
+ that->m_psi= PSI_server ? PSI_server->init_mutex(key, & that->m_mutex) :
NULL;
+#endif
+#ifdef SAFE_MUTEX
+ return safe_mutex_init(& that->m_mutex, attr, file, line, "FIXME");
+#else
+ return pthread_mutex_init(& that->m_mutex, attr);
+#endif
+}
+
+static inline int mysql_mutex_destroy(
+ mysql_mutex_t *that
+#ifdef SAFE_MUTEX
+ , const char* file, int line
+#endif
+ )
+{
+#ifdef HAVE_PSI_INTERFACE
+ if (PSI_server && that->m_psi)
+ PSI_server->destroy_mutex(that->m_psi, & that->m_mutex);
+#endif
+#ifdef SAFE_MUTEX
+ return safe_mutex_destroy(& that->m_mutex, file, line);
+#else
+ return pthread_mutex_destroy(& that->m_mutex);
+#endif
+}
+
+static inline int mysql_mutex_lock(
+ mysql_mutex_t *that
+#ifdef SAFE_MUTEX
+ , const char* file, int line
+#endif
+ )
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_wait(locker, that->m_psi, 1);
+#endif
+#ifdef SAFE_MUTEX
+ result= safe_mutex_lock(& that->m_mutex, FALSE, file, line);
+#else
+ result= pthread_mutex_lock(& that->m_mutex);
+#endif
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_wait(locker, that->m_psi, 1, result);
+#endif
+ return result;
+}
+
+static inline int mysql_mutex_unlock(
+ mysql_mutex_t *that
+#ifdef SAFE_MUTEX
+ , const char* file, int line
+#endif
+ )
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ PSI_server->unlock_mutex(thread, that->m_psi);
+#endif
+#ifdef SAFE_MUTEX
+ result= safe_mutex_unlock(& that->m_mutex, file, line);
+#else
+ result= pthread_mutex_unlock(& that->m_mutex);
+#endif
+ return result;
+}
+
+struct s_mysql_rwlock
+{
+ rw_lock_t m_rwlock;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_rwlock *m_psi;
+#endif
+};
+typedef struct s_mysql_rwlock mysql_rwlock_t;
+
+static inline int mysql_rwlock_init(
+ mysql_rwlock_t *that,
+#ifdef HAVE_PSI_INTERFACE
+ PSI_rwlock_key key,
+#endif
+ const pthread_rwlockattr_t *attr)
+{
+#ifdef HAVE_PSI_INTERFACE
+ that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, & that->m_rwlock)
: NULL);
+#endif
+ return my_rwlock_init(& that->m_rwlock, attr);
+}
+
+static inline int mysql_rwlock_destroy(
+ mysql_rwlock_t *that)
+{
+#ifdef HAVE_PSI_INTERFACE
+ if (PSI_server)
+ PSI_server->destroy_rwlock(that->m_psi, & that->m_rwlock);
+#endif
+ return rwlock_destroy(& that->m_rwlock);
+}
+
+static inline int mysql_rwlock_rdlock(
+ mysql_rwlock_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_rdwait(locker, that->m_psi, 1);
+#endif
+ result= rw_rdlock(& that->m_rwlock);
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_rdwait(locker, that->m_psi, 1, result);
+#endif
+ return result;
+}
+
+static inline int mysql_rwlock_wrlock(
+ mysql_rwlock_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_wrwait(locker, that->m_psi, 1);
+#endif
+ result= rw_rdlock(& that->m_rwlock);
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_wrwait(locker, that->m_psi, 1, result);
+#endif
+ return result;
+}
+
+static inline int mysql_rwlock_tryrdlock(
+ mysql_rwlock_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_rdwait(locker, that->m_psi, 0);
+#endif
+ result= rw_rdlock(& that->m_rwlock);
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_rdwait(locker, that->m_psi, 0, result);
+#endif
+ return result;
+}
+
+static inline int mysql_rwlock_trywrlock(
+ mysql_rwlock_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_wrwait(locker, that->m_psi, 0);
+#endif
+ result= rw_rdlock(& that->m_rwlock);
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_wrwait(locker, that->m_psi, 0, result);
+#endif
+ return result;
+}
+
+static inline int mysql_rwlock_unlock(
+ mysql_rwlock_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ PSI_server->unlock_rwlock(thread, that->m_psi);
+#endif
+ result= rw_unlock(& that->m_rwlock);
+ return result;
+}
+
+struct s_mysql_cond
+{
+ pthread_cond_t m_cond;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_cond *m_psi;
+#endif
+};
+typedef struct s_mysql_cond mysql_cond_t;
+
+static inline int mysql_cond_init(
+ mysql_cond_t *that,
+#ifdef HAVE_PSI_INTERFACE
+ PSI_cond_key key,
+#endif
+ const pthread_condattr_t *attr
+ )
+{
+#ifdef HAVE_PSI_INTERFACE
+ that->m_psi= (PSI_server ? PSI_server->init_cond(key, & that->m_cond) :
NULL);
+#endif
+ return pthread_cond_init(& that->m_cond, attr);
+}
+
+static inline int mysql_cond_destroy(
+ mysql_cond_t *that)
+{
+#ifdef HAVE_PSI_INTERFACE
+ if (PSI_server)
+ PSI_server->destroy_cond(that->m_psi, & that->m_cond);
+#endif
+ return pthread_cond_destroy(& that->m_cond);
+}
+
+static inline int mysql_cond_wait(
+ mysql_cond_t *that,
+ mysql_mutex_t *mutex)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_condwait(locker, that->m_psi, 1);
+#endif
+ result= pthread_cond_wait(& that->m_cond, & mutex->m_mutex);
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_condwait(locker, that->m_psi, 1, result);
+#endif
+ return result;
+}
+
+static inline int mysql_cond_timedwait(
+ mysql_cond_t *that,
+ mysql_mutex_t *mutex,
+ struct timespec *abstime)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_locker *locker= NULL;
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ if ((locker= PSI_server->get_locker(thread)))
+ PSI_server->start_condwait(locker, that->m_psi, 0);
+#endif
+ result= pthread_cond_timedwait(& that->m_cond, & mutex->m_mutex,
abstime);
+#ifdef HAVE_PSI_INTERFACE
+ if (locker)
+ PSI_server->end_condwait(locker, that->m_psi, 0, result);
+#endif
+ return result;
+}
+
+static inline int mysql_cond_signal(
+ mysql_cond_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ PSI_server->signal_cond(thread, that->m_psi);
+#endif
+ result= pthread_cond_signal(& that->m_cond);
+ return result;
+}
+
+static inline int mysql_cond_broadcast(
+ mysql_cond_t *that)
+{
+ int result;
+#ifdef HAVE_PSI_INTERFACE
+ struct PSI_thread *thread;
+ if (PSI_server && that->m_psi)
+ if ((thread= PSI_server->get_thread()))
+ PSI_server->broadcast_cond(thread, that->m_psi);
+#endif
+ result= pthread_cond_broadcast(& that->m_cond);
+ return result;
+}
+
+#endif
+
=== added file 'include/mysql/psi.h'
--- a/include/mysql/psi.h 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi.h 2008-10-10 20:34:55 +0000
@@ -0,0 +1,100 @@
+
+#ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
+#define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
+
+#define PSI_VERSION_1 1
+#define PSI_VERSION_2 2
+#define PSI_CURRENT_VERSION 1
+
+#ifndef USE_PSI_2
+#ifndef USE_PSI_1
+#define USE_PSI_1
+#endif
+#endif
+
+struct PSI_bootstrap
+{
+ void* (*get_PSI)(int version);
+};
+
+/* Opaque structure */
+struct PSI_mutex;
+struct PSI_rwlock;
+struct PSI_cond;
+struct PSI_thread;
+struct PSI_locker;
+
+/* Opaque key */
+typedef int PSI_mutex_key;
+typedef int PSI_rwlock_key;
+typedef int PSI_cond_key;
+
+#ifdef USE_PSI_1
+#define HAVE_PSI_1
+#endif
+
+#ifdef HAVE_PSI_1
+/**
+ Performance Schema Application Binary Interface, version 1.
+*/
+struct PSI_v1
+{
+ PSI_mutex_key (*register_mutex)(const char* name, int global);
+ PSI_rwlock_key (*register_rwlock)(const char* name, int global);
+ PSI_cond_key (*register_cond)(const char* name, int global);
+
+ struct PSI_mutex* (*init_mutex)(PSI_mutex_key key, void *identity);
+ void (*destroy_mutex)(struct PSI_mutex* mutex, void *identity);
+ struct PSI_rwlock* (*init_rwlock)(PSI_rwlock_key key, void *identity);
+ void (*destroy_rwlock)(struct PSI_rwlock* rwlock, void *identity);
+ struct PSI_cond* (*init_cond)(PSI_cond_key key, void *identity);
+ void (*destroy_cond)(struct PSI_cond* cond, void *identity);
+
+ struct PSI_thread* (*new_thread)();
+ struct PSI_thread* (*get_thread)();
+ void (*delete_thread)(struct PSI_thread *thread);
+
+ struct PSI_locker* (*get_locker)(struct PSI_thread *thread);
+
+ void (*unlock_mutex)(struct PSI_thread *thread, struct PSI_mutex* mutex);
+ void (*unlock_rwlock)(struct PSI_thread *thread, struct PSI_rwlock* rwlock);
+ void (*signal_cond)(struct PSI_thread *thread, struct PSI_cond* cond);
+ void (*broadcast_cond)(struct PSI_thread *thread, struct PSI_cond* cond);
+
+ void (*start_wait)(struct PSI_locker* locker, struct PSI_mutex* mutex, int must);
+ void (*end_wait)(struct PSI_locker* locker, struct PSI_mutex* mutex, int must, int rc);
+ void (*start_rdwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must);
+ void (*end_rdwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must, int
rc);
+ void (*start_wrwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must);
+ void (*end_wrwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must, int
rc);
+ void (*start_condwait)(struct PSI_locker* locker, struct PSI_cond* cond, int must);
+ void (*end_condwait)(struct PSI_locker* locker, struct PSI_cond* cond, int must, int
rc);
+};
+#endif
+
+#ifdef USE_PSI_2
+#define HAVE_PSI_2
+#endif
+
+#ifdef HAVE_PSI_2
+/**
+ Performance Schema Application Binary Interface, version 2.
+*/
+struct PSI_v2
+{
+ int later;
+ /* ... extended interface ... */
+};
+#endif
+
+/* Export the required version */
+#ifdef USE_PSI_1
+typedef struct PSI_v1 PSI;
+#endif
+
+#ifdef USE_PSI_2
+typedef struct PSI_v2 PSI;
+#endif
+
+#endif
+
=== added file 'include/mysql/psi_abi_v1.h'
--- a/include/mysql/psi_abi_v1.h 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi_abi_v1.h 2008-10-10 20:34:55 +0000
@@ -0,0 +1,4 @@
+
+#define USE_PSI_1
+#include "mysql/psi.h"
+
=== added file 'include/mysql/psi_abi_v1.h.pp'
--- a/include/mysql/psi_abi_v1.h.pp 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi_abi_v1.h.pp 2008-10-10 20:34:55 +0000
@@ -0,0 +1,42 @@
+#include "mysql/psi.h"
+struct PSI_bootstrap
+{
+ void* (*get_PSI)(int version);
+};
+struct PSI_mutex;
+struct PSI_rwlock;
+struct PSI_cond;
+struct PSI_thread;
+struct PSI_locker;
+typedef int PSI_mutex_key;
+typedef int PSI_rwlock_key;
+typedef int PSI_cond_key;
+struct PSI_v1
+{
+ PSI_mutex_key (*register_mutex)(const char* name, int global);
+ PSI_rwlock_key (*register_rwlock)(const char* name, int global);
+ PSI_cond_key (*register_cond)(const char* name, int global);
+ struct PSI_mutex* (*init_mutex)(PSI_mutex_key key, void *identity);
+ void (*destroy_mutex)(struct PSI_mutex* mutex, void *identity);
+ struct PSI_rwlock* (*init_rwlock)(PSI_rwlock_key key, void *identity);
+ void (*destroy_rwlock)(struct PSI_rwlock* rwlock, void *identity);
+ struct PSI_cond* (*init_cond)(PSI_cond_key key, void *identity);
+ void (*destroy_cond)(struct PSI_cond* cond, void *identity);
+ struct PSI_thread* (*new_thread)();
+ struct PSI_thread* (*get_thread)();
+ void (*delete_thread)(struct PSI_thread *thread);
+ struct PSI_locker* (*get_locker)(struct PSI_thread *thread);
+ void (*unlock_mutex)(struct PSI_thread *thread, struct PSI_mutex* mutex);
+ void (*unlock_rwlock)(struct PSI_thread *thread, struct PSI_rwlock* rwlock);
+ void (*signal_cond)(struct PSI_thread *thread, struct PSI_cond* cond);
+ void (*broadcast_cond)(struct PSI_thread *thread, struct PSI_cond* cond);
+ void (*start_wait)(struct PSI_locker* locker, struct PSI_mutex* mutex, int must);
+ void (*end_wait)(struct PSI_locker* locker, struct PSI_mutex* mutex, int must, int rc);
+ void (*start_rdwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must);
+ void (*end_rdwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must, int
rc);
+ void (*start_wrwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must);
+ void (*end_wrwait)(struct PSI_locker* locker, struct PSI_rwlock *rwlock, int must, int
rc);
+ void (*start_condwait)(struct PSI_locker* locker, struct PSI_cond* cond, int must);
+ void (*end_condwait)(struct PSI_locker* locker, struct PSI_cond* cond, int must, int
rc);
+};
+typedef struct PSI_v1 PSI;
=== added file 'include/mysql/psi_abi_v2.h'
--- a/include/mysql/psi_abi_v2.h 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi_abi_v2.h 2008-10-10 20:34:55 +0000
@@ -0,0 +1,4 @@
+
+#define USE_PSI_2
+#include "mysql/psi.h"
+
=== added file 'include/mysql/psi_abi_v2.h.pp'
--- a/include/mysql/psi_abi_v2.h.pp 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi_abi_v2.h.pp 2008-10-10 20:34:55 +0000
@@ -0,0 +1,18 @@
+#include "mysql/psi.h"
+struct PSI_bootstrap
+{
+ void* (*get_PSI)(int version);
+};
+struct PSI_mutex;
+struct PSI_rwlock;
+struct PSI_cond;
+struct PSI_thread;
+struct PSI_locker;
+typedef int PSI_mutex_key;
+typedef int PSI_rwlock_key;
+typedef int PSI_cond_key;
+struct PSI_v2
+{
+ int later;
+};
+typedef struct PSI_v2 PSI;
=== modified file 'include/thr_lock.h'
--- a/include/thr_lock.h 2008-06-28 11:00:59 +0000
+++ b/include/thr_lock.h 2008-10-10 20:34:55 +0000
@@ -115,7 +115,7 @@ struct st_lock_list {
typedef struct st_thr_lock {
LIST list;
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
struct st_lock_list read_wait;
struct st_lock_list read;
struct st_lock_list write_wait;
@@ -133,7 +133,7 @@ typedef struct st_thr_lock {
extern LIST *thr_lock_thread_list;
-extern pthread_mutex_t THR_LOCK_lock;
+extern mysql_mutex_t THR_LOCK_lock;
my_bool init_thr_lock(void); /* Must be called once/thread */
#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)
=== modified file 'include/wqueue.h'
--- a/include/wqueue.h 2008-02-22 20:32:34 +0000
+++ b/include/wqueue.h 2008-10-10 20:34:55 +0000
@@ -18,7 +18,7 @@ void wqueue_unlink_from_queue(WQUEUE *wq
void wqueue_add_to_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
void wqueue_add_and_wait(WQUEUE *wqueue,
struct st_my_thread_var *thread,
- pthread_mutex_t *lock);
+ mysql_mutex_t *lock);
void wqueue_release_queue(WQUEUE *wqueue);
void wqueue_release_one_locktype_from_queue(WQUEUE *wqueue);
=== modified file 'mysys/charset.c'
--- a/mysys/charset.c 2008-07-24 11:33:35 +0000
+++ b/mysys/charset.c 2008-10-10 20:34:55 +0000
@@ -444,7 +444,7 @@ static my_bool init_available_charsets(m
To make things thread safe we are not allowing other threads to interfere
while we may changing the cs_info_table
*/
- pthread_mutex_lock(&THR_LOCK_charset);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_charset);
if (!charset_initialized)
{
bzero(&all_charsets,sizeof(all_charsets));
@@ -467,7 +467,7 @@ static my_bool init_available_charsets(m
error= my_read_charset_file(fname,myflags);
charset_initialized=1;
}
- pthread_mutex_unlock(&THR_LOCK_charset);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_charset);
}
return error;
}
@@ -524,7 +524,7 @@ static CHARSET_INFO *get_internal_charse
To make things thread safe we are not allowing other threads to interfere
while we may changing the cs_info_table
*/
- pthread_mutex_lock(&THR_LOCK_charset);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_charset);
if ((cs= all_charsets[cs_number]))
{
if (!(cs->state & MY_CS_COMPILED) && !(cs->state &
MY_CS_LOADED))
@@ -542,7 +542,7 @@ static CHARSET_INFO *get_internal_charse
else
cs->state|= MY_CS_READY;
}
- pthread_mutex_unlock(&THR_LOCK_charset);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_charset);
return cs;
}
=== modified file 'mysys/mf_iocache.c'
--- a/mysys/mf_iocache.c 2008-07-09 07:12:43 +0000
+++ b/mysys/mf_iocache.c 2008-10-10 20:34:55 +0000
@@ -58,9 +58,9 @@ static void my_aiowait(my_aio_result *re
#ifdef THREAD
#define lock_append_buffer(info) \
- pthread_mutex_lock(&(info)->append_buffer_lock)
+ MYSQL_MUTEX_LOCK(&(info)->append_buffer_lock)
#define unlock_append_buffer(info) \
- pthread_mutex_unlock(&(info)->append_buffer_lock)
+ MYSQL_MUTEX_UNLOCK(&(info)->append_buffer_lock)
#else
#define lock_append_buffer(info)
#define unlock_append_buffer(info)
@@ -691,7 +691,7 @@ void remove_io_thread(IO_CACHE *cache)
if (cache == cshare->source_cache)
flush_io_cache(cache);
- pthread_mutex_lock(&cshare->mutex);
+ MYSQL_MUTEX_LOCK(&cshare->mutex);
DBUG_PRINT("io_cache_share", ("%s: %p",
(cache == cshare->source_cache) ?
"writer" : "reader", cache));
@@ -714,18 +714,18 @@ void remove_io_thread(IO_CACHE *cache)
if (!--cshare->running_threads)
{
DBUG_PRINT("io_cache_share", ("the last running thread leaves, wake all"));
- pthread_cond_signal(&cshare->cond_writer);
- pthread_cond_broadcast(&cshare->cond);
+ MYSQL_COND_SIGNAL(&cshare->cond_writer);
+ MYSQL_COND_BROADCAST(&cshare->cond);
}
- pthread_mutex_unlock(&cshare->mutex);
+ MYSQL_MUTEX_UNLOCK(&cshare->mutex);
if (!total)
{
DBUG_PRINT("io_cache_share", ("last thread removed, destroy share"));
- pthread_cond_destroy (&cshare->cond_writer);
- pthread_cond_destroy (&cshare->cond);
- pthread_mutex_destroy(&cshare->mutex);
+ MYSQL_COND_DESTROY (&cshare->cond_writer);
+ MYSQL_COND_DESTROY (&cshare->cond);
+ MYSQL_MUTEX_DESTROY(&cshare->mutex);
}
DBUG_VOID_RETURN;
@@ -766,7 +766,7 @@ static int lock_io_cache(IO_CACHE *cache
DBUG_ENTER("lock_io_cache");
/* Enter the lock. */
- pthread_mutex_lock(&cshare->mutex);
+ MYSQL_MUTEX_LOCK(&cshare->mutex);
cshare->running_threads--;
DBUG_PRINT("io_cache_share", ("%s: %p pos: %lu running: %u",
(cache == cshare->source_cache) ?
@@ -783,7 +783,7 @@ static int lock_io_cache(IO_CACHE *cache
while (cshare->running_threads)
{
DBUG_PRINT("io_cache_share", ("writer waits in lock"));
- pthread_cond_wait(&cshare->cond_writer, &cshare->mutex);
+ MYSQL_COND_WAIT(&cshare->cond_writer, &cshare->mutex);
}
DBUG_PRINT("io_cache_share", ("writer awoke, going to copy"));
@@ -795,7 +795,7 @@ static int lock_io_cache(IO_CACHE *cache
if (!cshare->running_threads)
{
DBUG_PRINT("io_cache_share", ("waking writer"));
- pthread_cond_signal(&cshare->cond_writer);
+ MYSQL_COND_SIGNAL(&cshare->cond_writer);
}
/*
@@ -807,7 +807,7 @@ static int lock_io_cache(IO_CACHE *cache
cshare->source_cache)
{
DBUG_PRINT("io_cache_share", ("reader waits in lock"));
- pthread_cond_wait(&cshare->cond, &cshare->mutex);
+ MYSQL_COND_WAIT(&cshare->cond, &cshare->mutex);
}
/*
@@ -849,7 +849,7 @@ static int lock_io_cache(IO_CACHE *cache
cshare->running_threads)
{
DBUG_PRINT("io_cache_share", ("reader waits in lock"));
- pthread_cond_wait(&cshare->cond, &cshare->mutex);
+ MYSQL_COND_WAIT(&cshare->cond, &cshare->mutex);
}
/* If the block is not yet read, continue with a locked cache and read. */
@@ -871,7 +871,7 @@ static int lock_io_cache(IO_CACHE *cache
Leave the lock. Do not call unlock_io_cache() later. The thread that
filled the buffer did this and marked all threads as running.
*/
- pthread_mutex_unlock(&cshare->mutex);
+ MYSQL_MUTEX_UNLOCK(&cshare->mutex);
DBUG_RETURN(0);
}
@@ -914,8 +914,8 @@ static void unlock_io_cache(IO_CACHE *ca
cshare->total_threads));
cshare->running_threads= cshare->total_threads;
- pthread_cond_broadcast(&cshare->cond);
- pthread_mutex_unlock(&cshare->mutex);
+ MYSQL_COND_BROADCAST(&cshare->cond);
+ MYSQL_MUTEX_UNLOCK(&cshare->mutex);
DBUG_VOID_RETURN;
}
@@ -1865,7 +1865,7 @@ int end_io_cache(IO_CACHE *info)
/* Destroy allocated mutex */
info->type= TYPE_NOT_SET;
#ifdef THREAD
- pthread_mutex_destroy(&info->append_buffer_lock);
+ MYSQL_MUTEX_DESTROY(&info->append_buffer_lock);
#endif
}
#ifdef THREAD
=== modified file 'mysys/mf_iocache2.c'
--- a/mysys/mf_iocache2.c 2008-05-29 15:44:11 +0000
+++ b/mysys/mf_iocache2.c 2008-10-10 20:34:55 +0000
@@ -82,7 +82,7 @@ my_off_t my_b_append_tell(IO_CACHE* info
answer to the question.
*/
#ifdef THREAD
- pthread_mutex_lock(&info->append_buffer_lock);
+ MYSQL_MUTEX_LOCK(&info->append_buffer_lock);
#endif
#ifndef DBUG_OFF
/*
@@ -104,7 +104,7 @@ my_off_t my_b_append_tell(IO_CACHE* info
#endif
res = info->end_of_file + (info->write_pos-info->append_read_pos);
#ifdef THREAD
- pthread_mutex_unlock(&info->append_buffer_lock);
+ MYSQL_MUTEX_UNLOCK(&info->append_buffer_lock);
#endif
return res;
}
=== modified file 'mysys/mf_keycache.c'
--- a/mysys/mf_keycache.c 2008-08-20 10:29:58 +0000
+++ b/mysys/mf_keycache.c 2008-10-10 20:34:55 +0000
@@ -59,13 +59,13 @@
time only.
Before starting to wait on its condition variable with
- pthread_cond_wait(), the thread enters itself to a specific wait queue
+ MYSQL_COND_WAIT(), the thread enters itself to a specific wait queue
with link_into_queue() (double linked with '*next' + '**prev') or
wait_on_queue() (single linked with '*next').
Another thread, when releasing a resource, looks up the waiting thread
in the related wait queue. It sends a signal with
- pthread_cond_signal() to the waiting thread.
+ MYSQL_COND_SIGNAL() to the waiting thread.
NOTE: Depending on the particular wait situation, either the sending
thread removes the waiting thread from the wait queue with
@@ -127,8 +127,8 @@
accessing it;
to set this number equal to <N> add
#define MAX_THREADS <N>
- - to substitute calls of pthread_cond_wait for calls of
- pthread_cond_timedwait (wait with timeout set up);
+ - to substitute calls of MYSQL_COND_WAIT for calls of
+ MYSQL_COND_TIMEDWAIT (wait with timeout set up);
this setting should be used only when you want to trap a deadlock
situation, which theoretically should not happen;
to set timeout equal to <T> seconds add
@@ -159,7 +159,7 @@
#define COND_FOR_SAVED 1
#define COND_FOR_READERS 2
-typedef pthread_cond_t KEYCACHE_CONDVAR;
+typedef mysql_cond_t KEYCACHE_CONDVAR;
/* descriptor of the page in the key cache block buffer */
struct st_keycache_page
@@ -227,7 +227,7 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cac
static int flush_all_key_blocks(KEY_CACHE *keycache);
#ifdef THREAD
static void wait_on_queue(KEYCACHE_WQUEUE *wqueue,
- pthread_mutex_t *mutex);
+ mysql_mutex_t *mutex);
static void release_whole_queue(KEYCACHE_WQUEUE *wqueue);
#else
#define wait_on_queue(wqueue, mutex) do {} while (0)
@@ -314,20 +314,20 @@ static long keycache_thread_id;
((uint) (((char*)(h)-(char *) keycache->hash_link_root)/sizeof(HASH_LINK)))
#if (defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)) || defined(KEYCACHE_DEBUG)
-static int keycache_pthread_cond_wait(pthread_cond_t *cond,
- pthread_mutex_t *mutex);
+static int keycache_MYSQL_COND_WAIT(mysql_cond_t *cond,
+ mysql_mutex_t *mutex);
#else
-#define keycache_pthread_cond_wait pthread_cond_wait
+#define keycache_MYSQL_COND_WAIT MYSQL_COND_WAIT
#endif
#if defined(KEYCACHE_DEBUG)
-static int keycache_pthread_mutex_lock(pthread_mutex_t *mutex);
-static void keycache_pthread_mutex_unlock(pthread_mutex_t *mutex);
-static int keycache_pthread_cond_signal(pthread_cond_t *cond);
+static int keycache_MYSQL_MUTEX_LOCK(mysql_mutex_t *mutex);
+static void keycache_MYSQL_MUTEX_UNLOCK(mysql_mutex_t *mutex);
+static int keycache_MYSQL_COND_SIGNAL(mysql_cond_t *cond);
#else
-#define keycache_pthread_mutex_lock pthread_mutex_lock
-#define keycache_pthread_mutex_unlock pthread_mutex_unlock
-#define keycache_pthread_cond_signal pthread_cond_signal
+#define keycache_MYSQL_MUTEX_LOCK MYSQL_MUTEX_LOCK
+#define keycache_MYSQL_MUTEX_UNLOCK MYSQL_MUTEX_UNLOCK
+#define keycache_MYSQL_COND_SIGNAL MYSQL_COND_SIGNAL
#endif /* defined(KEYCACHE_DEBUG) */
#if !defined(DBUG_OFF)
@@ -581,7 +581,7 @@ int resize_key_cache(KEY_CACHE *keycache
DBUG_RETURN(keycache->disk_blocks);
}
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
#ifdef THREAD
/*
@@ -664,7 +664,7 @@ finish:
/* Signal waiting threads. */
release_whole_queue(&keycache->resize_queue);
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
DBUG_RETURN(blocks);
}
@@ -711,14 +711,14 @@ void change_key_cache_param(KEY_CACHE *k
{
DBUG_ENTER("change_key_cache_param");
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
if (division_limit)
keycache->min_warm_blocks= (keycache->disk_blocks *
division_limit / 100 + 1);
if (age_threshold)
keycache->age_threshold= (keycache->disk_blocks *
age_threshold / 100);
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
DBUG_VOID_RETURN;
}
@@ -767,7 +767,7 @@ void end_key_cache(KEY_CACHE *keycache,
if (cleanup)
{
- pthread_mutex_destroy(&keycache->cache_lock);
+ MYSQL_MUTEX_DESTROY(&keycache->cache_lock);
keycache->key_cache_inited= keycache->can_be_used= 0;
keycache->post_write= NULL;
KEYCACHE_DEBUG_CLOSE;
@@ -907,7 +907,7 @@ static void unlink_from_queue(KEYCACHE_W
*/
static void wait_on_queue(KEYCACHE_WQUEUE *wqueue,
- pthread_mutex_t *mutex)
+ mysql_mutex_t *mutex)
{
struct st_my_thread_var *last;
struct st_my_thread_var *thread= my_thread_var;
@@ -931,7 +931,7 @@ static void wait_on_queue(KEYCACHE_WQUEU
do
{
KEYCACHE_DBUG_PRINT("wait", ("suspend thread %ld", thread->id));
- keycache_pthread_cond_wait(&thread->suspend, mutex);
+ keycache_MYSQL_COND_WAIT(&thread->suspend, mutex);
}
while (thread->next);
}
@@ -970,7 +970,7 @@ static void release_whole_queue(KEYCACHE
KEYCACHE_DBUG_PRINT("release_whole_queue: signal",
("thread %ld", thread->id));
/* Signal the thread. */
- keycache_pthread_cond_signal(&thread->suspend);
+ keycache_MYSQL_COND_SIGNAL(&thread->suspend);
/* Take thread from queue. */
next=thread->next;
thread->next= NULL;
@@ -1175,7 +1175,7 @@ static void link_block(KEY_CACHE *keycac
if ((HASH_LINK *) thread->opt_info == hash_link)
{
KEYCACHE_DBUG_PRINT("link_block: signal", ("thread %ld", thread->id));
- keycache_pthread_cond_signal(&thread->suspend);
+ keycache_MYSQL_COND_SIGNAL(&thread->suspend);
unlink_from_queue(&keycache->waiting_for_block, thread);
block->requests++;
}
@@ -1437,7 +1437,7 @@ static void remove_reader(BLOCK_LINK *bl
DBUG_ASSERT(block->hash_link->requests);
#ifdef THREAD
if (! --block->hash_link->requests && block->condvar)
- keycache_pthread_cond_signal(block->condvar);
+ keycache_MYSQL_COND_SIGNAL(block->condvar);
#else
--block->hash_link->requests;
#endif
@@ -1472,7 +1472,7 @@ static void wait_for_readers(KEY_CACHE *
/* There must be no other waiter. We have no queue here. */
DBUG_ASSERT(!block->condvar);
block->condvar= &thread->suspend;
- keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock);
+ keycache_MYSQL_COND_WAIT(&thread->suspend, &keycache->cache_lock);
block->condvar= NULL;
}
#else
@@ -1533,7 +1533,7 @@ static void unlink_hash(KEY_CACHE *keyca
if (page->file == hash_link->file && page->filepos ==
hash_link->diskpos)
{
KEYCACHE_DBUG_PRINT("unlink_hash: signal", ("thread %ld", thread->id));
- keycache_pthread_cond_signal(&thread->suspend);
+ keycache_MYSQL_COND_SIGNAL(&thread->suspend);
unlink_from_queue(&keycache->waiting_for_hash_link, thread);
}
}
@@ -1621,7 +1621,7 @@ restart:
link_into_queue(&keycache->waiting_for_hash_link, thread);
KEYCACHE_DBUG_PRINT("get_hash_link: wait",
("suspend thread %ld", thread->id));
- keycache_pthread_cond_wait(&thread->suspend,
+ keycache_MYSQL_COND_WAIT(&thread->suspend,
&keycache->cache_lock);
thread->opt_info= NULL;
#else
@@ -1790,7 +1790,7 @@ restart:
{
KEYCACHE_DBUG_PRINT("find_key_block: wait",
("suspend thread %ld", thread->id));
- keycache_pthread_cond_wait(&thread->suspend,
+ keycache_MYSQL_COND_WAIT(&thread->suspend,
&keycache->cache_lock);
} while (thread->next);
thread->opt_info= NULL;
@@ -2136,7 +2136,7 @@ restart:
{
KEYCACHE_DBUG_PRINT("find_key_block: wait",
("suspend thread %ld", thread->id));
- keycache_pthread_cond_wait(&thread->suspend,
+ keycache_MYSQL_COND_WAIT(&thread->suspend,
&keycache->cache_lock);
}
while (thread->next);
@@ -2232,7 +2232,7 @@ restart:
BLOCK_CHANGED | BLOCK_IN_USE));
DBUG_ASSERT(block->hash_link);
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
/*
The call is thread safe because only the current
thread might change the block->hash_link value
@@ -2245,7 +2245,7 @@ restart:
MYF(MY_NABP | MY_WAIT_IF_FULL),
keycache->post_write,
block->post_write_arg);
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/* Block status must not have changed. */
DBUG_ASSERT((block->status & ~BLOCK_IN_EVICTION) ==
@@ -2462,14 +2462,14 @@ static void read_block(KEY_CACHE *keycac
keycache->global_cache_read++;
/* Page is not in buffer yet, is to be read from disk */
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
/*
Here other threads may step in and register as secondary readers.
They will register in block->wqueue[COND_FOR_REQUESTED].
*/
got_length= my_pread(block->hash_link->file, block->buffer,
read_length, block->hash_link->diskpos, MYF(0));
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/*
The block can now have been marked for free (in case of
FLUSH_RELEASE). Otherwise the state must be unchanged.
@@ -2576,7 +2576,7 @@ uchar *key_cache_read(KEY_CACHE *keycach
disabled cache. We always increment and decrement
'cnt_for_resize_op' so that a resizer can wait for pending I/O.
*/
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/*
Cache resizing has two phases: Flushing and re-initializing. In
the flush phase read requests are allowed to bypass the cache for
@@ -2628,10 +2628,10 @@ uchar *key_cache_read(KEY_CACHE *keycach
Read directly from file.
*/
keycache->global_cache_read++;
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
error= (my_pread(file, (uchar*) buff, read_length,
filepos + offset, MYF(MY_NABP)) != 0);
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
goto next_block;
}
if (!(block->status & BLOCK_ERROR))
@@ -2673,7 +2673,7 @@ uchar *key_cache_read(KEY_CACHE *keycach
{
DBUG_ASSERT(block->status & (BLOCK_READ | BLOCK_IN_USE));
#if !defined(SERIALIZED_READ_FROM_CACHE)
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
#endif
/* Copy data from the cache buffer */
@@ -2683,7 +2683,7 @@ uchar *key_cache_read(KEY_CACHE *keycach
memcpy(buff, block->buffer+offset, (size_t) read_length);
#if !defined(SERIALIZED_READ_FROM_CACHE)
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
DBUG_ASSERT(block->status & (BLOCK_READ | BLOCK_IN_USE));
#endif
}
@@ -2724,17 +2724,17 @@ no_key_cache:
keycache->global_cache_read++;
if (locked_and_incremented)
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
if (my_pread(file, (uchar*) buff, length, filepos, MYF(MY_NABP)))
error= 1;
if (locked_and_incremented)
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
end:
if (locked_and_incremented)
{
dec_counter_for_resize_op(keycache);
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
}
DBUG_RETURN(error ? (uchar*) 0 : start);
}
@@ -2784,7 +2784,7 @@ int key_cache_insert(KEY_CACHE *keycache
disabled cache. We always increment and decrement
'cnt_for_resize_op' so that a resizer can wait for pending I/O.
*/
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/*
We do not load index data into a disabled cache nor into an
ongoing resize.
@@ -2880,7 +2880,7 @@ int key_cache_insert(KEY_CACHE *keycache
(block->status & BLOCK_READ));
#if !defined(SERIALIZED_READ_FROM_CACHE)
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
/*
Here other threads may step in and register as secondary readers.
They will register in block->wqueue[COND_FOR_REQUESTED].
@@ -2894,7 +2894,7 @@ int key_cache_insert(KEY_CACHE *keycache
memcpy(block->buffer+offset, buff, (size_t) read_length);
#if !defined(SERIALIZED_READ_FROM_CACHE)
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
DBUG_ASSERT(block->status & BLOCK_IN_USE);
DBUG_ASSERT((page_st == PAGE_TO_BE_READ) ||
(block->status & BLOCK_READ));
@@ -2967,7 +2967,7 @@ int key_cache_insert(KEY_CACHE *keycache
no_key_cache:
if (locked_and_incremented)
dec_counter_for_resize_op(keycache);
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
}
DBUG_RETURN(error);
}
@@ -3053,7 +3053,7 @@ int key_cache_write(KEY_CACHE *keycache,
disabled cache. We always increment and decrement
'cnt_for_resize_op' so that a resizer can wait for pending I/O.
*/
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/*
Cache resizing has two phases: Flushing and re-initializing. In
the flush phase write requests can modify dirty blocks that are
@@ -3103,13 +3103,13 @@ int key_cache_write(KEY_CACHE *keycache,
{
/* Used in the server. */
keycache->global_cache_write++;
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
if (key_cache_pwrite(file, (uchar*) buff, read_length,
filepos + offset,
MYF(MY_NABP | MY_WAIT_IF_FULL),
keycache->post_write, post_write_arg))
error=1;
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
}
goto next_block;
}
@@ -3201,7 +3201,7 @@ int key_cache_write(KEY_CACHE *keycache,
{
block->post_write_arg= post_write_arg;
#if !defined(SERIALIZED_READ_FROM_CACHE)
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
#endif
if (!(read_length & 511))
bmove512(block->buffer+offset, buff, read_length);
@@ -3209,7 +3209,7 @@ int key_cache_write(KEY_CACHE *keycache,
memcpy(block->buffer+offset, buff, (size_t) read_length);
#if !defined(SERIALIZED_READ_FROM_CACHE)
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
#endif
}
@@ -3274,20 +3274,20 @@ no_key_cache:
keycache->global_cache_w_requests++;
keycache->global_cache_write++;
if (locked_and_incremented)
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
if (key_cache_pwrite(file, (uchar*) buff, length, filepos,
MYF(MY_NABP | MY_WAIT_IF_FULL),
keycache->post_write, post_write_arg))
error=1;
if (locked_and_incremented)
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
}
end:
if (locked_and_incremented)
{
dec_counter_for_resize_op(keycache);
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
}
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
DBUG_EXECUTE("exec",
@@ -3469,14 +3469,14 @@ static int flush_cached_blocks(KEY_CACHE
uint count= (uint) (end-cache);
/* Don't lock the cache during the flush */
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
/*
As all blocks referred in 'cache' are marked by BLOCK_IN_FLUSH
we are guarunteed no thread will change them
*/
my_qsort((uchar*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/*
Note: Do not break the loop. We have registered a request on every
block in 'cache'. These must be unregistered by free_block() or
@@ -3502,14 +3502,14 @@ static int flush_cached_blocks(KEY_CACHE
DBUG_ASSERT((block->status & ~BLOCK_IN_EVICTION) ==
(BLOCK_READ | BLOCK_IN_FLUSH | BLOCK_CHANGED | BLOCK_IN_USE));
block->status|= BLOCK_IN_FLUSHWRITE;
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
error= key_cache_pwrite(file,
block->buffer+block->offset,
block->length - block->offset,
block->hash_link->diskpos+ block->offset,
MYF(MY_NABP | MY_WAIT_IF_FULL),
keycache->post_write, block->post_write_arg);
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
keycache->global_cache_write++;
if (error)
{
@@ -4051,7 +4051,7 @@ int flush_key_blocks(KEY_CACHE *keycache
if (!keycache->key_cache_inited)
DBUG_RETURN(0);
- keycache_pthread_mutex_lock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_LOCK(&keycache->cache_lock);
/* While waiting for lock, keycache could have been ended. */
if (keycache->disk_blocks > 0)
{
@@ -4059,7 +4059,7 @@ int flush_key_blocks(KEY_CACHE *keycache
res= flush_key_blocks_int(keycache, file, type);
dec_counter_for_resize_op(keycache);
}
- keycache_pthread_mutex_unlock(&keycache->cache_lock);
+ keycache_MYSQL_MUTEX_UNLOCK(&keycache->cache_lock);
DBUG_RETURN(res);
}
@@ -4106,7 +4106,7 @@ static int flush_all_key_blocks(KEY_CACH
do
{
- safe_mutex_assert_owner(&keycache->cache_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&keycache->cache_lock);
total_found= 0;
/*
@@ -4347,8 +4347,8 @@ static void keycache_dump(KEY_CACHE *key
#if defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)
-static int keycache_pthread_cond_wait(pthread_cond_t *cond,
- pthread_mutex_t *mutex)
+static int keycache_MYSQL_COND_WAIT(mysql_cond_t *cond,
+ mysql_mutex_t *mutex)
{
int rc;
struct timeval now; /* time when we started waiting */
@@ -4375,7 +4375,7 @@ static int keycache_pthread_cond_wait(pt
fprintf(keycache_debug_log, "waiting...\n");
fflush(keycache_debug_log);
#endif
- rc= pthread_cond_timedwait(cond, mutex, &timeout);
+ rc= MYSQL_COND_TIMEDWAIT(cond, mutex, &timeout);
KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
if (rc == ETIMEDOUT || rc == ETIME)
{
@@ -4396,12 +4396,12 @@ static int keycache_pthread_cond_wait(pt
}
#else
#if defined(KEYCACHE_DEBUG)
-static int keycache_pthread_cond_wait(pthread_cond_t *cond,
- pthread_mutex_t *mutex)
+static int keycache_MYSQL_COND_WAIT(mysql_cond_t *cond,
+ mysql_mutex_t *mutex)
{
int rc;
KEYCACHE_THREAD_TRACE_END("started waiting");
- rc= pthread_cond_wait(cond, mutex);
+ rc= MYSQL_COND_WAIT(cond, mutex);
KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
return rc;
}
@@ -4411,27 +4411,27 @@ static int keycache_pthread_cond_wait(pt
#if defined(KEYCACHE_DEBUG)
-static int keycache_pthread_mutex_lock(pthread_mutex_t *mutex)
+static int keycache_MYSQL_MUTEX_LOCK(mysql_mutex_t *mutex)
{
int rc;
- rc= pthread_mutex_lock(mutex);
+ rc= MYSQL_MUTEX_LOCK(mutex);
KEYCACHE_THREAD_TRACE_BEGIN("");
return rc;
}
-static void keycache_pthread_mutex_unlock(pthread_mutex_t *mutex)
+static void keycache_MYSQL_MUTEX_UNLOCK(mysql_mutex_t *mutex)
{
KEYCACHE_THREAD_TRACE_END("");
- pthread_mutex_unlock(mutex);
+ MYSQL_MUTEX_UNLOCK(mutex);
}
-static int keycache_pthread_cond_signal(pthread_cond_t *cond)
+static int keycache_MYSQL_COND_SIGNAL(mysql_cond_t *cond)
{
int rc;
KEYCACHE_THREAD_TRACE("signal");
- rc= pthread_cond_signal(cond);
+ rc= MYSQL_COND_SIGNAL(cond);
return rc;
}
=== modified file 'mysys/mf_tempdir.c'
--- a/mysys/mf_tempdir.c 2007-05-10 09:59:39 +0000
+++ b/mysys/mf_tempdir.c 2008-10-10 20:34:55 +0000
@@ -65,7 +65,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, c
err:
delete_dynamic(&tmpdir->full_list); /* Safe to free */
- pthread_mutex_destroy(&tmpdir->mutex);
+ MYSQL_MUTEX_DESTROY(&tmpdir->mutex);
DBUG_RETURN(TRUE);
}
@@ -75,10 +75,10 @@ char *my_tmpdir(MY_TMPDIR *tmpdir)
char *dir;
if (!tmpdir->max)
return tmpdir->list[0];
- pthread_mutex_lock(&tmpdir->mutex);
+ MYSQL_MUTEX_LOCK(&tmpdir->mutex);
dir=tmpdir->list[tmpdir->cur];
tmpdir->cur= (tmpdir->cur == tmpdir->max) ? 0 : tmpdir->cur+1;
- pthread_mutex_unlock(&tmpdir->mutex);
+ MYSQL_MUTEX_UNLOCK(&tmpdir->mutex);
return dir;
}
@@ -88,6 +88,6 @@ void free_tmpdir(MY_TMPDIR *tmpdir)
for (i=0; i<=tmpdir->max; i++)
my_free(tmpdir->list[i], MYF(0));
delete_dynamic(&tmpdir->full_list);
- pthread_mutex_destroy(&tmpdir->mutex);
+ MYSQL_MUTEX_DESTROY(&tmpdir->mutex);
}
=== modified file 'mysys/my_bitmap.c'
--- a/mysys/my_bitmap.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_bitmap.c 2008-10-10 20:34:55 +0000
@@ -87,7 +87,7 @@ static inline void bitmap_lock(MY_BITMAP
{
#ifdef THREAD
if (map->mutex)
- pthread_mutex_lock(map->mutex);
+ MYSQL_MUTEX_LOCK(map->mutex);
#endif
}
@@ -95,7 +95,7 @@ static inline void bitmap_unlock(MY_BITM
{
#ifdef THREAD
if (map->mutex)
- pthread_mutex_unlock(map->mutex);
+ MYSQL_MUTEX_UNLOCK(map->mutex);
#endif
}
@@ -112,7 +112,7 @@ my_bool bitmap_init(MY_BITMAP *map, my_b
if (thread_safe)
{
size_in_bytes= ALIGN_SIZE(size_in_bytes);
- extra= sizeof(pthread_mutex_t);
+ extra= sizeof(mysql_mutex_t);
}
map->mutex= 0;
#endif
@@ -121,7 +121,7 @@ my_bool bitmap_init(MY_BITMAP *map, my_b
#ifdef THREAD
if (thread_safe)
{
- map->mutex= (pthread_mutex_t *) ((char*) buf + size_in_bytes);
+ map->mutex= (mysql_mutex_t *) ((char*) buf + size_in_bytes);
pthread_mutex_init(map->mutex, MY_MUTEX_INIT_FAST);
}
#endif
@@ -148,7 +148,7 @@ void bitmap_free(MY_BITMAP *map)
{
#ifdef THREAD
if (map->mutex)
- pthread_mutex_destroy(map->mutex);
+ MYSQL_MUTEX_DESTROY(map->mutex);
#endif
my_free((char*) map->bitmap, MYF(0));
map->bitmap=0;
=== modified file 'mysys/my_fopen.c'
--- a/mysys/my_fopen.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_fopen.c 2008-10-10 20:34:55 +0000
@@ -71,18 +71,18 @@ FILE *my_fopen(const char *filename, int
thread_safe_increment(my_stream_opened,&THR_LOCK_open);
DBUG_RETURN(fd); /* safeguard */
}
- pthread_mutex_lock(&THR_LOCK_open);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_open);
if ((my_file_info[fileno(fd)].name = (char*)
my_strdup(filename,MyFlags)))
{
my_stream_opened++;
my_file_total_opened++;
my_file_info[fileno(fd)].type = STREAM_BY_FOPEN;
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
DBUG_PRINT("exit",("stream: %p", fd));
DBUG_RETURN(fd);
}
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
(void) my_fclose(fd,MyFlags);
my_errno=ENOMEM;
}
@@ -105,7 +105,7 @@ int my_fclose(FILE *fd, myf MyFlags)
DBUG_ENTER("my_fclose");
DBUG_PRINT("my",("stream: %p MyFlags: %d", fd, MyFlags));
- pthread_mutex_lock(&THR_LOCK_open);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_open);
file=fileno(fd);
if ((err = fclose(fd)) < 0)
{
@@ -121,7 +121,7 @@ int my_fclose(FILE *fd, myf MyFlags)
my_file_info[file].type = UNOPEN;
my_free(my_file_info[file].name, MYF(MY_ALLOW_ZERO_PTR));
}
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
DBUG_RETURN(err);
} /* my_fclose */
@@ -146,7 +146,7 @@ FILE *my_fdopen(File Filedes, const char
}
else
{
- pthread_mutex_lock(&THR_LOCK_open);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_open);
my_stream_opened++;
if ((uint) Filedes < (uint) my_file_limit)
{
@@ -160,7 +160,7 @@ FILE *my_fdopen(File Filedes, const char
}
my_file_info[Filedes].type = STREAM_BY_FDOPEN;
}
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
}
DBUG_PRINT("exit",("stream: %p", fd));
=== modified file 'mysys/my_gethostbyname.c'
--- a/mysys/my_gethostbyname.c 2006-12-31 00:32:21 +0000
+++ b/mysys/my_gethostbyname.c 2008-10-10 20:34:55 +0000
@@ -79,7 +79,7 @@ struct hostent *my_gethostbyname_r(const
#else /* !HAVE_GETHOSTBYNAME_R */
#ifdef THREAD
-extern pthread_mutex_t LOCK_gethostbyname_r;
+extern mysql_mutex_t LOCK_gethostbyname_r;
#endif
/*
@@ -96,7 +96,7 @@ struct hostent *my_gethostbyname_r(const
int buflen, int *h_errnop)
{
struct hostent *hp;
- pthread_mutex_lock(&LOCK_gethostbyname_r);
+ MYSQL_MUTEX_LOCK(&LOCK_gethostbyname_r);
hp= gethostbyname(name);
*h_errnop= h_errno;
return hp;
@@ -104,7 +104,7 @@ struct hostent *my_gethostbyname_r(const
void my_gethostbyname_r_free()
{
- pthread_mutex_unlock(&LOCK_gethostbyname_r);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gethostbyname_r);
}
#endif /* !HAVE_GETHOSTBYNAME_R */
=== modified file 'mysys/my_getsystime.c'
--- a/mysys/my_getsystime.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_getsystime.c 2008-10-10 20:34:55 +0000
@@ -168,7 +168,7 @@ ulonglong my_micro_time_and_time(time_t
static time_t cur_time= 0;
hrtime_t cur_gethrtime;
- pthread_mutex_lock(&THR_LOCK_time);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_time);
cur_gethrtime= gethrtime();
if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)
{
@@ -176,7 +176,7 @@ ulonglong my_micro_time_and_time(time_t
prev_gethrtime= cur_gethrtime;
}
*time_arg= cur_time;
- pthread_mutex_unlock(&THR_LOCK_time);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_time);
return cur_gethrtime/1000;
#else
ulonglong newtime;
=== modified file 'mysys/my_lib.c'
--- a/mysys/my_lib.c 2008-04-09 01:07:00 +0000
+++ b/mysys/my_lib.c 2008-10-10 20:34:55 +0000
@@ -111,7 +111,7 @@ MY_DIR *my_dir(const char *path, myf MyF
DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
#if defined(THREAD) && !defined(HAVE_READDIR_R)
- pthread_mutex_lock(&THR_LOCK_open);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_open);
#endif
dirp = opendir(directory_file_name(tmp_path,(char *) path));
@@ -174,7 +174,7 @@ MY_DIR *my_dir(const char *path, myf MyF
(void) closedir(dirp);
#if defined(THREAD) && !defined(HAVE_READDIR_R)
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
#endif
result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
result->number_off_files= dir_entries_storage->elements;
@@ -186,7 +186,7 @@ MY_DIR *my_dir(const char *path, myf MyF
error:
#if defined(THREAD) && !defined(HAVE_READDIR_R)
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
#endif
my_errno=errno;
if (dirp)
=== modified file 'mysys/my_lockmem.c'
--- a/mysys/my_lockmem.c 2008-04-09 00:56:49 +0000
+++ b/mysys/my_lockmem.c 2008-10-10 20:34:55 +0000
@@ -66,9 +66,9 @@ uchar *my_malloc_lock(uint size,myf MyFl
element->list.data=(uchar*) element;
element->page=ptr;
element->size=size;
- pthread_mutex_lock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_malloc);
mem_list=list_add(mem_list,&element->list);
- pthread_mutex_unlock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_malloc);
}
DBUG_RETURN(ptr);
}
@@ -79,7 +79,7 @@ void my_free_lock(uchar *ptr,myf Myflags
LIST *list;
struct st_mem_list *element=0;
- pthread_mutex_lock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_malloc);
for (list=mem_list ; list ; list=list->next)
{
element=(struct st_mem_list*) list->data;
@@ -90,7 +90,7 @@ void my_free_lock(uchar *ptr,myf Myflags
break;
}
}
- pthread_mutex_unlock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_malloc);
if (element)
my_free((uchar*) element,MYF(0));
free(ptr); /* Free even if not locked */
=== modified file 'mysys/my_net.c'
--- a/mysys/my_net.c 2006-12-23 19:20:40 +0000
+++ b/mysys/my_net.c 2008-10-10 20:34:55 +0000
@@ -35,8 +35,8 @@
void my_inet_ntoa(struct in_addr in, char *buf)
{
char *ptr;
- pthread_mutex_lock(&THR_LOCK_net);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_net);
ptr=inet_ntoa(in);
strmov(buf,ptr);
- pthread_mutex_unlock(&THR_LOCK_net);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_net);
}
=== modified file 'mysys/my_open.c'
--- a/mysys/my_open.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_open.c 2008-10-10 20:34:55 +0000
@@ -93,7 +93,7 @@ int my_close(File fd, myf MyFlags)
DBUG_ENTER("my_close");
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
- pthread_mutex_lock(&THR_LOCK_open);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_open);
do
{
err= close(fd);
@@ -110,12 +110,12 @@ int my_close(File fd, myf MyFlags)
{
my_free(my_file_info[fd].name, MYF(0));
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined (__WIN__)
- pthread_mutex_destroy(&my_file_info[fd].mutex);
+ MYSQL_MUTEX_DESTROY(&my_file_info[fd].mutex);
#endif
my_file_info[fd].type = UNOPEN;
}
my_file_opened--;
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
DBUG_RETURN(err);
} /* my_close */
@@ -154,7 +154,7 @@ File my_register_filename(File fd, const
}
else
{
- pthread_mutex_lock(&THR_LOCK_open);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_open);
if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags)))
{
my_file_opened++;
@@ -163,11 +163,11 @@ File my_register_filename(File fd, const
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(__WIN__)
pthread_mutex_init(&my_file_info[fd].mutex,MY_MUTEX_INIT_FAST);
#endif
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
DBUG_PRINT("exit",("fd: %d",fd));
DBUG_RETURN(fd);
}
- pthread_mutex_unlock(&THR_LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_open);
my_errno= ENOMEM;
}
(void) my_close(fd, MyFlags);
=== modified file 'mysys/my_pread.c'
--- a/mysys/my_pread.c 2008-08-25 18:23:18 +0000
+++ b/mysys/my_pread.c 2008-10-10 20:34:55 +0000
@@ -134,12 +134,12 @@ size_t my_pread(File Filedes, uchar *Buf
{
errno= 0; /* Linux, Windows don't reset this on EOF/success */
#if !defined (HAVE_PREAD) && !defined (__WIN__)
- pthread_mutex_lock(&my_file_info[Filedes].mutex);
+ MYSQL_MUTEX_LOCK(&my_file_info[Filedes].mutex);
readbytes= (uint) -1;
error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
(readbytes= read(Filedes, Buffer, Count)) != Count);
save_errno= errno;
- pthread_mutex_unlock(&my_file_info[Filedes].mutex);
+ MYSQL_MUTEX_UNLOCK(&my_file_info[Filedes].mutex);
if (error)
{
errno= save_errno;
@@ -221,10 +221,10 @@ size_t my_pwrite(int Filedes, const ucha
#if !defined (HAVE_PREAD) && !defined (__WIN__)
int error;
writenbytes= (size_t) -1;
- pthread_mutex_lock(&my_file_info[Filedes].mutex);
+ MYSQL_MUTEX_LOCK(&my_file_info[Filedes].mutex);
error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 &&
(writenbytes = write(Filedes, Buffer, Count)) == Count);
- pthread_mutex_unlock(&my_file_info[Filedes].mutex);
+ MYSQL_MUTEX_UNLOCK(&my_file_info[Filedes].mutex);
if (error)
break;
#else
=== modified file 'mysys/my_pthread.c'
--- a/mysys/my_pthread.c 2008-04-09 00:56:49 +0000
+++ b/mysys/my_pthread.c 2008-10-10 20:34:55 +0000
@@ -136,7 +136,7 @@ int my_sigwait(const sigset_t *set,int *
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
-extern pthread_mutex_t LOCK_localtime_r;
+extern mysql_mutex_t LOCK_localtime_r;
#endif
@@ -144,10 +144,10 @@ extern pthread_mutex_t LOCK_localtime_r;
struct tm *localtime_r(const time_t *clock, struct tm *res)
{
struct tm *tmp;
- pthread_mutex_lock(&LOCK_localtime_r);
+ MYSQL_MUTEX_LOCK(&LOCK_localtime_r);
tmp=localtime(clock);
*res= *tmp;
- pthread_mutex_unlock(&LOCK_localtime_r);
+ MYSQL_MUTEX_UNLOCK(&LOCK_localtime_r);
return res;
}
#endif
@@ -161,10 +161,10 @@ struct tm *localtime_r(const time_t *clo
struct tm *gmtime_r(const time_t *clock, struct tm *res)
{
struct tm *tmp;
- pthread_mutex_lock(&LOCK_localtime_r);
+ MYSQL_MUTEX_LOCK(&LOCK_localtime_r);
tmp= gmtime(clock);
*res= *tmp;
- pthread_mutex_unlock(&LOCK_localtime_r);
+ MYSQL_MUTEX_UNLOCK(&LOCK_localtime_r);
return res;
}
#endif
@@ -300,16 +300,16 @@ int sigwait(sigset_t *setp, int *sigp)
static sigset_t pending_set;
static bool inited=0;
-static pthread_cond_t COND_sigwait;
-static pthread_mutex_t LOCK_sigwait;
+static mysql_cond_t COND_sigwait;
+static mysql_mutex_t LOCK_sigwait;
void sigwait_handle_sig(int sig)
{
- pthread_mutex_lock(&LOCK_sigwait);
+ MYSQL_MUTEX_LOCK(&LOCK_sigwait);
sigaddset(&pending_set, sig);
- pthread_cond_signal(&COND_sigwait); /* inform sigwait() about signal */
- pthread_mutex_unlock(&LOCK_sigwait);
+ MYSQL_COND_SIGNAL(&COND_sigwait); /* inform sigwait() about signal */
+ MYSQL_MUTEX_UNLOCK(&LOCK_sigwait);
}
void *sigwait_thread(void *set_arg)
@@ -369,7 +369,7 @@ int sigwait(sigset_t *setp, int *sigp)
pthread_attr_destroy(&thr_attr);
}
- pthread_mutex_lock(&LOCK_sigwait);
+ MYSQL_MUTEX_LOCK(&LOCK_sigwait);
for (;;)
{
ulong *ptr= (ulong*) &pending_set;
@@ -388,11 +388,11 @@ int sigwait(sigset_t *setp, int *sigp)
}
*sigp=found;
sigdelset(&pending_set,found);
- pthread_mutex_unlock(&LOCK_sigwait);
+ MYSQL_MUTEX_UNLOCK(&LOCK_sigwait);
return 0;
}
}
- pthread_cond_wait(&COND_sigwait,&LOCK_sigwait);
+ MYSQL_COND_WAIT(&COND_sigwait,&LOCK_sigwait);
}
return 0;
}
@@ -408,17 +408,17 @@ int sigwait(sigset_t *setp, int *sigp)
/* Undefined wrappers set my_pthread.h so that we call os functions */
#undef pthread_mutex_init
-#undef pthread_mutex_lock
-#undef pthread_mutex_unlock
-#undef pthread_mutex_destroy
+#undef MYSQL_MUTEX_LOCK
+#undef MYSQL_MUTEX_UNLOCK
+#undef MYSQL_MUTEX_DESTROY
#undef pthread_mutex_wait
-#undef pthread_mutex_timedwait
-#undef pthread_mutex_trylock
-#undef pthread_mutex_t
+#undef mysql_mutex_timedwait
+#undef mysql_mutex_trylock
+#undef mysql_mutex_t
#undef pthread_cond_init
-#undef pthread_cond_wait
-#undef pthread_cond_timedwait
-#undef pthread_cond_t
+#undef MYSQL_COND_WAIT
+#undef MYSQL_COND_TIMEDWAIT
+#undef mysql_cond_t
#undef pthread_attr_getstacksize
/*****************************************************************************
@@ -429,7 +429,7 @@ int sigwait(sigset_t *setp, int *sigp)
#include <netdb.h>
-int my_pthread_mutex_init(pthread_mutex_t *mp, const pthread_mutexattr_t *attr)
+int my_pthread_mutex_init(mysql_mutex_t *mp, const pthread_mutexattr_t *attr)
{
int error;
if (!attr)
@@ -439,7 +439,7 @@ int my_pthread_mutex_init(pthread_mutex_
return error;
}
-int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr)
+int my_pthread_cond_init(mysql_cond_t *mp, const pthread_condattr_t *attr)
{
int error;
if (!attr)
@@ -464,10 +464,10 @@ int my_pthread_cond_init(pthread_cond_t
#if defined(HPUX10) || defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT)
-int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+int my_MYSQL_COND_TIMEDWAIT(mysql_cond_t *cond, mysql_mutex_t *mutex,
struct timespec *abstime)
{
- int error=pthread_cond_timedwait(cond, mutex, abstime);
+ int error=MYSQL_COND_TIMEDWAIT(cond, mutex, abstime);
if (error == -1) /* Safety if the lib is fixed */
{
if (!(error=errno))
@@ -492,8 +492,8 @@ void my_pthread_attr_getstacksize(pthrea
#ifdef HAVE_POSIX1003_4a_MUTEX
/*
In HP-UX-10.20 and other old Posix 1003.4a Draft 4 implementations
- pthread_mutex_trylock returns 1 on success, not 0 like
- pthread_mutex_lock
+ mysql_mutex_trylock returns 1 on success, not 0 like
+ MYSQL_MUTEX_LOCK
From the HP-UX-10.20 man page:
RETURN VALUES
@@ -509,18 +509,18 @@ void my_pthread_attr_getstacksize(pthrea
*/
/*
- Convert pthread_mutex_trylock to return values according to latest POSIX
+ Convert mysql_mutex_trylock to return values according to latest POSIX
RETURN VALUES
0 If we are able successfully lock the mutex.
EBUSY Mutex was locked by another thread
- # Other error number returned by pthread_mutex_trylock()
+ # Other error number returned by mysql_mutex_trylock()
(Not likely)
*/
-int my_pthread_mutex_trylock(pthread_mutex_t *mutex)
+int my_mysql_mutex_trylock(mysql_mutex_t *mutex)
{
- int error= pthread_mutex_trylock(mutex);
+ int error= mysql_mutex_trylock(mutex);
if (error == 1)
return 0; /* Got lock on mutex */
if (error == 0) /* Someon else is locking mutex */
=== modified file 'mysys/my_safehash.c'
--- a/mysys/my_safehash.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_safehash.c 2008-10-10 20:34:55 +0000
@@ -134,7 +134,7 @@ void safe_hash_free(SAFE_HASH *hash)
if (hash->default_value)
{
hash_free(&hash->hash);
- rwlock_destroy(&hash->mutex);
+ MYSQL_RWLOCK_DESTROY(&hash->mutex);
hash->default_value=0;
}
}
@@ -159,9 +159,9 @@ uchar *safe_hash_search(SAFE_HASH *hash,
{
uchar *result;
DBUG_ENTER("safe_hash_search");
- rw_rdlock(&hash->mutex);
+ MYSQL_RWLOCK_RDLOCK(&hash->mutex);
result= hash_search(&hash->hash, key, length);
- rw_unlock(&hash->mutex);
+ MYSQL_RWLOCK_UNLOCK(&hash->mutex);
if (!result)
result= def;
else
@@ -199,7 +199,7 @@ my_bool safe_hash_set(SAFE_HASH *hash, c
DBUG_ENTER("safe_hash_set");
DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, (long) data));
- rw_wrlock(&hash->mutex);
+ MYSQL_RWLOCK_WRLOCK(&hash->mutex);
entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length);
if (data == hash->default_value)
@@ -249,7 +249,7 @@ my_bool safe_hash_set(SAFE_HASH *hash, c
}
end:
- rw_unlock(&hash->mutex);
+ MYSQL_RWLOCK_UNLOCK(&hash->mutex);
DBUG_RETURN(error);
}
@@ -274,7 +274,7 @@ void safe_hash_change(SAFE_HASH *hash, u
SAFE_HASH_ENTRY *entry, *next;
DBUG_ENTER("safe_hash_change");
- rw_wrlock(&hash->mutex);
+ MYSQL_RWLOCK_WRLOCK(&hash->mutex);
for (entry= hash->root ; entry ; entry= next)
{
@@ -292,6 +292,6 @@ void safe_hash_change(SAFE_HASH *hash, u
}
}
- rw_unlock(&hash->mutex);
+ MYSQL_RWLOCK_UNLOCK(&hash->mutex);
DBUG_VOID_RETURN;
}
=== modified file 'mysys/my_safehash.h'
--- a/mysys/my_safehash.h 2007-07-02 17:45:15 +0000
+++ b/mysys/my_safehash.h 2008-10-10 20:34:55 +0000
@@ -40,7 +40,7 @@ typedef struct st_safe_hash_entry
typedef struct st_safe_hash_with_default
{
#ifdef THREAD
- rw_lock_t mutex;
+ mysql_rwlock_t mutex;
#endif
HASH hash;
uchar *default_value;
=== modified file 'mysys/my_seek.c'
--- a/mysys/my_seek.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_seek.c 2008-10-10 20:34:55 +0000
@@ -59,9 +59,9 @@ my_off_t my_seek(File fd, my_off_t pos,
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(__WIN__)
if (MyFlags & MY_THREADSAFE)
{
- pthread_mutex_lock(&my_file_info[fd].mutex);
+ MYSQL_MUTEX_LOCK(&my_file_info[fd].mutex);
newpos= lseek(fd, pos, whence);
- pthread_mutex_unlock(&my_file_info[fd].mutex);
+ MYSQL_MUTEX_UNLOCK(&my_file_info[fd].mutex);
}
else
#endif
=== modified file 'mysys/my_static.c'
--- a/mysys/my_static.c 2008-08-19 14:10:19 +0000
+++ b/mysys/my_static.c 2008-10-10 20:34:55 +0000
@@ -103,3 +103,9 @@ my_bool NEAR my_disable_async_io=0;
my_bool NEAR my_disable_flush_key_blocks=0;
my_bool NEAR my_disable_symlinks=0;
my_bool NEAR mysys_uses_curses=0;
+
+#ifdef HAVE_PSI_INTERFACE
+struct PSI_bootstrap *PSI_hook= NULL;
+PSI *PSI_server= NULL;
+#endif
+
=== modified file 'mysys/my_thr_init.c'
--- a/mysys/my_thr_init.c 2008-07-09 07:12:43 +0000
+++ b/mysys/my_thr_init.c 2008-10-10 20:34:55 +0000
@@ -29,21 +29,21 @@ pthread_key(struct st_my_thread_var*, TH
#else
pthread_key(struct st_my_thread_var, THR_KEY_mysys);
#endif /* USE_TLS */
-pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,
+mysql_mutex_t THR_LOCK_malloc,THR_LOCK_open,
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_heap, THR_LOCK_net,
THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time;
/** For insert/delete in the list of MyISAM open tables */
-pthread_mutex_t THR_LOCK_myisam;
+mysql_mutex_t THR_LOCK_myisam;
/** For writing to the MyISAM logs */
-pthread_mutex_t THR_LOCK_myisam_log;
-pthread_cond_t THR_COND_threads;
+mysql_mutex_t THR_LOCK_myisam_log;
+mysql_cond_t THR_COND_threads;
uint THR_thread_count= 0;
uint my_thread_end_wait_time= 5;
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
-pthread_mutex_t LOCK_localtime_r;
+mysql_mutex_t LOCK_localtime_r;
#endif
#ifndef HAVE_GETHOSTBYNAME_R
-pthread_mutex_t LOCK_gethostbyname_r;
+mysql_mutex_t LOCK_gethostbyname_r;
#endif
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_t my_fast_mutexattr;
@@ -179,10 +179,10 @@ void my_thread_global_end(void)
my_bool all_threads_killed= 1;
set_timespec(abstime, my_thread_end_wait_time);
- pthread_mutex_lock(&THR_LOCK_threads);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_threads);
while (THR_thread_count > 0)
{
- int error= pthread_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads,
+ int error= MYSQL_COND_TIMEDWAIT(&THR_COND_threads, &THR_LOCK_threads,
&abstime);
if (error == ETIMEDOUT || error == ETIME)
{
@@ -201,7 +201,7 @@ void my_thread_global_end(void)
break;
}
}
- pthread_mutex_unlock(&THR_LOCK_threads);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_threads);
pthread_key_delete(THR_KEY_mysys);
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
@@ -210,26 +210,26 @@ void my_thread_global_end(void)
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
pthread_mutexattr_destroy(&my_errorcheck_mutexattr);
#endif
- pthread_mutex_destroy(&THR_LOCK_malloc);
- pthread_mutex_destroy(&THR_LOCK_open);
- pthread_mutex_destroy(&THR_LOCK_lock);
- pthread_mutex_destroy(&THR_LOCK_isam);
- pthread_mutex_destroy(&THR_LOCK_myisam);
- pthread_mutex_destroy(&THR_LOCK_myisam_log);
- pthread_mutex_destroy(&THR_LOCK_heap);
- pthread_mutex_destroy(&THR_LOCK_net);
- pthread_mutex_destroy(&THR_LOCK_time);
- pthread_mutex_destroy(&THR_LOCK_charset);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_malloc);
+ 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_log);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_heap);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_net);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_time);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_charset);
if (all_threads_killed)
{
- pthread_mutex_destroy(&THR_LOCK_threads);
- pthread_cond_destroy(&THR_COND_threads);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_threads);
+ MYSQL_COND_DESTROY(&THR_COND_threads);
}
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
- pthread_mutex_destroy(&LOCK_localtime_r);
+ MYSQL_MUTEX_DESTROY(&LOCK_localtime_r);
#endif
#ifndef HAVE_GETHOSTBYNAME_R
- pthread_mutex_destroy(&LOCK_gethostbyname_r);
+ MYSQL_MUTEX_DESTROY(&LOCK_gethostbyname_r);
#endif
}
@@ -297,10 +297,10 @@ my_bool my_thread_init(void)
pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
pthread_cond_init(&tmp->suspend, NULL);
- pthread_mutex_lock(&THR_LOCK_threads);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_threads);
tmp->id= ++thread_id;
++THR_thread_count;
- pthread_mutex_unlock(&THR_LOCK_threads);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_threads);
tmp->init= 1;
#ifndef DBUG_OFF
/* Generate unique name for thread */
@@ -350,9 +350,9 @@ void my_thread_end(void)
#endif
#if !defined(__bsdi__) && !defined(__OpenBSD__)
/* bsdi and openbsd 3.5 dumps core here */
- pthread_cond_destroy(&tmp->suspend);
+ MYSQL_COND_DESTROY(&tmp->suspend);
#endif
- pthread_mutex_destroy(&tmp->mutex);
+ MYSQL_MUTEX_DESTROY(&tmp->mutex);
#if !defined(__WIN__) || defined(USE_TLS)
free(tmp);
#else
@@ -368,11 +368,11 @@ void my_thread_end(void)
my_thread_end and thus freed all memory they have allocated in
my_thread_init() and DBUG_xxxx
*/
- pthread_mutex_lock(&THR_LOCK_threads);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_threads);
DBUG_ASSERT(THR_thread_count != 0);
if (--THR_thread_count == 0)
- pthread_cond_signal(&THR_COND_threads);
- pthread_mutex_unlock(&THR_LOCK_threads);
+ MYSQL_COND_SIGNAL(&THR_COND_threads);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_threads);
}
else
{
=== modified file 'mysys/my_uuid.c'
--- a/mysys/my_uuid.c 2008-07-23 11:28:20 +0000
+++ b/mysys/my_uuid.c 2008-10-10 20:34:55 +0000
@@ -50,7 +50,7 @@ static ulonglong uuid_time= 0;
static uchar uuid_suffix[2+6]; /* clock_seq and node */
#ifdef THREAD
-static pthread_mutex_t LOCK_uuid_generator;
+static mysql_mutex_t LOCK_uuid_generator;
#endif
/*
@@ -133,7 +133,7 @@ void my_uuid(uchar *to)
DBUG_ASSERT(my_uuid_inited);
- pthread_mutex_lock(&LOCK_uuid_generator);
+ MYSQL_MUTEX_LOCK(&LOCK_uuid_generator);
tv= my_getsystime() + UUID_TIME_OFFSET + nanoseq;
if (likely(tv > uuid_time))
@@ -194,7 +194,7 @@ void my_uuid(uchar *to)
}
uuid_time=tv;
- pthread_mutex_unlock(&LOCK_uuid_generator);
+ MYSQL_MUTEX_UNLOCK(&LOCK_uuid_generator);
time_low= (uint32) (tv & 0xFFFFFFFF);
time_mid= (uint16) ((tv >> 32) & 0xFFFF);
@@ -238,6 +238,6 @@ void my_uuid_end()
if (my_uuid_inited)
{
my_uuid_inited= 0;
- pthread_mutex_destroy(&LOCK_uuid_generator);
+ MYSQL_MUTEX_DESTROY(&LOCK_uuid_generator);
}
}
=== modified file 'mysys/my_wincond.c'
--- a/mysys/my_wincond.c 2007-05-10 09:59:39 +0000
+++ b/mysys/my_wincond.c 2008-10-10 20:34:55 +0000
@@ -25,7 +25,7 @@
#include <process.h>
#include <sys/timeb.h>
-int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
+int pthread_cond_init(mysql_cond_t *cond, const pthread_condattr_t *attr)
{
cond->waiting= 0;
InitializeCriticalSection(&cond->lock_waiting);
@@ -54,7 +54,7 @@ int pthread_cond_init(pthread_cond_t *co
return 0;
}
-int pthread_cond_destroy(pthread_cond_t *cond)
+int MYSQL_COND_DESTROY(mysql_cond_t *cond)
{
DeleteCriticalSection(&cond->lock_waiting);
@@ -66,13 +66,13 @@ int pthread_cond_destroy(pthread_cond_t
}
-int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+int MYSQL_COND_WAIT(mysql_cond_t *cond, mysql_mutex_t *mutex)
{
- return pthread_cond_timedwait(cond,mutex,NULL);
+ return MYSQL_COND_TIMEDWAIT(cond,mutex,NULL);
}
-int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+int MYSQL_COND_TIMEDWAIT(mysql_cond_t *cond, mysql_mutex_t *mutex,
struct timespec *abstime)
{
int result;
@@ -144,7 +144,7 @@ int pthread_cond_timedwait(pthread_cond_
return result == WAIT_TIMEOUT ? ETIMEDOUT : 0;
}
-int pthread_cond_signal(pthread_cond_t *cond)
+int MYSQL_COND_SIGNAL(mysql_cond_t *cond)
{
EnterCriticalSection(&cond->lock_waiting);
@@ -157,7 +157,7 @@ int pthread_cond_signal(pthread_cond_t *
}
-int pthread_cond_broadcast(pthread_cond_t *cond)
+int MYSQL_COND_BROADCAST(mysql_cond_t *cond)
{
EnterCriticalSection(&cond->lock_waiting);
/*
=== modified file 'mysys/my_winthread.c'
--- a/mysys/my_winthread.c 2008-05-29 15:44:11 +0000
+++ b/mysys/my_winthread.c 2008-10-10 20:34:55 +0000
@@ -26,7 +26,7 @@
#undef getpid
#include <process.h>
-static pthread_mutex_t THR_LOCK_thread;
+static mysql_mutex_t THR_LOCK_thread;
struct pthread_map
{
@@ -42,13 +42,13 @@ void win_pthread_init(void)
/**
- Adapter to @c pthread_mutex_trylock()
+ Adapter to @c mysql_mutex_trylock()
@retval 0 Mutex was acquired
@retval EBUSY Mutex was already locked by a thread
*/
int
-win_pthread_mutex_trylock(pthread_mutex_t *mutex)
+win_mysql_mutex_trylock(mysql_mutex_t *mutex)
{
if (TryEnterCriticalSection(mutex))
{
@@ -79,9 +79,9 @@ pthread_handler_t pthread_start(void *pa
void *func_param=((struct pthread_map *) param)->param;
void *result;
my_thread_init(); /* Will always succeed in windows */
- pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */
+ MYSQL_MUTEX_LOCK(&THR_LOCK_thread); /* Wait for beginthread to return */
win_pthread_self=((struct pthread_map *) param)->pthreadself;
- pthread_mutex_unlock(&THR_LOCK_thread);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_thread);
free((char*) param); /* Free param from create */
result= (void*) (*func)(func_param);
my_thread_end();
@@ -110,7 +110,7 @@ int pthread_create(pthread_t *thread_id,
}
if (StackSize == 0)
StackSize= PTHREAD_STACK_MIN;
- pthread_mutex_lock(&THR_LOCK_thread);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_thread);
#ifdef __BORLANDC__
hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start,
StackSize, (void*) map);
@@ -120,7 +120,7 @@ int pthread_create(pthread_t *thread_id,
#endif
DBUG_PRINT("info", ("hThread=%lu",(long) hThread));
*thread_id=map->pthreadself=hThread;
- pthread_mutex_unlock(&THR_LOCK_thread);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_thread);
if (hThread == (HANDLE) -1)
{
=== modified file 'mysys/mysys_priv.h'
--- a/mysys/mysys_priv.h 2007-07-30 08:33:50 +0000
+++ b/mysys/mysys_priv.h 2008-10-10 20:34:55 +0000
@@ -26,9 +26,9 @@
#ifdef THREAD
#include <my_pthread.h>
-extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
-extern pthread_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net;
-extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time;
+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_charset, THR_LOCK_time;
#else
#include <my_no_pthread.h>
#endif
=== modified file 'mysys/safemalloc.c'
--- a/mysys/safemalloc.c 2008-08-21 05:20:27 +0000
+++ b/mysys/safemalloc.c 2008-10-10 20:34:55 +0000
@@ -178,7 +178,7 @@ void *_mymalloc(size_t size, const char
irem->prev= NULL;
/* Add this remember structure to the linked list */
- pthread_mutex_lock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_malloc);
if ((irem->next= sf_malloc_root))
sf_malloc_root->prev= irem;
sf_malloc_root= irem;
@@ -188,7 +188,7 @@ void *_mymalloc(size_t size, const char
if (sf_malloc_cur_memory > sf_malloc_max_memory)
sf_malloc_max_memory= sf_malloc_cur_memory;
sf_malloc_count++;
- pthread_mutex_unlock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_malloc);
/* Set the memory to the aribtrary wierd value */
if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
@@ -291,7 +291,7 @@ void _myfree(void *ptr, const char *file
}
/* Remove this structure from the linked list */
- pthread_mutex_lock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_malloc);
if (irem->prev)
irem->prev->next= irem->next;
else
@@ -302,7 +302,7 @@ void _myfree(void *ptr, const char *file
/* Handle the statistics */
sf_malloc_cur_memory-= irem->datasize;
sf_malloc_count--;
- pthread_mutex_unlock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_malloc);
#ifndef HAVE_purify
/* Mark this data as free'ed */
@@ -365,7 +365,7 @@ void TERMINATE(FILE *file, uint flag)
{
struct st_irem *irem;
DBUG_ENTER("TERMINATE");
- pthread_mutex_lock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_malloc);
/*
Report the difference between number of calls to
@@ -428,7 +428,7 @@ void TERMINATE(FILE *file, uint flag)
DBUG_PRINT("safe",("Maximum memory usage: %lu bytes (%luk)",
(ulong) sf_malloc_max_memory,
(ulong) (sf_malloc_max_memory + 1023L) /1024L));
- pthread_mutex_unlock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_malloc);
DBUG_VOID_RETURN;
}
@@ -505,7 +505,7 @@ int _sanity(const char *filename, uint l
reg2 int flag=0;
uint count=0;
- pthread_mutex_lock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_malloc);
#ifndef PEDANTIC_SAFEMALLOC
if (sf_malloc_tampered && (int) sf_malloc_count < 0)
sf_malloc_count=0;
@@ -513,7 +513,7 @@ int _sanity(const char *filename, uint l
count=sf_malloc_count;
for (irem= sf_malloc_root; irem != NULL && count-- ; irem= irem->next)
flag+= _checkchunk (irem, filename, lineno);
- pthread_mutex_unlock(&THR_LOCK_malloc);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_malloc);
if (count || irem)
{
const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'";
=== modified file 'mysys/thr_alarm.c'
--- a/mysys/thr_alarm.c 2008-05-29 15:44:11 +0000
+++ b/mysys/thr_alarm.c 2008-10-10 20:34:55 +0000
@@ -43,8 +43,8 @@ static sig_handler process_alarm_part2(i
#if !defined(__WIN__)
-static pthread_mutex_t LOCK_alarm;
-static pthread_cond_t COND_alarm;
+static mysql_mutex_t LOCK_alarm;
+static mysql_cond_t COND_alarm;
static sigset_t full_signal_set;
static QUEUE alarm_queue;
static uint max_used_alarms=0;
@@ -52,7 +52,7 @@ pthread_t alarm_thread;
#ifdef USE_ALARM_THREAD
static void *alarm_handler(void *arg);
-#define reschedule_alarms() pthread_cond_signal(&COND_alarm)
+#define reschedule_alarms() MYSQL_COND_SIGNAL(&COND_alarm)
#else
#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
#endif
@@ -119,14 +119,14 @@ void init_thr_alarm(uint max_alarms)
void resize_thr_alarm(uint max_alarms)
{
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
/*
It's ok not to shrink the queue as there may be more pending alarms than
than max_alarms
*/
if (alarm_queue.elements < max_alarms)
resize_queue(&alarm_queue,max_alarms+1);
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
}
@@ -164,12 +164,12 @@ my_bool thr_alarm(thr_alarm_t *alrm, uin
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
#endif
- pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */
+ MYSQL_MUTEX_LOCK(&LOCK_alarm); /* Lock from threads & alarms */
if (alarm_aborted > 0)
{ /* No signal thread */
DBUG_PRINT("info", ("alarm aborted"));
*alrm= 0; /* No alarm */
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
@@ -185,7 +185,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uin
DBUG_PRINT("info", ("alarm queue full"));
fprintf(stderr,"Warning: thr_alarm queue is full\n");
*alrm= 0; /* No alarm */
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
@@ -200,7 +200,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uin
{
DBUG_PRINT("info", ("failed my_malloc()"));
*alrm= 0; /* No alarm */
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
@@ -228,7 +228,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uin
else
reschedule_alarms(); /* Reschedule alarms */
}
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
@@ -253,7 +253,7 @@ void thr_end_alarm(thr_alarm_t *alarmed)
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
#endif
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
alarm_data= (ALARM*) ((uchar*) *alarmed - offsetof(ALARM,alarmed));
for (i=0 ; i < alarm_queue.elements ; i++)
@@ -278,7 +278,7 @@ void thr_end_alarm(thr_alarm_t *alarmed)
DBUG_PRINT("warning",("Didn't find alarm %p in queue\n",
*alarmed));
}
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
#ifndef USE_ONE_SIGNAL_HAND
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
@@ -321,14 +321,14 @@ sig_handler process_alarm(int sig __attr
#ifndef USE_ALARM_THREAD
pthread_sigmask(SIG_SETMASK,&full_signal_set,&old_mask);
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
#endif
process_alarm_part2(sig);
#ifndef USE_ALARM_THREAD
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
my_sigset(THR_SERVER_ALARM,process_alarm);
#endif
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
return;
@@ -436,7 +436,7 @@ void end_thr_alarm(my_bool free_structur
DBUG_ENTER("end_thr_alarm");
if (alarm_aborted != 1) /* If memory not freed */
{
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
DBUG_PRINT("info",("Resheduling %d waiting alarms",alarm_queue.elements));
alarm_aborted= -1; /* mark aborted */
if (alarm_queue.elements || (alarm_thread_running && free_structures))
@@ -456,21 +456,21 @@ void end_thr_alarm(my_bool free_structur
set_timespec(abstime, 10); /* Wait up to 10 seconds */
while (alarm_thread_running)
{
- int error= pthread_cond_timedwait(&COND_alarm, &LOCK_alarm, &abstime);
+ int error= MYSQL_COND_TIMEDWAIT(&COND_alarm, &LOCK_alarm, &abstime);
if (error == ETIME || error == ETIMEDOUT)
break; /* Don't wait forever */
}
delete_queue(&alarm_queue);
alarm_aborted= 1;
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
if (!alarm_thread_running) /* Safety */
{
- pthread_mutex_destroy(&LOCK_alarm);
- pthread_cond_destroy(&COND_alarm);
+ MYSQL_MUTEX_DESTROY(&LOCK_alarm);
+ MYSQL_COND_DESTROY(&COND_alarm);
}
}
else
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
}
DBUG_VOID_RETURN;
}
@@ -485,7 +485,7 @@ void thr_alarm_kill(my_thread_id thread_
uint i;
if (alarm_aborted)
return;
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
for (i=0 ; i < alarm_queue.elements ; i++)
{
if (((ALARM*) queue_element(&alarm_queue,i))->thread_id == thread_id)
@@ -497,13 +497,13 @@ void thr_alarm_kill(my_thread_id thread_
break;
}
}
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
}
void thr_alarm_info(ALARM_INFO *info)
{
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
info->next_alarm_time= 0;
info->max_used_alarms= max_used_alarms;
if ((info->active_alarms= alarm_queue.elements))
@@ -514,7 +514,7 @@ void thr_alarm_info(ALARM_INFO *info)
time_diff= (long) (alarm_data->expire_time - now);
info->next_alarm_time= (ulong) (time_diff < 0 ? 0 : time_diff);
}
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
}
/*
@@ -551,7 +551,7 @@ static void *alarm_handler(void *arg __a
#endif
my_thread_init();
alarm_thread_running= 1;
- pthread_mutex_lock(&LOCK_alarm);
+ MYSQL_MUTEX_LOCK(&LOCK_alarm);
for (;;)
{
if (alarm_queue.elements)
@@ -566,7 +566,7 @@ static void *alarm_handler(void *arg __a
abstime.tv_sec=sleep_time;
abstime.tv_nsec=0;
next_alarm_expire_time= sleep_time;
- if ((error=pthread_cond_timedwait(&COND_alarm,&LOCK_alarm,&abstime))
&&
+ if ((error=MYSQL_COND_TIMEDWAIT(&COND_alarm,&LOCK_alarm,&abstime))
&&
error != ETIME && error != ETIMEDOUT)
{
#ifdef MAIN
@@ -581,7 +581,7 @@ static void *alarm_handler(void *arg __a
else
{
next_alarm_expire_time= ~ (time_t) 0;
- if ((error=pthread_cond_wait(&COND_alarm,&LOCK_alarm)))
+ if ((error=MYSQL_COND_WAIT(&COND_alarm,&LOCK_alarm)))
{
#ifdef MAIN
printf("Got error: %d from ptread_cond_wait (errno: %d)\n",
@@ -593,8 +593,8 @@ static void *alarm_handler(void *arg __a
}
bzero((char*) &alarm_thread,sizeof(alarm_thread)); /* For easy debugging */
alarm_thread_running= 0;
- pthread_cond_signal(&COND_alarm);
- pthread_mutex_unlock(&LOCK_alarm);
+ MYSQL_COND_SIGNAL(&COND_alarm);
+ MYSQL_MUTEX_UNLOCK(&LOCK_alarm);
pthread_exit(0);
return 0; /* Impossible */
}
@@ -696,8 +696,8 @@ void resize_thr_alarm(uint max_alarms)
#ifdef MAIN
#if defined(THREAD) && !defined(DONT_USE_THR_ALARM)
-static pthread_cond_t COND_thread_count;
-static pthread_mutex_t LOCK_thread_count;
+static mysql_cond_t COND_thread_count;
+static mysql_mutex_t LOCK_thread_count;
static uint thread_count;
#ifdef HPUX10
@@ -784,10 +784,10 @@ static void *test_thread(void *arg)
thr_end_alarm(&got_alarm);
fflush(stdout);
}
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
- pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_SIGNAL(&COND_thread_count); /* Tell main we are ready */
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
free((uchar*) arg);
return 0;
}
@@ -814,9 +814,9 @@ static void *signal_hand(void *arg __att
my_thread_init();
pthread_detach_this_thread();
init_thr_alarm(10); /* Setup alarm handler */
- pthread_mutex_lock(&LOCK_thread_count); /* Required by bsdi */
- pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count); /* Required by bsdi */
+ MYSQL_COND_SIGNAL(&COND_thread_count); /* Tell main we are ready */
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
sigemptyset(&set); /* Catch all signals */
sigaddset(&set,SIGINT);
@@ -915,10 +915,10 @@ int main(int argc __attribute__((unused)
pthread_attr_setstacksize(&thr_attr,65536L);
/* Start signal thread and wait for it to start */
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
pthread_create(&tid,&thr_attr,signal_hand,NULL);
- pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_PRINT("info",("signal thread created"));
thr_setconcurrency(3);
@@ -928,32 +928,32 @@ int main(int argc __attribute__((unused)
{
param=(int*) malloc(sizeof(int));
*param= i;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
if ((error=pthread_create(&tid,&thr_attr,test_thread,(void*) param)))
{
printf("Can't create thread %d, error: %d\n",i,error);
exit(1);
}
thread_count++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
pthread_attr_destroy(&thr_attr);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thr_alarm_info(&alarm_info);
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
alarm_info.active_alarms, alarm_info.max_used_alarms,
alarm_info.next_alarm_time);
while (thread_count)
{
- pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
+ MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
if (thread_count == 1)
{
printf("Calling end_thr_alarm. This should cancel the last thread\n");
end_thr_alarm(0);
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thr_alarm_info(&alarm_info);
end_thr_alarm(1);
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c 2008-08-26 12:00:01 +0000
+++ b/mysys/thr_lock.c 2008-10-10 20:34:55 +0000
@@ -100,7 +100,7 @@ enum thr_lock_type thr_upgraded_concurre
LIST *thr_lock_thread_list; /* List of threads in use */
ulong max_write_lock_count= ~(ulong) 0L;
-static inline pthread_cond_t *get_cond(void)
+static inline mysql_cond_t *get_cond(void)
{
return &my_thread_var->suspend;
}
@@ -344,10 +344,10 @@ void thr_lock_init(THR_LOCK *lock)
lock->write_wait.last= &lock->write_wait.data;
lock->write.last= &lock->write.data;
- pthread_mutex_lock(&THR_LOCK_lock); /* Add to locks in use */
+ MYSQL_MUTEX_LOCK(&THR_LOCK_lock); /* Add to locks in use */
lock->list.data=(void*) lock;
thr_lock_thread_list=list_add(thr_lock_thread_list,&lock->list);
- pthread_mutex_unlock(&THR_LOCK_lock);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_lock);
DBUG_VOID_RETURN;
}
@@ -355,10 +355,10 @@ void thr_lock_init(THR_LOCK *lock)
void thr_lock_delete(THR_LOCK *lock)
{
DBUG_ENTER("thr_lock_delete");
- pthread_mutex_lock(&THR_LOCK_lock);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_lock);
thr_lock_thread_list=list_delete(thr_lock_thread_list,&lock->list);
- pthread_mutex_unlock(&THR_LOCK_lock);
- pthread_mutex_destroy(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_lock);
+ MYSQL_MUTEX_DESTROY(&lock->mutex);
DBUG_VOID_RETURN;
}
@@ -422,7 +422,7 @@ wait_for_lock(struct st_lock_list *wait,
my_bool in_wait_list)
{
struct st_my_thread_var *thread_var= my_thread_var;
- pthread_cond_t *cond= &thread_var->suspend;
+ mysql_cond_t *cond= &thread_var->suspend;
struct timespec wait_timeout;
enum enum_thr_lock_result result= THR_LOCK_ABORTED;
my_bool can_deadlock= test(data->owner->info->n_cursors);
@@ -456,9 +456,9 @@ wait_for_lock(struct st_lock_list *wait,
while (!thread_var->abort || in_wait_list)
{
int rc= (can_deadlock ?
- pthread_cond_timedwait(cond, &data->lock->mutex,
+ MYSQL_COND_TIMEDWAIT(cond, &data->lock->mutex,
&wait_timeout) :
- pthread_cond_wait(cond, &data->lock->mutex));
+ MYSQL_COND_WAIT(cond, &data->lock->mutex));
/*
We must break the wait if one of the following occurs:
- the connection has been aborted (!thread_var->abort), but
@@ -514,13 +514,13 @@ wait_for_lock(struct st_lock_list *wait,
(*data->lock->get_status)(data->status_param, 0);
check_locks(data->lock,"got wait_for_lock",0);
}
- pthread_mutex_unlock(&data->lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&data->lock->mutex);
/* The following must be done after unlock of lock->mutex */
- pthread_mutex_lock(&thread_var->mutex);
+ MYSQL_MUTEX_LOCK(&thread_var->mutex);
thread_var->current_mutex= 0;
thread_var->current_cond= 0;
- pthread_mutex_unlock(&thread_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&thread_var->mutex);
DBUG_RETURN(result);
}
@@ -539,7 +539,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_O
data->cond=0; /* safety */
data->type=lock_type;
data->owner= owner; /* Must be reset ! */
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
DBUG_PRINT("lock",("data: %p thread: 0x%lx lock: %p type: %d",
data, data->owner->info->thread_id,
lock, (int) lock_type));
@@ -748,7 +748,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_O
/* Can't get lock yet; Wait for it */
DBUG_RETURN(wait_for_lock(wait_queue, data, 0));
end:
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_RETURN(result);
}
@@ -770,7 +770,7 @@ static inline void free_all_read_locks(T
do
{
- pthread_cond_t *cond=data->cond;
+ mysql_cond_t *cond=data->cond;
if ((int) data->type == (int) TL_READ_NO_INSERT)
{
if (using_concurrent_insert)
@@ -795,7 +795,7 @@ static inline void free_all_read_locks(T
data->owner->info->thread_id));
/* purecov: end */
data->cond=0; /* Mark thread free */
- pthread_cond_signal(cond);
+ MYSQL_COND_SIGNAL(cond);
} while ((data=data->next));
*lock->read_wait.last=0;
if (!lock->read_wait.data)
@@ -812,7 +812,7 @@ void thr_unlock(THR_LOCK_DATA *data)
DBUG_ENTER("thr_unlock");
DBUG_PRINT("lock",("data: %p thread: 0x%lx lock: %p",
data, data->owner->info->thread_id, lock));
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
check_locks(lock,"start of release lock",0);
if (((*data->prev)=data->next)) /* remove from lock-list */
@@ -834,7 +834,7 @@ void thr_unlock(THR_LOCK_DATA *data)
data->type=TL_UNLOCK; /* Mark unlocked */
check_locks(lock,"after releasing lock",1);
wake_up_waiters(lock);
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_VOID_RETURN;
}
@@ -892,9 +892,9 @@ static void wake_up_waiters(THR_LOCK *lo
data->type, data->owner->info->thread_id));
/* purecov: end */
{
- pthread_cond_t *cond=data->cond;
+ mysql_cond_t *cond=data->cond;
data->cond=0; /* Mark thread free */
- pthread_cond_signal(cond); /* Start waiting thread */
+ MYSQL_COND_SIGNAL(cond); /* Start waiting thread */
}
if (data->type != TL_WRITE_ALLOW_WRITE ||
!lock->write_wait.data ||
@@ -935,7 +935,7 @@ static void wake_up_waiters(THR_LOCK *lo
goto end;
}
do {
- pthread_cond_t *cond=data->cond;
+ mysql_cond_t *cond=data->cond;
if (((*data->prev)=data->next)) /* remove from wait-list */
data->next->prev= data->prev;
else
@@ -945,7 +945,7 @@ static void wake_up_waiters(THR_LOCK *lo
lock->write.last= &data->next;
data->next=0; /* Only one write lock */
data->cond=0; /* Mark thread free */
- pthread_cond_signal(cond); /* Start waiting thread */
+ MYSQL_COND_SIGNAL(cond); /* Start waiting thread */
} while (lock_type == TL_WRITE_ALLOW_WRITE &&
(data=lock->write_wait.data) &&
data->type == TL_WRITE_ALLOW_WRITE);
@@ -1131,19 +1131,19 @@ void thr_abort_locks(THR_LOCK *lock, my_
{
THR_LOCK_DATA *data;
DBUG_ENTER("thr_abort_locks");
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
for (data=lock->read_wait.data; data ; data=data->next)
{
data->type=TL_UNLOCK; /* Mark killed */
/* It's safe to signal the cond first: we're still holding the mutex. */
- pthread_cond_signal(data->cond);
+ MYSQL_COND_SIGNAL(data->cond);
data->cond=0; /* Removed from list */
}
for (data=lock->write_wait.data; data ; data=data->next)
{
data->type=TL_UNLOCK;
- pthread_cond_signal(data->cond);
+ MYSQL_COND_SIGNAL(data->cond);
data->cond=0;
}
lock->read_wait.last= &lock->read_wait.data;
@@ -1151,7 +1151,7 @@ void thr_abort_locks(THR_LOCK *lock, my_
lock->read_wait.data=lock->write_wait.data=0;
if (upgrade_lock && lock->write.data)
lock->write.data->type=TL_WRITE_ONLY;
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_VOID_RETURN;
}
@@ -1168,7 +1168,7 @@ my_bool thr_abort_locks_for_thread(THR_L
my_bool found= FALSE;
DBUG_ENTER("thr_abort_locks_for_thread");
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
for (data= lock->read_wait.data; data ; data= data->next)
{
if (data->owner->info->thread_id == thread_id) /* purecov: tested */
@@ -1177,7 +1177,7 @@ my_bool thr_abort_locks_for_thread(THR_L
data->type= TL_UNLOCK; /* Mark killed */
/* It's safe to signal the cond first: we're still holding the mutex. */
found= TRUE;
- pthread_cond_signal(data->cond);
+ MYSQL_COND_SIGNAL(data->cond);
data->cond= 0; /* Removed from list */
if (((*data->prev)= data->next))
@@ -1193,7 +1193,7 @@ my_bool thr_abort_locks_for_thread(THR_L
DBUG_PRINT("info",("Aborting write-wait lock"));
data->type= TL_UNLOCK;
found= TRUE;
- pthread_cond_signal(data->cond);
+ MYSQL_COND_SIGNAL(data->cond);
data->cond= 0;
if (((*data->prev)= data->next))
@@ -1203,7 +1203,7 @@ my_bool thr_abort_locks_for_thread(THR_L
}
}
wake_up_waiters(lock);
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_RETURN(found);
}
@@ -1252,7 +1252,7 @@ void thr_downgrade_write_lock(THR_LOCK_D
#endif
DBUG_ENTER("thr_downgrade_write_only_lock");
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
DBUG_ASSERT(old_lock_type == TL_WRITE_ONLY);
DBUG_ASSERT(old_lock_type > new_lock_type);
in_data->type= new_lock_type;
@@ -1344,7 +1344,7 @@ void thr_downgrade_write_lock(THR_LOCK_D
next= data->next;
if (start_writers && data->type == new_lock_type)
{
- pthread_cond_t *cond= data->cond;
+ mysql_cond_t *cond= data->cond;
/*
It is ok to start this waiter.
Move from being first in wait queue to be last in write queue.
@@ -1358,7 +1358,7 @@ void thr_downgrade_write_lock(THR_LOCK_D
data->next= 0;
check_locks(lock, "Started write lock after downgrade",0);
data->cond= 0;
- pthread_cond_signal(cond);
+ MYSQL_COND_SIGNAL(cond);
}
else
{
@@ -1398,7 +1398,7 @@ void thr_downgrade_write_lock(THR_LOCK_D
if (new_lock_type != TL_WRITE_ALLOW_READ ||
data->type != TL_READ_NO_INSERT)
{
- pthread_cond_t *cond= data->cond;
+ mysql_cond_t *cond= data->cond;
if (((*data->prev)= data->next))
data->next->prev= data->prev;
else
@@ -1411,13 +1411,13 @@ void thr_downgrade_write_lock(THR_LOCK_D
lock->read_no_write_count++;
check_locks(lock, "Started read lock after downgrade",0);
data->cond= 0;
- pthread_cond_signal(cond);
+ MYSQL_COND_SIGNAL(cond);
}
}
}
check_locks(lock,"after starting waiters after downgrading lock",0);
#endif
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_VOID_RETURN;
}
@@ -1428,10 +1428,10 @@ my_bool thr_upgrade_write_delay_lock(THR
THR_LOCK *lock=data->lock;
DBUG_ENTER("thr_upgrade_write_delay_lock");
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
if (data->type == TL_UNLOCK || data->type >= TL_WRITE_LOW_PRIORITY)
{
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_RETURN(data->type == TL_UNLOCK); /* Test if Aborted */
}
check_locks(lock,"before upgrading lock",0);
@@ -1445,7 +1445,7 @@ my_bool thr_upgrade_write_delay_lock(THR
{ /* We have the lock */
if (lock->get_status)
(*lock->get_status)(data->status_param, 0);
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_RETURN(0);
}
@@ -1477,10 +1477,10 @@ my_bool thr_reschedule_write_lock(THR_LO
THR_LOCK *lock=data->lock;
DBUG_ENTER("thr_reschedule_write_lock");
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
if (!lock->read_wait.data) /* No waiting read locks */
{
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_RETURN(0);
}
@@ -1501,7 +1501,7 @@ my_bool thr_reschedule_write_lock(THR_LO
lock->write_wait.data=data;
free_all_read_locks(lock,0);
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
DBUG_RETURN(thr_upgrade_write_delay_lock(data));
}
@@ -1536,13 +1536,13 @@ void thr_print_locks(void)
LIST *list;
uint count=0;
- pthread_mutex_lock(&THR_LOCK_lock);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_lock);
puts("Current locks:");
for (list= thr_lock_thread_list; list && count++ < MAX_THREADS;
list= list_rest(list))
{
THR_LOCK *lock=(THR_LOCK*) list->data;
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
printf("lock: 0x%lx:",(ulong) lock);
if ((lock->write_wait.data || lock->read_wait.data) &&
(! lock->read.data && ! lock->write.data))
@@ -1560,11 +1560,11 @@ void thr_print_locks(void)
thr_print_lock("write_wait",&lock->write_wait);
thr_print_lock("read",&lock->read);
thr_print_lock("read_wait",&lock->read_wait);
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
puts("");
}
fflush(stdout);
- pthread_mutex_unlock(&THR_LOCK_lock);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_lock);
}
#endif /* THREAD */
@@ -1641,8 +1641,8 @@ int lock_counts[]= {sizeof(test_0)/sizeo
};
-static pthread_cond_t COND_thread_count;
-static pthread_mutex_t LOCK_thread_count;
+static mysql_cond_t COND_thread_count;
+static mysql_mutex_t LOCK_thread_count;
static uint thread_count;
static ulong sum=0;
@@ -1693,7 +1693,7 @@ static void *test_thread(void *arg)
data[i].type= tests[param][i].lock_type;
}
thr_multi_lock(multi_locks, lock_counts[param], &owner);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
{
int tmp=rand() & 7; /* Do something from 0-2 sec */
if (tmp == 0)
@@ -1707,16 +1707,16 @@ static void *test_thread(void *arg)
sum+=k;
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thr_multi_unlock(multi_locks,lock_counts[param]);
}
printf("Thread %s (%d) ended\n",my_thread_name(),param); fflush(stdout);
thr_print_locks();
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
- pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_SIGNAL(&COND_thread_count); /* Tell main we are ready */
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
free((uchar*) arg);
return 0;
}
@@ -1785,9 +1785,9 @@ int main(int argc __attribute__((unused)
param=(int*) malloc(sizeof(int));
*param=i;
- if ((error=pthread_mutex_lock(&LOCK_thread_count)))
+ if ((error=MYSQL_MUTEX_LOCK(&LOCK_thread_count)))
{
- fprintf(stderr,"Got error: %d from pthread_mutex_lock (errno: %d)",
+ fprintf(stderr,"Got error: %d from MYSQL_MUTEX_LOCK (errno: %d)",
error,errno);
exit(1);
}
@@ -1795,23 +1795,23 @@ int main(int argc __attribute__((unused)
{
fprintf(stderr,"Got error: %d from pthread_create (errno: %d)\n",
error,errno);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
exit(1);
}
thread_count++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
pthread_attr_destroy(&thr_attr);
- if ((error=pthread_mutex_lock(&LOCK_thread_count)))
- fprintf(stderr,"Got error: %d from pthread_mutex_lock\n",error);
+ if ((error=MYSQL_MUTEX_LOCK(&LOCK_thread_count)))
+ fprintf(stderr,"Got error: %d from MYSQL_MUTEX_LOCK\n",error);
while (thread_count)
{
- if ((error=pthread_cond_wait(&COND_thread_count,&LOCK_thread_count)))
- fprintf(stderr,"Got error: %d from pthread_cond_wait\n",error);
+ if ((error=MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count)))
+ fprintf(stderr,"Got error: %d from MYSQL_COND_WAIT\n",error);
}
- if ((error=pthread_mutex_unlock(&LOCK_thread_count)))
- fprintf(stderr,"Got error: %d from pthread_mutex_unlock\n",error);
+ if ((error=MYSQL_MUTEX_UNLOCK(&LOCK_thread_count)))
+ fprintf(stderr,"Got error: %d from MYSQL_MUTEX_UNLOCK\n",error);
for (i=0 ; i < array_elements(locks) ; i++)
thr_lock_delete(locks+i);
#ifdef EXTRA_DEBUG
=== modified file 'mysys/thr_rwlock.c'
--- a/mysys/thr_rwlock.c 2006-12-23 19:17:15 +0000
+++ b/mysys/thr_rwlock.c 2008-10-10 20:34:55 +0000
@@ -58,7 +58,7 @@
* Mountain View, California 94043
*/
-int my_rwlock_init(rw_lock_t *rwp, void *arg __attribute__((unused)))
+int my_rwlock_init(mysql_rwlock_t *rwp, void *arg __attribute__((unused)))
{
pthread_condattr_t cond_attr;
@@ -75,32 +75,32 @@ int my_rwlock_init(rw_lock_t *rwp, void
}
-int my_rwlock_destroy(rw_lock_t *rwp)
+int my_MYSQL_RWLOCK_DESTROY(mysql_rwlock_t *rwp)
{
- pthread_mutex_destroy( &rwp->lock );
- pthread_cond_destroy( &rwp->readers );
- pthread_cond_destroy( &rwp->writers );
+ MYSQL_MUTEX_DESTROY( &rwp->lock );
+ MYSQL_COND_DESTROY( &rwp->readers );
+ MYSQL_COND_DESTROY( &rwp->writers );
return(0);
}
-int my_rw_rdlock(rw_lock_t *rwp)
+int my_MYSQL_RWLOCK_RDLOCK(mysql_rwlock_t *rwp)
{
- pthread_mutex_lock(&rwp->lock);
+ MYSQL_MUTEX_LOCK(&rwp->lock);
/* active or queued writers */
while (( rwp->state < 0 ) || rwp->waiters)
- pthread_cond_wait( &rwp->readers, &rwp->lock);
+ MYSQL_COND_WAIT( &rwp->readers, &rwp->lock);
rwp->state++;
- pthread_mutex_unlock(&rwp->lock);
+ MYSQL_MUTEX_UNLOCK(&rwp->lock);
return(0);
}
-int my_rw_tryrdlock(rw_lock_t *rwp)
+int my_MYSQL_RWLOCK_TRYRDLOCK(mysql_rwlock_t *rwp)
{
int res;
- pthread_mutex_lock(&rwp->lock);
+ MYSQL_MUTEX_LOCK(&rwp->lock);
if ((rwp->state < 0 ) || rwp->waiters)
res= EBUSY; /* Can't get lock */
else
@@ -108,29 +108,29 @@ int my_rw_tryrdlock(rw_lock_t *rwp)
res=0;
rwp->state++;
}
- pthread_mutex_unlock(&rwp->lock);
+ MYSQL_MUTEX_UNLOCK(&rwp->lock);
return(res);
}
-int my_rw_wrlock(rw_lock_t *rwp)
+int my_MYSQL_RWLOCK_WRLOCK(mysql_rwlock_t *rwp)
{
- pthread_mutex_lock(&rwp->lock);
+ MYSQL_MUTEX_LOCK(&rwp->lock);
rwp->waiters++; /* another writer queued */
while (rwp->state)
- pthread_cond_wait(&rwp->writers, &rwp->lock);
+ MYSQL_COND_WAIT(&rwp->writers, &rwp->lock);
rwp->state = -1;
rwp->waiters--;
- pthread_mutex_unlock(&rwp->lock);
+ MYSQL_MUTEX_UNLOCK(&rwp->lock);
return(0);
}
-int my_rw_trywrlock(rw_lock_t *rwp)
+int my_MYSQL_RWLOCK_TRYWRLOCK(mysql_rwlock_t *rwp)
{
int res;
- pthread_mutex_lock(&rwp->lock);
+ MYSQL_MUTEX_LOCK(&rwp->lock);
if (rwp->state)
res= EBUSY; /* Can't get lock */
else
@@ -138,33 +138,33 @@ int my_rw_trywrlock(rw_lock_t *rwp)
res=0;
rwp->state = -1;
}
- pthread_mutex_unlock(&rwp->lock);
+ MYSQL_MUTEX_UNLOCK(&rwp->lock);
return(res);
}
-int my_rw_unlock(rw_lock_t *rwp)
+int my_MYSQL_RWLOCK_UNLOCK(mysql_rwlock_t *rwp)
{
- DBUG_PRINT("rw_unlock",
+ DBUG_PRINT("MYSQL_RWLOCK_UNLOCK",
("state: %d waiters: %d", rwp->state, rwp->waiters));
- pthread_mutex_lock(&rwp->lock);
+ MYSQL_MUTEX_LOCK(&rwp->lock);
if (rwp->state == -1) /* writer releasing */
{
rwp->state= 0; /* mark as available */
if ( rwp->waiters ) /* writers queued */
- pthread_cond_signal( &rwp->writers );
+ MYSQL_COND_SIGNAL( &rwp->writers );
else
- pthread_cond_broadcast( &rwp->readers );
+ MYSQL_COND_BROADCAST( &rwp->readers );
}
else
{
if ( --rwp->state == 0 ) /* no more readers */
- pthread_cond_signal( &rwp->writers );
+ MYSQL_COND_SIGNAL( &rwp->writers );
}
- pthread_mutex_unlock( &rwp->lock );
+ MYSQL_MUTEX_UNLOCK( &rwp->lock );
return(0);
}
=== modified file 'mysys/wqueue.c'
--- a/mysys/wqueue.c 2008-04-21 14:43:38 +0000
+++ b/mysys/wqueue.c 2008-10-10 20:34:55 +0000
@@ -130,7 +130,7 @@ void wqueue_release_queue(WQUEUE *wqueue
do
{
thread= next;
- pthread_cond_signal(&thread->suspend);
+ MYSQL_COND_SIGNAL(&thread->suspend);
next= thread->next;
thread->next= NULL;
}
@@ -158,7 +158,7 @@ void wqueue_release_one_locktype_from_qu
if (first_type == MY_PTHREAD_LOCK_WRITE)
{
/* release first waiting for write lock */
- pthread_cond_signal(&next->suspend);
+ MYSQL_COND_SIGNAL(&next->suspend);
if (next == last)
wqueue->last_thread= NULL;
else
@@ -184,7 +184,7 @@ void wqueue_release_one_locktype_from_qu
else
{
/* release waiting for read lock */
- pthread_cond_signal(&thread->suspend);
+ MYSQL_COND_SIGNAL(&thread->suspend);
thread->next= NULL;
}
} while (thread != last);
@@ -204,7 +204,7 @@ void wqueue_release_one_locktype_from_qu
void wqueue_add_and_wait(WQUEUE *wqueue,
struct st_my_thread_var *thread,
- pthread_mutex_t *lock)
+ mysql_mutex_t *lock)
{
DBUG_ENTER("wqueue_add_and_wait");
DBUG_PRINT("enter",
@@ -215,7 +215,7 @@ void wqueue_add_and_wait(WQUEUE *wqueue,
{
DBUG_PRINT("info", ("wait... cond: 0x%lx mutex: 0x%lx",
(ulong) &thread->suspend, (ulong) lock));
- pthread_cond_wait(&thread->suspend, lock);
+ MYSQL_COND_WAIT(&thread->suspend, lock);
DBUG_PRINT("info", ("wait done cond: 0x%lx mutex: 0x%lx next: 0x%lx",
(ulong) &thread->suspend, (ulong) lock,
(ulong) thread->next));
=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h 2008-09-02 09:04:39 +0000
+++ b/sql/backup/backup_kernel.h 2008-10-10 20:34:55 +0000
@@ -50,6 +50,10 @@ int restore_table_data(THD*, Restore_inf
}
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_BRC_run_lock;
+#endif
+
/**
Instances of this class are used for creating required context and performing
backup/restore operations.
@@ -87,7 +91,7 @@ class Backup_restore_ctx: public backup:
ongoing backup/restore operation. If pointer is null, no
operation is currently running. */
static Backup_restore_ctx *current_op;
- static pthread_mutex_t run_lock; ///< To guard @c current_op.
+ static mysql_mutex_t run_lock; ///< To guard @c current_op.
/**
@brief State of a context object.
=== modified file 'sql/backup/be_thread.cc'
--- a/sql/backup/be_thread.cc 2008-07-09 07:12:43 +0000
+++ b/sql/backup/be_thread.cc 2008-10-10 20:34:55 +0000
@@ -52,9 +52,9 @@ THD *create_new_thd()
THD_CHECK_SENTRY(thd);
thd->thread_stack = (char*)&thd; // remember where our stack is
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->thread_id= thread_id++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (unlikely(thd->store_globals())) // for a proper MEM_ROOT
{
thd->cleanup();
@@ -81,11 +81,11 @@ THD *create_new_thd()
Making this thread visible to SHOW PROCESSLIST is useful for
troubleshooting a backup job (why does it stall etc).
*/
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
threads.append(thd);
thread_count++;
thread_running++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_RETURN(thd);
}
@@ -146,13 +146,13 @@ pthread_handler_t backup_thread_for_lock
goto end2;
}
- pthread_mutex_lock(&locking_thd->THR_LOCK_caller);
+ MYSQL_MUTEX_LOCK(&locking_thd->THR_LOCK_caller);
if (thd->killed)
{
THD_SET_PROC_INFO(thd, "lock error");
locking_thd->lock_state= LOCK_ERROR;
- pthread_mutex_unlock(&locking_thd->THR_LOCK_caller);
+ MYSQL_MUTEX_UNLOCK(&locking_thd->THR_LOCK_caller);
goto end;
}
@@ -166,7 +166,7 @@ pthread_handler_t backup_thread_for_lock
DBUG_PRINT("info",("Online backup locking thread dying"));
THD_SET_PROC_INFO(thd, "lock error");
locking_thd->lock_state= LOCK_ERROR;
- pthread_mutex_unlock(&locking_thd->THR_LOCK_caller);
+ MYSQL_MUTEX_UNLOCK(&locking_thd->THR_LOCK_caller);
goto end;
}
@@ -174,24 +174,24 @@ pthread_handler_t backup_thread_for_lock
{
THD_SET_PROC_INFO(thd, "lock error");
locking_thd->lock_state= LOCK_ERROR;
- pthread_mutex_unlock(&locking_thd->THR_LOCK_caller);
+ MYSQL_MUTEX_UNLOCK(&locking_thd->THR_LOCK_caller);
goto end;
}
- pthread_mutex_unlock(&locking_thd->THR_LOCK_caller);
+ MYSQL_MUTEX_UNLOCK(&locking_thd->THR_LOCK_caller);
/*
Part of work is done. Rest until woken up.
We wait if the thread is not killed and the driver has not signaled us.
*/
THD_SET_PROC_INFO(thd, "waiting for signal");
- pthread_mutex_lock(&locking_thd->THR_LOCK_thread);
+ MYSQL_MUTEX_LOCK(&locking_thd->THR_LOCK_thread);
locking_thd->lock_state= LOCK_ACQUIRED;
thd->enter_cond(&locking_thd->COND_thread_wait,
&locking_thd->THR_LOCK_thread,
"Locking thread: holding table locks");
while (!thd->killed && (locking_thd->lock_state != LOCK_SIGNAL))
- pthread_cond_wait(&locking_thd->COND_thread_wait,
+ MYSQL_COND_WAIT(&locking_thd->COND_thread_wait,
&locking_thd->THR_LOCK_thread);
thd->exit_cond("Locking thread: terminating");
THD_SET_PROC_INFO(thd, "terminating");
@@ -206,12 +206,12 @@ end:
end2:
THD_SET_PROC_INFO(thd, "lock done");
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
thread_running--;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
- pthread_mutex_lock(&locking_thd->THR_LOCK_caller);
+ MYSQL_MUTEX_LOCK(&locking_thd->THR_LOCK_caller);
net_end(&thd->net);
my_thread_end();
delete thd;
@@ -222,8 +222,8 @@ end2:
/*
Signal the driver thread that it's ok to proceed with destructor.
*/
- pthread_cond_signal(&locking_thd->COND_caller_wait);
- pthread_mutex_unlock(&locking_thd->THR_LOCK_caller);
+ MYSQL_COND_SIGNAL(&locking_thd->COND_caller_wait);
+ MYSQL_MUTEX_UNLOCK(&locking_thd->THR_LOCK_caller);
pthread_exit(0);
return (0);
}
@@ -236,10 +236,10 @@ Locking_thread_st::Locking_thread_st()
/*
Initialize the thread mutex and cond variable.
*/
- pthread_mutex_init(&THR_LOCK_thread, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_thread_wait, NULL);
- pthread_mutex_init(&THR_LOCK_caller, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_caller_wait, NULL);
+ MYSQL_MUTEX_INIT(&THR_LOCK_thread, key_THR_LOCK_thread, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_thread_wait, key_COND_thread_wait, NULL);
+ MYSQL_MUTEX_INIT(&THR_LOCK_caller, key_THR_LOCK_caller, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_caller_wait, key_COND_caller_wait, NULL);
lock_state= LOCK_NOT_STARTED;
lock_thd= NULL; // set to 0 as precaution for get_data being called too soon
thd_name.length(0);
@@ -261,10 +261,10 @@ Locking_thread_st::~Locking_thread_st()
/*
Destroy the thread mutexes and cond variables.
*/
- pthread_mutex_destroy(&THR_LOCK_thread);
- pthread_cond_destroy(&COND_thread_wait);
- pthread_mutex_destroy(&THR_LOCK_caller);
- pthread_cond_destroy(&COND_caller_wait);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_thread);
+ MYSQL_COND_DESTROY(&COND_thread_wait);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_caller);
+ MYSQL_COND_DESTROY(&COND_caller_wait);
}
/**
@@ -297,19 +297,19 @@ result_t Locking_thread_st::start_lockin
void Locking_thread_st::kill_locking_thread()
{
DBUG_ENTER("Locking_thread_st::kill_locking_thread");
- pthread_mutex_lock(&THR_LOCK_caller);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_caller);
if (lock_state == LOCK_ERROR)
THD_SET_PROC_INFO(m_thd, "error in the locking thread");
if (lock_thd && (lock_state != LOCK_DONE) && (lock_state !=
LOCK_SIGNAL))
{
lock_state= LOCK_SIGNAL;
- pthread_mutex_lock(&lock_thd->LOCK_delete);
+ MYSQL_MUTEX_LOCK(&lock_thd->LOCK_delete);
lock_thd->awake(THD::KILL_CONNECTION);
- pthread_mutex_unlock(&lock_thd->LOCK_delete);
- pthread_cond_signal(&COND_thread_wait);
+ MYSQL_MUTEX_UNLOCK(&lock_thd->LOCK_delete);
+ MYSQL_COND_SIGNAL(&COND_thread_wait);
}
- pthread_mutex_unlock(&THR_LOCK_caller);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_caller);
/*
This tells the CS driver that we're finished with the tables.
@@ -328,17 +328,17 @@ void Locking_thread_st::kill_locking_thr
*/
void Locking_thread_st::wait_until_locking_thread_dies()
{
- pthread_mutex_lock(&THR_LOCK_caller);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_caller);
if (lock_state != LOCK_DONE)
{
m_thd->enter_cond(&COND_caller_wait, &THR_LOCK_caller,
"Locking thread: waiting until locking thread is done");
while (lock_state != LOCK_DONE)
- pthread_cond_wait(&COND_caller_wait, &THR_LOCK_caller);
+ MYSQL_COND_WAIT(&COND_caller_wait, &THR_LOCK_caller);
m_thd->exit_cond("Locking thread: terminating");
DBUG_PRINT("info",("Locking thread's locking thread terminated"));
}
else
- pthread_mutex_unlock(&THR_LOCK_caller);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_caller);
}
=== modified file 'sql/backup/be_thread.h'
--- a/sql/backup/be_thread.h 2008-07-09 07:12:43 +0000
+++ b/sql/backup/be_thread.h 2008-10-10 20:34:55 +0000
@@ -33,6 +33,13 @@ using backup::Table_list;
*/
pthread_handler_t backup_thread_for_locking(void *arg);
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_THR_LOCK_thread;
+extern PSI_cond_key key_COND_thread_wait;
+extern PSI_mutex_key key_THR_LOCK_caller;
+extern PSI_cond_key key_COND_caller_wait;
+#endif
+
/**
* @struct Locking_thread
*
@@ -48,10 +55,10 @@ public:
Locking_thread_st();
~Locking_thread_st();
- pthread_mutex_t THR_LOCK_thread; ///< mutex for thread variables
- pthread_cond_t COND_thread_wait; ///< condition variable for wait
- pthread_mutex_t THR_LOCK_caller; ///< mutex for thread variables
- pthread_cond_t COND_caller_wait; ///< condition variable for wait
+ mysql_mutex_t THR_LOCK_thread; ///< mutex for thread variables
+ mysql_cond_t COND_thread_wait; ///< condition variable for wait
+ mysql_mutex_t THR_LOCK_caller; ///< mutex for thread variables
+ mysql_cond_t COND_caller_wait; ///< condition variable for wait
TABLE_LIST *tables_in_backup; ///< List of tables used in backup
THD *lock_thd; ///< Locking thread pointer
=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc 2008-09-19 09:55:21 +0000
+++ b/sql/backup/kernel.cc 2008-10-10 20:34:55 +0000
@@ -94,7 +94,7 @@
*/
int backup_init()
{
- pthread_mutex_init(&Backup_restore_ctx::run_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&Backup_restore_ctx::run_lock, key_BRC_run_lock,
MY_MUTEX_INIT_FAST);
return 0;
}
@@ -106,7 +106,7 @@ int backup_init()
*/
void backup_shutdown()
{
- pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+ MYSQL_MUTEX_DESTROY(&Backup_restore_ctx::run_lock);
}
/*
@@ -362,7 +362,7 @@ class Mem_allocator
// static members
Backup_restore_ctx *Backup_restore_ctx::current_op= NULL;
-pthread_mutex_t Backup_restore_ctx::run_lock;
+mysql_mutex_t Backup_restore_ctx::run_lock;
Backup_restore_ctx::Backup_restore_ctx(THD *thd)
@@ -428,14 +428,14 @@ int Backup_restore_ctx::prepare(LEX_STRI
this operation.
*/
- pthread_mutex_lock(&run_lock);
+ MYSQL_MUTEX_LOCK(&run_lock);
if (!current_op)
current_op= this;
else
fatal_error(ER_BACKUP_RUNNING);
- pthread_mutex_unlock(&run_lock);
+ MYSQL_MUTEX_UNLOCK(&run_lock);
if (m_error)
return m_error;
@@ -833,11 +833,11 @@ int Backup_restore_ctx::close()
mem_alloc= NULL;
// deregister this operation if it was running
- pthread_mutex_lock(&run_lock);
+ MYSQL_MUTEX_LOCK(&run_lock);
if (current_op == this) {
current_op= NULL;
}
- pthread_mutex_unlock(&run_lock);
+ MYSQL_MUTEX_UNLOCK(&run_lock);
/*
Remove the location, if asked for.
=== modified file 'sql/ddl_blocker.cc'
--- a/sql/ddl_blocker.cc 2008-08-19 15:35:29 +0000
+++ b/sql/ddl_blocker.cc 2008-10-10 20:34:55 +0000
@@ -46,24 +46,24 @@ void DDL_blocker_class::destroy_DDL_bloc
DDL_blocker_class::DDL_blocker_class()
{
- pthread_mutex_init(&THR_LOCK_DDL_blocker, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&THR_LOCK_DDL_is_blocked, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&THR_LOCK_DDL_blocker_blocked, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_DDL_blocker, NULL);
- pthread_cond_init(&COND_process_blocked, NULL);
- pthread_cond_init(&COND_DDL_blocker_blocked, NULL);
+ MYSQL_MUTEX_INIT(&THR_LOCK_DDL_blocker, key_THR_LOCK_DDL_blocker,
MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&THR_LOCK_DDL_is_blocked, key_THR_LOCK_DDL_is_blocked,
MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&THR_LOCK_DDL_blocker_blocked, key_THR_LOCK_DDL_blocker_blocked,
MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_DDL_blocker, key_COND_DDL_blocker, NULL);
+ MYSQL_COND_INIT(&COND_process_blocked, key_COND_process_blocked, NULL);
+ MYSQL_COND_INIT(&COND_DDL_blocker_blocked, key_COND_DDL_blocker_blocked, NULL);
DDL_blocked= FALSE;
DDL_blocks= 0;
}
DDL_blocker_class::~DDL_blocker_class()
{
- pthread_mutex_destroy(&THR_LOCK_DDL_blocker);
- pthread_mutex_destroy(&THR_LOCK_DDL_is_blocked);
- pthread_mutex_destroy(&THR_LOCK_DDL_blocker_blocked);
- pthread_cond_destroy(&COND_DDL_blocker);
- pthread_cond_destroy(&COND_process_blocked);
- pthread_cond_destroy(&COND_DDL_blocker_blocked);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_DDL_blocker);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_DDL_is_blocked);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_DDL_blocker_blocked);
+ MYSQL_COND_DESTROY(&COND_DDL_blocker);
+ MYSQL_COND_DESTROY(&COND_process_blocked);
+ MYSQL_COND_DESTROY(&COND_DDL_blocker_blocked);
}
/**
@@ -74,9 +74,9 @@ DDL_blocker_class::~DDL_blocker_class()
void DDL_blocker_class::start_DDL()
{
DBUG_ENTER("start_DDL()");
- pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_DDL_blocker);
DDL_blocks++;
- pthread_mutex_unlock(&THR_LOCK_DDL_blocker);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_DDL_blocker);
DBUG_VOID_RETURN;
}
@@ -89,12 +89,12 @@ void DDL_blocker_class::start_DDL()
void DDL_blocker_class::end_DDL()
{
DBUG_ENTER("end_DDL()");
- pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_DDL_blocker);
if (DDL_blocks > 0)
DDL_blocks--;
if (DDL_blocks == 0)
- pthread_cond_broadcast(&COND_process_blocked);
- pthread_mutex_unlock(&THR_LOCK_DDL_blocker);
+ MYSQL_COND_BROADCAST(&COND_process_blocked);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_DDL_blocker);
DBUG_VOID_RETURN;
}
@@ -123,7 +123,7 @@ my_bool DDL_blocker_class::check_DDL_blo
/*
Check the ddl blocker condition. Rest until ddl blocker is released.
*/
- pthread_mutex_lock(&THR_LOCK_DDL_is_blocked);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_DDL_is_blocked);
thd->enter_cond(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked,
"DDL blocker: DDL is blocked");
while (DDL_blocked && !thd->DDL_exception && (ret == 0))
@@ -131,7 +131,7 @@ my_bool DDL_blocker_class::check_DDL_blo
if (thd->backup_wait_timeout == 0)
ret = -1;
else
- ret= pthread_cond_timedwait(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked,
+ ret= MYSQL_COND_TIMEDWAIT(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked,
&ddl_timeout);
}
thd->exit_cond("DDL blocker: DDL is not blocked");
@@ -170,11 +170,11 @@ my_bool DDL_blocker_class::block_DDL(THD
Check the blocker blocked condition.
Rest until another blocker is done.
*/
- pthread_mutex_lock(&THR_LOCK_DDL_blocker_blocked);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_DDL_blocker_blocked);
thd->enter_cond(&COND_DDL_blocker_blocked, &THR_LOCK_DDL_blocker_blocked,
"DDL blocker: Checking block on blocker");
while (DDL_blocked)
- pthread_cond_wait(&COND_DDL_blocker_blocked,
+ MYSQL_COND_WAIT(&COND_DDL_blocker_blocked,
&THR_LOCK_DDL_blocker_blocked);
DDL_blocked= TRUE;
thd->exit_cond("DDL blocker: Ok to block DDL");
@@ -182,11 +182,11 @@ my_bool DDL_blocker_class::block_DDL(THD
/*
Check the ddl blocker condition. Rest until ddl blocker is released.
*/
- pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_DDL_blocker);
thd->enter_cond(&COND_process_blocked, &THR_LOCK_DDL_blocker,
"DDL blocker: Checking block on DDL");
while (DDL_blocks != 0)
- pthread_cond_wait(&COND_process_blocked, &THR_LOCK_DDL_blocker);
+ MYSQL_COND_WAIT(&COND_process_blocked, &THR_LOCK_DDL_blocker);
thd->exit_cond("DDL blocker: DDL is now blocked");
DEBUG_SYNC(thd, "after_block_ddl");
@@ -201,10 +201,10 @@ my_bool DDL_blocker_class::block_DDL(THD
*/
void DDL_blocker_class::unblock_DDL()
{
- pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_DDL_blocker);
DDL_blocked= FALSE;
- pthread_cond_broadcast(&COND_DDL_blocker);
- pthread_cond_signal(&COND_DDL_blocker_blocked);
- pthread_mutex_unlock(&THR_LOCK_DDL_blocker);
+ MYSQL_COND_BROADCAST(&COND_DDL_blocker);
+ MYSQL_COND_SIGNAL(&COND_DDL_blocker_blocked);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_DDL_blocker);
}
=== modified file 'sql/ddl_blocker.h'
--- a/sql/ddl_blocker.h 2008-06-25 13:39:04 +0000
+++ b/sql/ddl_blocker.h 2008-10-10 20:34:55 +0000
@@ -110,13 +110,23 @@ class DDL_blocker_class
These variables are used to implement the metadata freeze "DDL blocker"
for online backup.
*/
- pthread_mutex_t THR_LOCK_DDL_blocker; ///< Mutex for blocking DDL
- pthread_mutex_t THR_LOCK_DDL_is_blocked; ///< Mutex for checking block DDL
- pthread_mutex_t THR_LOCK_DDL_blocker_blocked; ///< One blocker at a time
- pthread_cond_t COND_DDL_blocker; ///< cond for blocking DDL
- pthread_cond_t COND_process_blocked; ///< cond for checking block DDL
- pthread_cond_t COND_DDL_blocker_blocked; ///< cond for blocker blocked
+ mysql_mutex_t THR_LOCK_DDL_blocker; ///< Mutex for blocking DDL
+ mysql_mutex_t THR_LOCK_DDL_is_blocked; ///< Mutex for checking block DDL
+ mysql_mutex_t THR_LOCK_DDL_blocker_blocked; ///< One blocker at a time
+ mysql_cond_t COND_DDL_blocker; ///< cond for blocking DDL
+ mysql_cond_t COND_process_blocked; ///< cond for checking block DDL
+ mysql_cond_t COND_DDL_blocker_blocked; ///< cond for blocker blocked
my_bool DDL_blocked; ///< Is blocking operation running
int DDL_blocks; ///< Number of DDL operations in progress.
static DDL_blocker_class *m_instance; ///< instance var for singleton
};
+
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_THR_LOCK_DDL_blocker;
+extern PSI_mutex_key key_THR_LOCK_DDL_is_blocked;
+extern PSI_mutex_key key_THR_LOCK_DDL_blocker_blocked;
+extern PSI_cond_key key_COND_DDL_blocker;
+extern PSI_cond_key key_COND_process_blocked;
+extern PSI_cond_key key_COND_DDL_blocker_blocked;
+#endif
+
=== modified file 'sql/debug_sync.cc'
--- a/sql/debug_sync.cc 2008-09-08 09:25:46 +0000
+++ b/sql/debug_sync.cc 2008-10-10 20:34:55 +0000
@@ -240,6 +240,10 @@ struct st_debug_sync_control
ulonglong dsp_max_active; /* statistics */
};
+#ifdef HAVE_PSI_INTERFACE
+PSI_cond_key key_ds_cond;
+PSI_mutex_key key_ds_mutex;
+#endif
/**
Definitions for the debug sync facility.
@@ -250,8 +254,8 @@ struct st_debug_sync_control
struct st_debug_sync_globals
{
String ds_signal; /* signal variable */
- pthread_cond_t ds_cond; /* condition variable */
- pthread_mutex_t ds_mutex; /* mutex variable */
+ mysql_cond_t ds_cond; /* condition variable */
+ mysql_mutex_t ds_mutex; /* mutex variable */
ulonglong dsp_hits; /* statistics */
ulonglong dsp_executed; /* statistics */
ulonglong dsp_max_active; /* statistics */
@@ -336,9 +340,10 @@ int debug_sync_init(void)
/* Initialize the global variables. */
debug_sync_global.ds_signal.length(0);
- if ((rc= pthread_cond_init(&debug_sync_global.ds_cond, NULL)) ||
- (rc= pthread_mutex_init(&debug_sync_global.ds_mutex,
- MY_MUTEX_INIT_FAST)))
+ if ((rc= MYSQL_COND_INIT(&debug_sync_global.ds_cond, key_ds_cond, NULL)) ||
+ (rc= MYSQL_MUTEX_INIT(&debug_sync_global.ds_mutex,
+ key_ds_mutex,
+ MY_MUTEX_INIT_FAST)))
DBUG_RETURN(rc);
/* Set the call back pointer in thr_lock.c. */
@@ -369,8 +374,8 @@ void debug_sync_end(void)
/* Destroy the global variables. */
debug_sync_global.ds_signal.free();
- (void) pthread_cond_destroy(&debug_sync_global.ds_cond);
- (void) pthread_mutex_destroy(&debug_sync_global.ds_mutex);
+ (void) MYSQL_COND_DESTROY(&debug_sync_global.ds_cond);
+ (void) MYSQL_MUTEX_DESTROY(&debug_sync_global.ds_mutex);
/* Print statistics. */
{
@@ -472,12 +477,12 @@ void debug_sync_end_thread(THD *thd)
}
/* Statistics. */
- pthread_mutex_lock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_LOCK(&debug_sync_global.ds_mutex);
debug_sync_global.dsp_hits+= ds_control->dsp_hits;
debug_sync_global.dsp_executed+= ds_control->dsp_executed;
if (debug_sync_global.dsp_max_active < ds_control->dsp_max_active)
debug_sync_global.dsp_max_active= ds_control->dsp_max_active;
- pthread_mutex_unlock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_UNLOCK(&debug_sync_global.ds_mutex);
my_free(ds_control, MYF(0));
thd->debug_sync_control= NULL;
@@ -711,9 +716,9 @@ static void debug_sync_reset(THD *thd)
ds_control->ds_active= 0;
/* Clear the global signal. */
- pthread_mutex_lock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_LOCK(&debug_sync_global.ds_mutex);
debug_sync_global.ds_signal.length(0);
- pthread_mutex_unlock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_UNLOCK(&debug_sync_global.ds_mutex);
DBUG_VOID_RETURN;
}
@@ -1516,7 +1521,7 @@ uchar *sys_var_debug_sync::value_ptr(THD
static char on[]= "ON - current signal: '";
// Ensure exclusive access to debug_sync_global.ds_signal
- pthread_mutex_lock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_LOCK(&debug_sync_global.ds_mutex);
size_t lgt= (sizeof(on) /* includes '\0' */ +
debug_sync_global.ds_signal.length() + 1 /* for '\'' */);
@@ -1533,7 +1538,7 @@ uchar *sys_var_debug_sync::value_ptr(THD
*(vptr++)= '\'';
*vptr= '\0'; /* We have one byte reserved for the worst case. */
}
- pthread_mutex_unlock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_UNLOCK(&debug_sync_global.ds_mutex);
}
else
value= strmake_root(thd->mem_root, STRING_WITH_LEN("OFF"));
@@ -1595,7 +1600,7 @@ static void debug_sync_execute(THD *thd,
read access too, to create a memory barrier in order to avoid that
threads just reads an old cached version of the signal.
*/
- pthread_mutex_lock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_LOCK(&debug_sync_global.ds_mutex);
if (action->signal.length())
{
/* Copy the signal to the global variable. */
@@ -1608,15 +1613,15 @@ static void debug_sync_execute(THD *thd,
debug_sync_emergency_disable(); /* purecov: tested */
}
/* Wake threads waiting in a sync point. */
- pthread_cond_broadcast(&debug_sync_global.ds_cond);
+ MYSQL_COND_BROADCAST(&debug_sync_global.ds_cond);
DBUG_PRINT("debug_sync_exec", ("signal '%s' at: '%s'",
sig_emit, dsp_name));
} /* end if (action->signal.length()) */
if (action->wait_for.length())
{
- pthread_mutex_t *old_mutex;
- pthread_cond_t *old_cond;
+ mysql_mutex_t *old_mutex;
+ mysql_cond_t *old_cond;
int error= 0;
struct timespec abstime;
@@ -1647,7 +1652,7 @@ static void debug_sync_execute(THD *thd,
while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for)
&&
!thd->killed && opt_debug_sync_timeout)
{
- error= pthread_cond_timedwait(&debug_sync_global.ds_cond,
+ error= MYSQL_COND_TIMEDWAIT(&debug_sync_global.ds_cond,
&debug_sync_global.ds_mutex,
&abstime);
DBUG_EXECUTE("debug_sync", {
@@ -1675,18 +1680,18 @@ static void debug_sync_execute(THD *thd,
protected mutex must always unlocked _before_ mysys_var->mutex
is locked. (See comment in THD::exit_cond().)
*/
- pthread_mutex_unlock(&debug_sync_global.ds_mutex);
- pthread_mutex_lock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_LOCK(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= old_mutex;
thd->mysys_var->current_cond= old_cond;
thd_proc_info(thd, old_proc_info);
- pthread_mutex_unlock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&thd->mysys_var->mutex);
} /* end if (action->wait_for.length()) */
else
{
// Make sure to realease mutex also when there is no WAIT_FOR
- pthread_mutex_unlock(&debug_sync_global.ds_mutex);
+ MYSQL_MUTEX_UNLOCK(&debug_sync_global.ds_mutex);
}
} /* end if (action->execute) */
=== modified file 'sql/des_key_file.cc'
--- a/sql/des_key_file.cc 2008-04-09 00:56:49 +0000
+++ b/sql/des_key_file.cc 2008-10-10 20:34:55 +0000
@@ -43,7 +43,7 @@ load_des_key_file(const char *file_name)
DBUG_ENTER("load_des_key_file");
DBUG_PRINT("enter",("name: %s",file_name));
- pthread_mutex_lock(&LOCK_des_key_file);
+ MYSQL_MUTEX_LOCK(&LOCK_des_key_file);
if ((file=my_open(file_name,O_RDONLY | O_BINARY ,MYF(MY_WME))) < 0 ||
init_io_cache(&io, file, IO_SIZE*2, READ_CACHE, 0, 0, MYF(MY_WME)))
goto error;
@@ -96,7 +96,7 @@ error:
my_close(file,MYF(0));
end_io_cache(&io);
}
- pthread_mutex_unlock(&LOCK_des_key_file);
+ MYSQL_MUTEX_UNLOCK(&LOCK_des_key_file);
DBUG_RETURN(result);
}
#endif /* HAVE_OPENSSL */
=== modified file 'sql/event_queue.cc'
--- a/sql/event_queue.cc 2008-05-14 13:49:41 +0000
+++ b/sql/event_queue.cc 2008-10-10 20:34:55 +0000
@@ -95,16 +95,16 @@ Event_queue::Event_queue()
mutex_queue_data_attempting_lock(FALSE),
waiting_on_cond(FALSE)
{
- pthread_mutex_init(&LOCK_event_queue, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_queue_state, NULL);
+ MYSQL_MUTEX_INIT(&LOCK_event_queue, key_LOCK_event_queue, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_queue_state, key_COND_queue_state, NULL);
}
Event_queue::~Event_queue()
{
deinit_queue();
- pthread_mutex_destroy(&LOCK_event_queue);
- pthread_cond_destroy(&COND_queue_state);
+ MYSQL_MUTEX_DESTROY(&LOCK_event_queue);
+ MYSQL_COND_DESTROY(&COND_queue_state);
}
@@ -211,7 +211,7 @@ Event_queue::create_event(THD *thd, Even
LOCK_QUEUE_DATA();
*created= (queue_insert_safe(&queue, (uchar *) new_element) == FALSE);
dbug_dump_queue(thd->query_start());
- pthread_cond_broadcast(&COND_queue_state);
+ MYSQL_COND_BROADCAST(&COND_queue_state);
UNLOCK_QUEUE_DATA();
DBUG_RETURN(!*created);
@@ -259,7 +259,7 @@ Event_queue::update_event(THD *thd, LEX_
{
DBUG_PRINT("info", ("new event in the queue: %p", new_element));
queue_insert_safe(&queue, (uchar *) new_element);
- pthread_cond_broadcast(&COND_queue_state);
+ MYSQL_COND_BROADCAST(&COND_queue_state);
}
dbug_dump_queue(thd->query_start());
@@ -344,7 +344,7 @@ Event_queue::drop_matching_events(THD *t
i++;
}
/*
- We don't call pthread_cond_broadcast(&COND_queue_state);
+ We don't call MYSQL_COND_BROADCAST(&COND_queue_state);
If we remove the top event:
1. The queue is empty. The scheduler will wake up at some time and
realize that the queue is empty. If create_event() comes inbetween
@@ -677,7 +677,7 @@ Event_queue::lock_data(const char *func,
mutex_last_attempted_lock_in_func= func;
mutex_last_attempted_lock_at_line= line;
mutex_queue_data_attempting_lock= TRUE;
- pthread_mutex_lock(&LOCK_event_queue);
+ MYSQL_MUTEX_LOCK(&LOCK_event_queue);
mutex_last_attempted_lock_in_func= "";
mutex_last_attempted_lock_at_line= 0;
mutex_queue_data_attempting_lock= FALSE;
@@ -708,19 +708,19 @@ Event_queue::unlock_data(const char *fun
mutex_last_unlocked_at_line= line;
mutex_queue_data_locked= FALSE;
mutex_last_unlocked_in_func= func;
- pthread_mutex_unlock(&LOCK_event_queue);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_queue);
DBUG_VOID_RETURN;
}
/*
- Wrapper for pthread_cond_wait/timedwait
+ Wrapper for MYSQL_COND_WAIT/timedwait
SYNOPSIS
Event_queue::cond_wait()
thd Thread (Could be NULL during shutdown procedure)
msg Message for thd->proc_info
- abstime If not null then call pthread_cond_timedwait()
+ abstime If not null then call MYSQL_COND_TIMEDWAIT()
func Which function is requesting cond_wait
line On which line cond_wait is requested
*/
@@ -739,9 +739,9 @@ Event_queue::cond_wait(THD *thd, struct
DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
if (!abstime)
- pthread_cond_wait(&COND_queue_state, &LOCK_event_queue);
+ MYSQL_COND_WAIT(&COND_queue_state, &LOCK_event_queue);
else
- pthread_cond_timedwait(&COND_queue_state, &LOCK_event_queue, abstime);
+ MYSQL_COND_TIMEDWAIT(&COND_queue_state, &LOCK_event_queue, abstime);
mutex_last_locked_in_func= func;
mutex_last_locked_at_line= line;
=== modified file 'sql/event_queue.h'
--- a/sql/event_queue.h 2007-08-15 15:08:44 +0000
+++ b/sql/event_queue.h 2008-10-10 20:34:55 +0000
@@ -35,6 +35,11 @@ class THD;
Queue of active events awaiting execution.
*/
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_event_queue;
+extern PSI_cond_key key_COND_queue_state;
+#endif
+
class Event_queue
{
public:
@@ -101,8 +106,8 @@ private:
dbug_dump_queue(time_t now);
/* LOCK_event_queue is the mutex which protects the access to the queue. */
- pthread_mutex_t LOCK_event_queue;
- pthread_cond_t COND_queue_state;
+ mysql_mutex_t LOCK_event_queue;
+ mysql_cond_t COND_queue_state;
/* The sorted queue with the Event_queue_element objects */
QUEUE queue;
=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc 2008-05-08 16:01:15 +0000
+++ b/sql/event_scheduler.cc 2008-10-10 20:34:55 +0000
@@ -129,11 +129,11 @@ post_init_event_thread(THD *thd)
}
lex_start(thd);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
threads.append(thd);
thread_count++;
thread_running++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
return FALSE;
}
@@ -154,11 +154,11 @@ deinit_event_thread(THD *thd)
DBUG_ASSERT(thd->net.buff != 0);
net_end(&thd->net);
DBUG_PRINT("exit", ("Event thread finishing"));
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
thread_running--;
delete thd;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
@@ -190,9 +190,9 @@ pre_init_event_thread(THD* thd)
thd->slave_thread= 0;
thd->options|= OPTION_AUTO_IS_NULL;
thd->client_capabilities|= CLIENT_MULTI_RESULTS;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
/*
Guarantees that we will see the thread in SHOW PROCESSLIST though its
@@ -348,16 +348,16 @@ Event_scheduler::Event_scheduler(Event_q
waiting_on_cond(FALSE),
started_events(0)
{
- pthread_mutex_init(&LOCK_scheduler_state, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_state, NULL);
+ MYSQL_MUTEX_INIT(&LOCK_scheduler_state, key_LOCK_scheduler_state,
MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_state, key_Event_scheduler_COND_state, NULL);
}
Event_scheduler::~Event_scheduler()
{
stop(); /* does nothing if not running */
- pthread_mutex_destroy(&LOCK_scheduler_state);
- pthread_cond_destroy(&COND_state);
+ MYSQL_MUTEX_DESTROY(&LOCK_scheduler_state);
+ MYSQL_COND_DESTROY(&COND_state);
}
@@ -427,11 +427,11 @@ Event_scheduler::start()
THD_SET_PROC_INFO(new_thd, "Clearing");
DBUG_ASSERT(new_thd->net.buff != 0);
net_end(&new_thd->net);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
thread_running--;
delete new_thd;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
end:
UNLOCK_DATA();
@@ -499,7 +499,7 @@ Event_scheduler::run(THD *thd)
scheduler_thd= NULL;
state= INITIALIZED;
DBUG_PRINT("info", ("Signalling back to the stopper COND_state"));
- pthread_cond_signal(&COND_state);
+ MYSQL_COND_SIGNAL(&COND_state);
UNLOCK_DATA();
DBUG_RETURN(res);
@@ -559,11 +559,11 @@ error:
THD_SET_PROC_INFO(new_thd, "Clearing");
DBUG_ASSERT(new_thd->net.buff != 0);
net_end(&new_thd->net);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
thread_running--;
delete new_thd;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
delete event_name;
DBUG_RETURN(TRUE);
@@ -643,13 +643,13 @@ Event_scheduler::stop()
DBUG_PRINT("info", ("Scheduler thread has id %lu",
scheduler_thd->thread_id));
/* Lock from delete */
- pthread_mutex_lock(&scheduler_thd->LOCK_delete);
+ MYSQL_MUTEX_LOCK(&scheduler_thd->LOCK_delete);
/* This will wake up the thread if it waits on Queue's conditional */
sql_print_information("Event Scheduler: Killing the scheduler thread, "
"thread id %lu",
scheduler_thd->thread_id);
scheduler_thd->awake(THD::KILL_CONNECTION);
- pthread_mutex_unlock(&scheduler_thd->LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&scheduler_thd->LOCK_delete);
/* thd could be 0x0, when shutting down */
sql_print_information("Event Scheduler: "
@@ -678,12 +678,12 @@ Event_scheduler::workers_count()
uint count= 0;
DBUG_ENTER("Event_scheduler::workers_count");
- pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count); // For unlink from list
I_List_iterator<THD> it(threads);
while ((tmp=it++))
if (tmp->system_thread == SYSTEM_THREAD_EVENT_WORKER)
++count;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_PRINT("exit", ("%d", count));
DBUG_RETURN(count);
}
@@ -704,7 +704,7 @@ Event_scheduler::lock_data(const char *f
{
DBUG_ENTER("Event_scheduler::lock_data");
DBUG_PRINT("enter", ("func=%s line=%u", func, line));
- pthread_mutex_lock(&LOCK_scheduler_state);
+ MYSQL_MUTEX_LOCK(&LOCK_scheduler_state);
mutex_last_locked_in_func= func;
mutex_last_locked_at_line= line;
mutex_scheduler_data_locked= TRUE;
@@ -730,18 +730,18 @@ Event_scheduler::unlock_data(const char
mutex_last_unlocked_at_line= line;
mutex_scheduler_data_locked= FALSE;
mutex_last_unlocked_in_func= func;
- pthread_mutex_unlock(&LOCK_scheduler_state);
+ MYSQL_MUTEX_UNLOCK(&LOCK_scheduler_state);
DBUG_VOID_RETURN;
}
/*
- Wrapper for pthread_cond_wait/timedwait
+ Wrapper for MYSQL_COND_WAIT/timedwait
SYNOPSIS
Event_scheduler::cond_wait()
thd Thread (Could be NULL during shutdown procedure)
- abstime If not null then call pthread_cond_timedwait()
+ abstime If not null then call MYSQL_COND_TIMEDWAIT()
msg Message for thd->proc_info
func Which function is requesting cond_wait
line On which line cond_wait is requested
@@ -761,9 +761,9 @@ Event_scheduler::cond_wait(THD *thd, str
DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
if (!abstime)
- pthread_cond_wait(&COND_state, &LOCK_scheduler_state);
+ MYSQL_COND_WAIT(&COND_state, &LOCK_scheduler_state);
else
- pthread_cond_timedwait(&COND_state, &LOCK_scheduler_state, abstime);
+ MYSQL_COND_TIMEDWAIT(&COND_state, &LOCK_scheduler_state, abstime);
if (thd)
{
/*
=== modified file 'sql/event_scheduler.h'
--- a/sql/event_scheduler.h 2007-08-15 15:08:44 +0000
+++ b/sql/event_scheduler.h 2008-10-10 20:34:55 +0000
@@ -65,6 +65,10 @@ private:
static Event_db_repository *db_repository;
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_scheduler_state;
+extern PSI_cond_key key_Event_scheduler_COND_state;
+#endif
class Event_scheduler
{
@@ -115,7 +119,7 @@ private:
cond_wait(THD *thd, struct timespec *abstime, const char* msg,
const char *func, uint line);
- pthread_mutex_t LOCK_scheduler_state;
+ mysql_mutex_t LOCK_scheduler_state;
enum enum_state
{
@@ -129,7 +133,7 @@ private:
THD *scheduler_thd;
- pthread_cond_t COND_state;
+ mysql_cond_t COND_state;
Event_queue *queue;
=== modified file 'sql/events.cc'
--- a/sql/events.cc 2008-08-07 17:52:43 +0000
+++ b/sql/events.cc 2008-10-10 20:34:55 +0000
@@ -100,7 +100,7 @@ Event_scheduler *Events::scheduler;
Event_db_repository *Events::db_repository;
enum Events::enum_opt_event_scheduler
Events::opt_event_scheduler= Events::EVENTS_OFF;
-pthread_mutex_t Events::LOCK_event_metadata;
+mysql_mutex_t Events::LOCK_event_metadata;
bool Events::check_system_tables_error= FALSE;
@@ -181,9 +181,9 @@ Events::get_opt_event_scheduler_str()
{
const char *str;
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
str= opt_typelib.type_names[(int) opt_event_scheduler];
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
return str;
}
@@ -396,7 +396,7 @@ Events::create_event(THD *thd, Event_par
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
@@ -424,7 +424,7 @@ Events::create_event(THD *thd, Event_par
write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
}
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
DBUG_RETURN(ret);
}
@@ -505,7 +505,7 @@ Events::update_event(THD *thd, Event_par
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->update_event(thd, parse_data,
@@ -538,7 +538,7 @@ Events::update_event(THD *thd, Event_par
write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
}
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
DBUG_RETURN(ret);
}
@@ -588,7 +588,7 @@ Events::drop_event(THD *thd, LEX_STRING
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists)))
{
@@ -598,7 +598,7 @@ Events::drop_event(THD *thd, LEX_STRING
DBUG_ASSERT(thd->query && thd->query_length);
write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
DBUG_RETURN(ret);
}
@@ -627,11 +627,11 @@ Events::drop_schema_events(THD *thd, cha
are damaged, as intended.
*/
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
if (event_queue)
event_queue->drop_schema_events(thd, db_lex);
db_repository->drop_schema_events(thd, db_lex);
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
DBUG_VOID_RETURN;
}
@@ -965,7 +965,7 @@ Events::deinit()
void
Events::init_mutexes()
{
- pthread_mutex_init(&LOCK_event_metadata, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_event_metadata, key_LOCK_event_metadata,
MY_MUTEX_INIT_FAST);
}
@@ -979,7 +979,7 @@ Events::init_mutexes()
void
Events::destroy_mutexes()
{
- pthread_mutex_destroy(&LOCK_event_metadata);
+ MYSQL_MUTEX_DESTROY(&LOCK_event_metadata);
}
@@ -1001,7 +1001,7 @@ Events::dump_internal_status()
puts("LLA = Last Locked At LUA = Last Unlocked At");
puts("WOC = Waiting On Condition DL = Data Locked");
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
if (opt_event_scheduler == EVENTS_DISABLED)
puts("The Event Scheduler is disabled");
else
@@ -1010,7 +1010,7 @@ Events::dump_internal_status()
event_queue->dump_internal_status();
}
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
DBUG_VOID_RETURN;
}
@@ -1040,7 +1040,7 @@ Events::switch_event_scheduler_state(enu
if (check_if_system_tables_error())
DBUG_RETURN(TRUE);
- pthread_mutex_lock(&LOCK_event_metadata);
+ MYSQL_MUTEX_LOCK(&LOCK_event_metadata);
if (opt_event_scheduler == EVENTS_DISABLED)
{
@@ -1064,7 +1064,7 @@ Events::switch_event_scheduler_state(enu
opt_event_scheduler= new_state;
end:
- pthread_mutex_unlock(&LOCK_event_metadata);
+ MYSQL_MUTEX_UNLOCK(&LOCK_event_metadata);
DBUG_RETURN(ret);
}
=== modified file 'sql/events.h'
--- a/sql/events.h 2007-08-15 15:08:44 +0000
+++ b/sql/events.h 2008-10-10 20:34:55 +0000
@@ -67,6 +67,10 @@ sortcmp_lex_string(LEX_STRING s, LEX_STR
subsystems (ACL, time zone tables, etc).
*/
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_event_metadata;
+#endif
+
class Events
{
public:
@@ -142,7 +146,7 @@ private:
private:
/* Command line option names */
static const TYPELIB opt_typelib;
- static pthread_mutex_t LOCK_event_metadata;
+ static mysql_mutex_t LOCK_event_metadata;
static Event_queue *event_queue;
static Event_scheduler *scheduler;
static Event_db_repository *db_repository;
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2008-07-31 18:41:00 +0000
+++ b/sql/ha_ndbcluster.cc 2008-10-10 20:34:55 +0000
@@ -141,8 +141,12 @@ extern Ndb* g_ndb;
uchar g_node_id_map[max_ndb_nodes];
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_ndbcluster_mutex;
+#endif
+
/// Handler synchronization
-pthread_mutex_t ndbcluster_mutex;
+mysql_mutex_t ndbcluster_mutex;
/// Table lock handling
HASH ndbcluster_open_tables;
@@ -161,9 +165,16 @@ static int ndb_get_table_statistics(ha_n
// Util thread variables
pthread_t ndb_util_thread;
int ndb_util_thread_running= 0;
-pthread_mutex_t LOCK_ndb_util_thread;
-pthread_cond_t COND_ndb_util_thread;
-pthread_cond_t COND_ndb_util_ready;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_ndb_util_thread;
+PSI_cond_key key_COND_ndb_util_thread;
+PSI_cond_key key_COND_ndb_util_ready;
+#endif
+
+mysql_mutex_t LOCK_ndb_util_thread;
+mysql_cond_t COND_ndb_util_thread;
+mysql_cond_t COND_ndb_util_ready;
pthread_handler_t ndb_util_thread_func(void *arg);
ulong ndb_cache_check_time;
@@ -5027,11 +5038,11 @@ int ha_ndbcluster::external_lock(THD *th
thd_ndb->changed_tables.push_back(m_share, &thd->transaction.mem_root);
}
- pthread_mutex_lock(&m_share->mutex);
+ MYSQL_MUTEX_LOCK(&m_share->mutex);
DBUG_PRINT("info", ("Invalidating commit_count"));
m_share->commit_count= 0;
m_share->commit_count_lock++;
- pthread_mutex_unlock(&m_share->mutex);
+ MYSQL_MUTEX_UNLOCK(&m_share->mutex);
}
if (!--thd_ndb->lock_count)
@@ -5209,12 +5220,12 @@ static int ndbcluster_commit(handlerton
List_iterator_fast<NDB_SHARE> it(thd_ndb->changed_tables);
while ((share= it++))
{
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
DBUG_PRINT("info", ("Invalidate commit_count for %s, share->commit_count: %lu",
share->table_name, (ulong) share->commit_count));
share->commit_count= 0;
share->commit_count_lock++;
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
}
thd_ndb->changed_tables.empty();
@@ -6025,7 +6036,7 @@ int ha_ndbcluster::create(const char *na
if (!my_errno)
{
NDB_SHARE *share= 0;
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
/*
First make sure we get a "fresh" share here, not an old trailing one...
*/
@@ -6050,7 +6061,7 @@ int ha_ndbcluster::create(const char *na
DBUG_PRINT("NDB_SHARE", ("%s binlog create use_count: %u",
share->key, share->use_count));
}
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
while (!IS_TMP_PREFIX(m_tabname))
{
@@ -6651,7 +6662,7 @@ retry_temporary_error1:
/* the drop table failed for some reason, drop the share anyways */
if (share)
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
if (share->state != NSS_DROPPED)
{
/*
@@ -6667,7 +6678,7 @@ retry_temporary_error1:
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count));
free_share(&share, TRUE);
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
}
#endif
DBUG_RETURN(res);
@@ -6702,7 +6713,7 @@ retry_temporary_error1:
if (share)
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
if (share->state != NSS_DROPPED)
{
/*
@@ -6718,7 +6729,7 @@ retry_temporary_error1:
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count));
free_share(&share, TRUE);
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
}
#endif
DBUG_RETURN(0);
@@ -7417,7 +7428,7 @@ int ndbcluster_drop_database_impl(THD *t
while ((tabname=it++))
{
tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (ha_ndbcluster::delete_table(thd, 0, ndb, full_path, dbname, tabname))
{
const NdbError err= dict->getNdbError();
@@ -7427,7 +7438,7 @@ int ndbcluster_drop_database_impl(THD *t
ret= ndb_to_mysql_error(&err);
}
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
DBUG_RETURN(ret);
}
@@ -7580,7 +7591,7 @@ int ndbcluster_find_all_files(THD *thd)
my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (discover)
{
/* ToDo 4.1 database needs to be created if missing */
@@ -7598,7 +7609,7 @@ int ndbcluster_find_all_files(THD *thd)
TRUE);
}
#endif
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
}
while (unhandled && retries);
@@ -7689,19 +7700,19 @@ int ndbcluster_find_files(handlerton *ht
build_table_filename(name, sizeof(name), db, file_name->str, reg_ext, 0);
if (my_access(name, F_OK))
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
DBUG_PRINT("info", ("Table %s listed and need discovery",
file_name->str));
if (ndb_create_table_from_engine(thd, db, file_name->str))
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TABLE_EXISTS_ERROR,
"Discover of table %s.%s failed",
db, file_name->str);
continue;
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str));
file_on_disk= TRUE;
@@ -7757,10 +7768,10 @@ int ndbcluster_find_files(handlerton *ht
file_name_str= (char*)hash_element(&ok_tables, i);
end= end1 +
tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name));
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
ndbcluster_create_binlog_setup(thd, ndb, name, end-name,
db, file_name_str, TRUE);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
}
#endif
@@ -7824,7 +7835,7 @@ int ndbcluster_find_files(handlerton *ht
thd->restore_backup_open_tables_state(&open_tables_state_backup);
/* Lock mutex before creating .FRM files. */
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
/* Create new files. */
List_iterator_fast<char> it2(create_list);
while ((file_name_str=it2++))
@@ -7839,7 +7850,7 @@ int ndbcluster_find_files(handlerton *ht
}
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
hash_free(&ok_tables);
hash_free(&ndb_tables);
@@ -7873,7 +7884,7 @@ int ndbcluster_find_files(handlerton *ht
/* Call back after cluster connect */
static int connect_callback()
{
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
update_status_variables(&g_ndb_status,
g_ndb_cluster_connection);
@@ -7883,13 +7894,13 @@ static int connect_callback()
while ((node_id= g_ndb_cluster_connection->get_next_node(node_iter)))
g_node_id_map[node_id]= i++;
- pthread_cond_signal(&COND_ndb_util_thread);
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_COND_SIGNAL(&COND_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
return 0;
}
extern int ndb_dictionary_is_mysqld;
-extern pthread_mutex_t LOCK_plugin;
+extern mysql_mutex_t LOCK_plugin;
static int ndbcluster_init(void *p)
{
@@ -7903,12 +7914,12 @@ static int ndbcluster_init(void *p)
plugin initialization code. Release it to avoid deadlocks. It's safe, as
there're no threads that may concurrently access plugin control structures.
*/
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
- pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_ndb_util_thread, NULL);
- pthread_cond_init(&COND_ndb_util_ready, NULL);
+ MYSQL_MUTEX_INIT(&ndbcluster_mutex, key_ndbcluster_mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_ndb_util_thread, key_LOCK_ndb_util_thread,
MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_ndb_util_thread, key_COND_ndb_util_thread, NULL);
+ MYSQL_COND_INIT(&COND_ndb_util_ready, key_COND_ndb_util_ready, NULL);
ndb_util_thread_running= -1;
ndbcluster_terminating= 0;
ndb_dictionary_is_mysqld= 1;
@@ -7961,31 +7972,31 @@ static int ndbcluster_init(void *p)
{
DBUG_PRINT("error", ("Could not create ndb utility thread"));
hash_free(&ndbcluster_open_tables);
- pthread_mutex_destroy(&ndbcluster_mutex);
- pthread_mutex_destroy(&LOCK_ndb_util_thread);
- pthread_cond_destroy(&COND_ndb_util_thread);
- pthread_cond_destroy(&COND_ndb_util_ready);
+ MYSQL_MUTEX_DESTROY(&ndbcluster_mutex);
+ MYSQL_MUTEX_DESTROY(&LOCK_ndb_util_thread);
+ MYSQL_COND_DESTROY(&COND_ndb_util_thread);
+ MYSQL_COND_DESTROY(&COND_ndb_util_ready);
goto ndbcluster_init_error;
}
/* Wait for the util thread to start */
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
while (ndb_util_thread_running < 0)
- pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_COND_WAIT(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
if (!ndb_util_thread_running)
{
DBUG_PRINT("error", ("ndb utility thread exited prematurely"));
hash_free(&ndbcluster_open_tables);
- pthread_mutex_destroy(&ndbcluster_mutex);
- pthread_mutex_destroy(&LOCK_ndb_util_thread);
- pthread_cond_destroy(&COND_ndb_util_thread);
- pthread_cond_destroy(&COND_ndb_util_ready);
+ MYSQL_MUTEX_DESTROY(&ndbcluster_mutex);
+ MYSQL_MUTEX_DESTROY(&LOCK_ndb_util_thread);
+ MYSQL_COND_DESTROY(&COND_ndb_util_thread);
+ MYSQL_COND_DESTROY(&COND_ndb_util_ready);
goto ndbcluster_init_error;
}
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
ndbcluster_inited= 1;
DBUG_RETURN(FALSE);
@@ -7995,7 +8006,7 @@ ndbcluster_init_error:
ndbcluster_disconnect();
ndbcluster_hton->state= SHOW_OPTION_DISABLED; // If we couldn't use
handler
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
DBUG_RETURN(TRUE);
}
@@ -8010,17 +8021,17 @@ static int ndbcluster_end(handlerton *ht
/* wait for util thread to finish */
sql_print_information("Stopping Cluster Utility thread");
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
ndbcluster_terminating= 1;
- pthread_cond_signal(&COND_ndb_util_thread);
+ MYSQL_COND_SIGNAL(&COND_ndb_util_thread);
while (ndb_util_thread_running > 0)
- pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_COND_WAIT(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
#ifdef HAVE_NDB_BINLOG
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
while (ndbcluster_open_tables.records)
{
NDB_SHARE *share=
@@ -8031,7 +8042,7 @@ static int ndbcluster_end(handlerton *ht
#endif
ndbcluster_real_free_share(&share);
}
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
}
#endif
hash_free(&ndbcluster_open_tables);
@@ -8057,10 +8068,10 @@ static int ndbcluster_end(handlerton *ht
// cleanup ndb interface
ndb_end_internal();
- pthread_mutex_destroy(&ndbcluster_mutex);
- pthread_mutex_destroy(&LOCK_ndb_util_thread);
- pthread_cond_destroy(&COND_ndb_util_thread);
- pthread_cond_destroy(&COND_ndb_util_ready);
+ MYSQL_MUTEX_DESTROY(&ndbcluster_mutex);
+ MYSQL_MUTEX_DESTROY(&LOCK_ndb_util_thread);
+ MYSQL_COND_DESTROY(&COND_ndb_util_thread);
+ MYSQL_COND_DESTROY(&COND_ndb_util_ready);
DBUG_RETURN(0);
}
@@ -8361,12 +8372,12 @@ uint ndb_get_commitcount(THD *thd, char
build_table_filename(name, sizeof(name), dbname, tabname, "", 0);
DBUG_PRINT("enter", ("name: %s", name));
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables,
(uchar*) name,
strlen(name))))
{
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_PRINT("info", ("Table %s not found in ndbcluster_open_tables", name));
DBUG_RETURN(1);
}
@@ -8374,9 +8385,9 @@ uint ndb_get_commitcount(THD *thd, char
share->use_count++;
DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u",
share->key, share->use_count));
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
if (ndb_cache_check_time > 0)
{
if (share->commit_count != 0)
@@ -8387,7 +8398,7 @@ uint ndb_get_commitcount(THD *thd, char
#endif
DBUG_PRINT("info", ("Getting commit_count: %s from share",
llstr(share->commit_count, buff)));
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
/* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count));
@@ -8404,7 +8415,7 @@ uint ndb_get_commitcount(THD *thd, char
ERR_RETURN(ndb->getNdbError());
}
uint lock= share->commit_count_lock;
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
struct Ndb_statistics stat;
{
@@ -8420,7 +8431,7 @@ uint ndb_get_commitcount(THD *thd, char
}
}
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
if (share->commit_count_lock == lock)
{
#ifndef DBUG_OFF
@@ -8436,7 +8447,7 @@ uint ndb_get_commitcount(THD *thd, char
DBUG_PRINT("info", ("Discarding commit_count, comit_count_lock changed"));
*commit_count= 0;
}
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
/* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count));
@@ -8659,7 +8670,7 @@ static void print_ndbcluster_open_tables
to avoid segmentation faults. There is a risk that the memory for
this trailing share leaks.
- Must be called with previous pthread_mutex_lock(&ndbcluster_mutex)
+ Must be called with previous MYSQL_MUTEX_LOCK(&ndbcluster_mutex)
*/
int handle_trailing_share(THD *thd, NDB_SHARE *share, int have_lock_open)
{
@@ -8672,21 +8683,21 @@ int handle_trailing_share(THD *thd, NDB_
sql_print_information ("handle_trailing_share: %s use_count: %u", share->key,
share->use_count);
DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u",
share->key, share->use_count));
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
TABLE_LIST table_list;
bzero((char*) &table_list,sizeof(table_list));
table_list.db= share->db;
table_list.alias= table_list.table_name= share->table_name;
if (have_lock_open)
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
else
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
close_cached_tables(thd, &table_list, TRUE, FALSE);
if (!have_lock_open)
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
/* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
share->key, share->use_count));
@@ -8802,7 +8813,7 @@ int ndbcluster_undo_rename_share(THD *th
int ndbcluster_rename_share(THD *thd, NDB_SHARE *share, int have_lock_open)
{
NDB_SHARE *tmp;
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
uint new_length= (uint) strlen(share->new_key);
DBUG_PRINT("ndbcluster_rename_share", ("old_key: %s old__length: %d",
share->key, share->key_length));
@@ -8835,7 +8846,7 @@ int ndbcluster_rename_share(THD *thd, ND
share->key));
}
dbug_print_open_tables();
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
return -1;
}
dbug_print_open_tables();
@@ -8865,7 +8876,7 @@ int ndbcluster_rename_share(THD *thd, ND
if (ndb_extra_logging > 9)
sql_print_information ("ndbcluster_rename_share: %s-%s use_count: %u", old_key,
share->key, share->use_count);
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
return 0;
}
#endif
@@ -8876,14 +8887,14 @@ int ndbcluster_rename_share(THD *thd, ND
*/
NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share)
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
share->use_count++;
dbug_print_open_tables();
dbug_print_share("ndbcluster_get_share:", share);
if (ndb_extra_logging > 9)
sql_print_information ("ndbcluster_get_share: %s use_count: %u", share->key,
share->use_count);
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
return share;
}
@@ -8900,7 +8911,7 @@ NDB_SHARE *ndbcluster_get_share(NDB_SHAR
create_if_not_exists == FALSE:
returns 0 if share does not exist
- have_lock == TRUE, pthread_mutex_lock(&ndbcluster_mutex) already taken
+ have_lock == TRUE, MYSQL_MUTEX_LOCK(&ndbcluster_mutex) already taken
*/
NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
@@ -8913,7 +8924,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
DBUG_PRINT("enter", ("key: '%s'", key));
if (!have_lock)
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
if (!(share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
(uchar*) key,
length)))
@@ -8922,7 +8933,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
{
DBUG_PRINT("error", ("get_share: %s does not exist", key));
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(0);
}
if ((share= (NDB_SHARE*) my_malloc(sizeof(*share),
@@ -8944,11 +8955,11 @@ NDB_SHARE *ndbcluster_get_share(const ch
my_free((uchar*) share, 0);
*root_ptr= old_root;
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(0);
}
thr_lock_init(&share->lock);
- pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&share->mutex, key_NDB_SHARE_mutex, MY_MUTEX_INIT_FAST);
share->commit_count= 0;
share->commit_count_lock= 0;
share->db= share->key + length + 1;
@@ -8962,7 +8973,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
ndbcluster_real_free_share(&share);
*root_ptr= old_root;
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(0);
}
#endif
@@ -8972,7 +8983,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
{
DBUG_PRINT("error", ("get_share: failed to alloc share"));
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*share));
DBUG_RETURN(0);
}
@@ -8984,7 +8995,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
dbug_print_open_tables();
dbug_print_share("ndbcluster_get_share:", share);
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(share);
}
@@ -8999,7 +9010,7 @@ void ndbcluster_real_free_share(NDB_SHAR
hash_delete(&ndbcluster_open_tables, (uchar*) *share);
thr_lock_delete(&(*share)->lock);
- pthread_mutex_destroy(&(*share)->mutex);
+ MYSQL_MUTEX_DESTROY(&(*share)->mutex);
#ifdef HAVE_NDB_BINLOG
(*share)->new_op= 0;
@@ -9021,7 +9032,7 @@ void ndbcluster_real_free_share(NDB_SHAR
void ndbcluster_free_share(NDB_SHARE **share, bool have_lock)
{
if (!have_lock)
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
if (!--(*share)->use_count)
{
if (ndb_extra_logging > 9)
@@ -9036,7 +9047,7 @@ void ndbcluster_free_share(NDB_SHARE **s
dbug_print_share("ndbcluster_free_share:", *share);
}
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
}
@@ -9067,16 +9078,16 @@ int ha_ndbcluster::update_stats(THD *thd
}
if (m_share)
{
- pthread_mutex_lock(&m_share->mutex);
+ MYSQL_MUTEX_LOCK(&m_share->mutex);
m_share->stat= stat;
- pthread_mutex_unlock(&m_share->mutex);
+ MYSQL_MUTEX_UNLOCK(&m_share->mutex);
}
}
else
{
- pthread_mutex_lock(&m_share->mutex);
+ MYSQL_MUTEX_LOCK(&m_share->mutex);
stat= m_share->stat;
- pthread_mutex_unlock(&m_share->mutex);
+ MYSQL_MUTEX_UNLOCK(&m_share->mutex);
}
struct Ndb_local_table_statistics *local_info= m_table_info;
int no_uncommitted_rows_count;
@@ -9993,7 +10004,7 @@ pthread_handler_t ndb_util_thread_func(v
DBUG_ENTER("ndb_util_thread");
DBUG_PRINT("enter", ("ndb_cache_check_time: %lu", ndb_cache_check_time));
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
thd= new THD; /* note that contructor of THD uses DBUG_ */
if (thd == NULL)
@@ -10027,45 +10038,45 @@ pthread_handler_t ndb_util_thread_func(v
/* Signal successful initialization */
ndb_util_thread_running= 1;
- pthread_cond_signal(&COND_ndb_util_ready);
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_COND_SIGNAL(&COND_ndb_util_ready);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
/*
wait for mysql server to start
*/
- pthread_mutex_lock(&LOCK_server_started);
+ MYSQL_MUTEX_LOCK(&LOCK_server_started);
while (!mysqld_server_started)
{
set_timespec(abstime, 1);
- pthread_cond_timedwait(&COND_server_started, &LOCK_server_started,
+ MYSQL_COND_TIMEDWAIT(&COND_server_started, &LOCK_server_started,
&abstime);
if (ndbcluster_terminating)
{
- pthread_mutex_unlock(&LOCK_server_started);
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_server_started);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
goto ndb_util_thread_end;
}
}
- pthread_mutex_unlock(&LOCK_server_started);
+ MYSQL_MUTEX_UNLOCK(&LOCK_server_started);
/*
Wait for cluster to start
*/
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
while (!g_ndb_status.cluster_node_id && (ndbcluster_hton->slot != ~(uint)0))
{
/* ndb not connected yet */
- pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread);
+ MYSQL_COND_WAIT(&COND_ndb_util_thread, &LOCK_ndb_util_thread);
if (ndbcluster_terminating)
goto ndb_util_thread_end;
}
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
/* Get thd_ndb for this thread */
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
{
sql_print_error("Could not allocate Thd_ndb object");
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
goto ndb_util_thread_end;
}
set_thd_ndb(thd, thd_ndb);
@@ -10086,14 +10097,14 @@ pthread_handler_t ndb_util_thread_func(v
set_timespec(abstime, 0);
for (;;)
{
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
if (!ndbcluster_terminating)
- pthread_cond_timedwait(&COND_ndb_util_thread,
+ MYSQL_COND_TIMEDWAIT(&COND_ndb_util_thread,
&LOCK_ndb_util_thread,
&abstime);
if (ndbcluster_terminating) /* Shutting down server */
goto ndb_util_thread_end;
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
#ifdef NDB_EXTRA_DEBUG_UTIL_THREAD
DBUG_PRINT("ndb_util_thread", ("Started, ndb_cache_check_time: %lu",
ndb_cache_check_time));
@@ -10118,7 +10129,7 @@ pthread_handler_t ndb_util_thread_func(v
/* Lock mutex and fill list with pointers to all open tables */
NDB_SHARE *share;
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
uint i, open_count, record_count= ndbcluster_open_tables.records;
if (share_list_size < record_count)
{
@@ -10127,7 +10138,7 @@ pthread_handler_t ndb_util_thread_func(v
{
sql_print_warning("ndb util thread: malloc failure, "
"query cache not maintained properly");
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
goto next; // At least do not crash
}
delete [] share_list;
@@ -10153,7 +10164,7 @@ pthread_handler_t ndb_util_thread_func(v
/* Store pointer to table */
share_list[open_count++]= share;
}
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
/* Iterate through the open files list */
for (i= 0; i < open_count; i++)
@@ -10178,9 +10189,9 @@ pthread_handler_t ndb_util_thread_func(v
struct Ndb_statistics stat;
uint lock;
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
lock= share->commit_count_lock;
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
{
/* Contact NDB to get commit count for table */
Ndb* ndb= thd_ndb->ndb;
@@ -10211,10 +10222,10 @@ pthread_handler_t ndb_util_thread_func(v
}
}
loop_next:
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
if (share->commit_count_lock == lock)
share->commit_count= stat.commit_count;
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
/* ndb_share reference temporary free */
DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
@@ -10244,7 +10255,7 @@ next:
}
}
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
ndb_util_thread_end:
net_end(&thd->net);
@@ -10256,8 +10267,8 @@ ndb_util_thread_fail:
/* signal termination */
ndb_util_thread_running= 0;
- pthread_cond_signal(&COND_ndb_util_ready);
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_COND_SIGNAL(&COND_ndb_util_ready);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
DBUG_PRINT("exit", ("ndb_util_thread"));
my_thread_end();
pthread_exit(0);
=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h 2008-06-05 16:11:22 +0000
+++ b/sql/ha_ndbcluster.h 2008-10-10 20:34:55 +0000
@@ -138,11 +138,15 @@ struct Ndb_statistics {
Uint64 fragment_memory;
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_NDB_SHARE_mutex;
+#endif
+
typedef struct st_ndbcluster_share {
NDB_SHARE_STATE state;
MEM_ROOT mem_root;
THR_LOCK lock;
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
char *key;
uint key_length;
char *new_key;
@@ -169,9 +173,9 @@ NDB_SHARE_STATE
get_ndb_share_state(NDB_SHARE *share)
{
NDB_SHARE_STATE state;
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
state= share->state;
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
return state;
}
@@ -179,19 +183,19 @@ inline
void
set_ndb_share_state(NDB_SHARE *share, NDB_SHARE_STATE state)
{
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
share->state= state;
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
}
struct Ndb_tuple_id_range_guard {
Ndb_tuple_id_range_guard(NDB_SHARE* _share) :
share(_share),
range(share->tuple_id_range) {
- pthread_mutex_lock(&share->mutex);
+ MYSQL_MUTEX_LOCK(&share->mutex);
}
~Ndb_tuple_id_range_guard() {
- pthread_mutex_unlock(&share->mutex);
+ MYSQL_MUTEX_UNLOCK(&share->mutex);
}
NDB_SHARE* share;
Ndb::TupleIdRange& range;
@@ -762,4 +766,4 @@ static const char ndbcluster_hton_name[]
static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1;
extern int ndbcluster_terminating;
extern int ndb_util_thread_running;
-extern pthread_cond_t COND_ndb_util_ready;
+extern mysql_cond_t COND_ndb_util_ready;
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2008-07-14 12:49:19 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2008-10-10 20:34:55 +0000
@@ -82,7 +82,7 @@ THD *injector_thd= 0;
to enable ndb injector thread receiving events.
Must therefore always be used with a surrounding
- pthread_mutex_lock(&injector_mutex), when doing create/dropEventOperation
+ MYSQL_MUTEX_LOCK(&injector_mutex), when doing create/dropEventOperation
*/
static Ndb *injector_ndb= 0;
static Ndb *schema_ndb= 0;
@@ -109,8 +109,14 @@ static int ndbcluster_binlog_terminating
and injector thread
*/
pthread_t ndb_binlog_thread;
-pthread_mutex_t injector_mutex;
-pthread_cond_t injector_cond;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_injector_mutex;
+PSI_cond_key key_injector_cond;
+#endif
+
+mysql_mutex_t injector_mutex;
+mysql_cond_t injector_cond;
/* NDB Injector thread (used for binlog creation) */
static ulonglong ndb_latest_applied_binlog_epoch= 0;
@@ -119,15 +125,24 @@ static ulonglong ndb_latest_received_bin
NDB_SHARE *ndb_apply_status_share= 0;
NDB_SHARE *ndb_schema_share= 0;
-pthread_mutex_t ndb_schema_share_mutex;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_ndb_schema_share_mutex;
+#endif
+mysql_mutex_t ndb_schema_share_mutex;
extern my_bool opt_log_slave_updates;
static my_bool g_ndb_log_slave_updates;
/* Schema object distribution handling */
HASH ndb_schema_objects;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_NSO_mutex;
+#endif
+
typedef struct st_ndb_schema_object {
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
char *key;
uint key_length;
uint use_count;
@@ -368,7 +383,7 @@ ndbcluster_binlog_open_table(THD *thd, N
TABLE *table= event_data->table=
(TABLE*)alloc_root(&event_data->mem_root, sizeof(TABLE));
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
init_tmp_table_share(thd, table_share, share->db, 0, share->table_name,
share->key);
if ((error= open_table_def(thd, table_share, 0)) ||
@@ -493,7 +508,7 @@ static void ndbcluster_binlog_wait(THD *
if (thd)
THD_SET_PROC_INFO(thd,
"Waiting for ndbcluster binlog update to reach current position");
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
while (!thd->killed && count && ndb_binlog_running &&
(ndb_latest_handled_binlog_epoch == 0 ||
ndb_latest_handled_binlog_epoch < wait_epoch))
@@ -501,9 +516,9 @@ static void ndbcluster_binlog_wait(THD *
count--;
struct timespec abstime;
set_timespec(abstime, 1);
- pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime);
+ MYSQL_COND_TIMEDWAIT(&injector_cond, &injector_mutex, &abstime);
}
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
if (thd)
THD_SET_PROC_INFO(thd, save_info);
DBUG_VOID_RETURN;
@@ -633,28 +648,28 @@ static int ndbcluster_binlog_end(THD *th
however be a likely case as the ndbcluster_binlog_end is supposed to
be called before ndb_cluster_end().
*/
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
/* Ensure mutex are not freed if ndb_cluster_end is running at same time */
ndb_util_thread_running++;
ndbcluster_terminating= 1;
- pthread_cond_signal(&COND_ndb_util_thread);
+ MYSQL_COND_SIGNAL(&COND_ndb_util_thread);
while (ndb_util_thread_running > 1)
- pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
+ MYSQL_COND_WAIT(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
ndb_util_thread_running--;
- pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_ndb_util_thread);
}
/* wait for injector thread to finish */
ndbcluster_binlog_terminating= 1;
- pthread_mutex_lock(&injector_mutex);
- pthread_cond_signal(&injector_cond);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
+ MYSQL_COND_SIGNAL(&injector_cond);
while (ndb_binlog_thread_running > 0)
- pthread_cond_wait(&injector_cond, &injector_mutex);
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_COND_WAIT(&injector_cond, &injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
- pthread_mutex_destroy(&injector_mutex);
- pthread_cond_destroy(&injector_cond);
- pthread_mutex_destroy(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_DESTROY(&injector_mutex);
+ MYSQL_COND_DESTROY(&injector_cond);
+ MYSQL_MUTEX_DESTROY(&ndb_schema_share_mutex);
#endif
DBUG_RETURN(0);
@@ -734,14 +749,14 @@ void ndbcluster_binlog_init_handlerton()
*/
static NDB_SHARE *ndbcluster_check_ndb_apply_status_share()
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
void *share= hash_search(&ndbcluster_open_tables,
(uchar*) NDB_APPLY_TABLE_FILE,
sizeof(NDB_APPLY_TABLE_FILE) - 1);
DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s %p",
NDB_APPLY_TABLE_FILE, share));
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
return (NDB_SHARE*) share;
}
@@ -752,14 +767,14 @@ static NDB_SHARE *ndbcluster_check_ndb_a
*/
static NDB_SHARE *ndbcluster_check_ndb_schema_share()
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
void *share= hash_search(&ndbcluster_open_tables,
(uchar*) NDB_SCHEMA_TABLE_FILE,
sizeof(NDB_SCHEMA_TABLE_FILE) - 1);
DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s %p",
NDB_SCHEMA_TABLE_FILE, share));
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
return (NDB_SHARE*) share;
}
@@ -885,9 +900,9 @@ int ndbcluster_setup_binlog_table_shares
if (!ndb_schema_share &&
ndbcluster_check_ndb_schema_share() == 0)
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_SCHEMA_TABLE);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (!ndb_schema_share)
{
ndbcluster_create_schema_table(thd);
@@ -899,9 +914,9 @@ int ndbcluster_setup_binlog_table_shares
if (!ndb_apply_status_share &&
ndbcluster_check_ndb_apply_status_share() == 0)
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_APPLY_TABLE);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (!ndb_apply_status_share)
{
ndbcluster_create_ndb_apply_status_table(thd);
@@ -912,7 +927,7 @@ int ndbcluster_setup_binlog_table_shares
if (!ndbcluster_find_all_files(thd))
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
ndb_binlog_tables_inited= TRUE;
if (ndb_binlog_tables_inited &&
ndb_binlog_running && ndb_binlog_is_ready)
@@ -921,9 +936,9 @@ int ndbcluster_setup_binlog_table_shares
sql_print_information("NDB Binlog: ndb tables writable");
close_cached_tables(NULL, NULL, TRUE, FALSE);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/* Signal injector thread that all is setup */
- pthread_cond_signal(&injector_cond);
+ MYSQL_COND_SIGNAL(&injector_cond);
}
return 0;
}
@@ -1219,12 +1234,12 @@ static void ndb_report_waiting(const cha
{
ulonglong ndb_latest_epoch= 0;
const char *proc_info= "<no info>";
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
if (injector_ndb)
ndb_latest_epoch= injector_ndb->getLatestGCI();
if (injector_thd)
proc_info= injector_thd->proc_info;
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
sql_print_information("NDB %s:"
" waiting max %u sec for %s %s."
" epochs: (%u/%u,%u/%u,%u/%u)"
@@ -1354,15 +1369,15 @@ int ndbcluster_log_schema_op(THD *thd,
bitmap_set_all(&schema_subscribers);
/* begin protect ndb_schema_share */
- pthread_mutex_lock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_LOCK(&ndb_schema_share_mutex);
if (ndb_schema_share == 0)
{
- pthread_mutex_unlock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_share_mutex);
if (ndb_schema_object)
ndb_free_schema_object(&ndb_schema_object, FALSE);
DBUG_RETURN(0);
}
- (void) pthread_mutex_lock(&ndb_schema_share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&ndb_schema_share->mutex);
for (i= 0; i < no_storage_nodes; i++)
{
MY_BITMAP *table_subscribers= &ndb_schema_share->subscriber_bitmap[i];
@@ -1373,8 +1388,8 @@ int ndbcluster_log_schema_op(THD *thd,
updated= 1;
}
}
- (void) pthread_mutex_unlock(&ndb_schema_share->mutex);
- pthread_mutex_unlock(&ndb_schema_share_mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&ndb_schema_share->mutex);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */
if (updated)
@@ -1397,10 +1412,10 @@ int ndbcluster_log_schema_op(THD *thd,
if (ndb_schema_object)
{
- (void) pthread_mutex_lock(&ndb_schema_object->mutex);
+ (void) MYSQL_MUTEX_LOCK(&ndb_schema_object->mutex);
memcpy(ndb_schema_object->slock, schema_subscribers.bitmap,
sizeof(ndb_schema_object->slock));
- (void) pthread_mutex_unlock(&ndb_schema_object->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&ndb_schema_object->mutex);
}
DBUG_DUMP("schema_subscribers", (uchar*)schema_subscribers.bitmap,
@@ -1568,11 +1583,11 @@ end:
ndbcluster_update_slock(thd, db, table_name);
}
int max_timeout= opt_ndb_sync_timeout;
- (void) pthread_mutex_lock(&ndb_schema_object->mutex);
+ (void) MYSQL_MUTEX_LOCK(&ndb_schema_object->mutex);
if (have_lock_open)
{
- safe_mutex_assert_owner(&LOCK_open);
- (void) pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
while (1)
{
@@ -1580,20 +1595,20 @@ end:
int i;
int no_storage_nodes= g_ndb_cluster_connection->no_db_nodes();
set_timespec(abstime, 1);
- int ret= pthread_cond_timedwait(&injector_cond,
+ int ret= MYSQL_COND_TIMEDWAIT(&injector_cond,
&ndb_schema_object->mutex,
&abstime);
if (thd->killed)
break;
/* begin protect ndb_schema_share */
- pthread_mutex_lock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_LOCK(&ndb_schema_share_mutex);
if (ndb_schema_share == 0)
{
- pthread_mutex_unlock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_share_mutex);
break;
}
- (void) pthread_mutex_lock(&ndb_schema_share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&ndb_schema_share->mutex);
for (i= 0; i < no_storage_nodes; i++)
{
/* remove any unsubscribed from schema_subscribers */
@@ -1601,8 +1616,8 @@ end:
if (!bitmap_is_clear_all(tmp))
bitmap_intersect(&schema_subscribers, tmp);
}
- (void) pthread_mutex_unlock(&ndb_schema_share->mutex);
- pthread_mutex_unlock(&ndb_schema_share_mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&ndb_schema_share->mutex);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */
/* remove any unsubscribed from ndb_schema_object->slock */
@@ -1631,9 +1646,9 @@ end:
}
if (have_lock_open)
{
- (void) pthread_mutex_lock(&LOCK_open);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_open);
}
- (void) pthread_mutex_unlock(&ndb_schema_object->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&ndb_schema_object->mutex);
}
if (ndb_schema_object)
@@ -1675,7 +1690,7 @@ ndb_handle_schema_change(THD *thd, Ndb *
ndbtab_g.invalidate();
}
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
DBUG_ASSERT(share->state == NSS_DROPPED ||
share->op == pOp || share->new_op == pOp);
if (share->new_op)
@@ -1689,10 +1704,10 @@ ndb_handle_schema_change(THD *thd, Ndb *
// either just us or drop table handling as well
/* Signal ha_ndbcluster::delete/rename_table that drop is done */
- (void) pthread_mutex_unlock(&share->mutex);
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
/* ndb_share reference binlog free */
DBUG_PRINT("NDB_SHARE", ("%s binlog free use_count: %u",
share->key, share->use_count));
@@ -1718,7 +1733,7 @@ ndb_handle_schema_change(THD *thd, Ndb *
}
else
share= 0;
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
if (event_data)
{
@@ -1726,10 +1741,10 @@ ndb_handle_schema_change(THD *thd, Ndb *
pOp->setCustomData(NULL);
}
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
ndb->dropEventOperation(pOp);
pOp= 0;
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
if (do_close_cached_tables)
{
@@ -1882,7 +1897,7 @@ ndb_binlog_thread_handle_schema_event(TH
}
// fall through
case SOT_CREATE_TABLE:
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (ndbcluster_check_if_local_table(schema->db, schema->name))
{
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
@@ -1904,7 +1919,7 @@ ndb_binlog_thread_handle_schema_event(TH
while ((err= it++))
sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
log_query= 1;
break;
case SOT_DROP_DB:
@@ -1993,7 +2008,7 @@ ndb_binlog_thread_handle_schema_event(TH
"read only on reconnect.");
/* begin protect ndb_schema_share */
- pthread_mutex_lock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_LOCK(&ndb_schema_share_mutex);
/* ndb_share reference binlog extra free */
DBUG_PRINT("NDB_SHARE", ("%s binlog extra free use_count: %u",
ndb_schema_share->key,
@@ -2002,7 +2017,7 @@ ndb_binlog_thread_handle_schema_event(TH
ndb_schema_share= 0;
ndb_binlog_tables_inited= FALSE;
ndb_binlog_is_ready= FALSE;
- pthread_mutex_unlock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */
close_cached_tables(NULL, NULL, FALSE, FALSE);
@@ -2014,7 +2029,7 @@ ndb_binlog_thread_handle_schema_event(TH
{
uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()];
DBUG_ASSERT(node_id != 0xFF);
- (void) pthread_mutex_lock(&tmp_share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&tmp_share->mutex);
bitmap_clear_all(&tmp_share->subscriber_bitmap[node_id]);
DBUG_PRINT("info",("NODE_FAILURE UNSUBSCRIBE[%d]", node_id));
if (ndb_extra_logging)
@@ -2025,8 +2040,8 @@ ndb_binlog_thread_handle_schema_event(TH
tmp_share->subscriber_bitmap[node_id].bitmap[1],
tmp_share->subscriber_bitmap[node_id].bitmap[0]);
}
- (void) pthread_mutex_unlock(&tmp_share->mutex);
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_MUTEX_UNLOCK(&tmp_share->mutex);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
break;
}
case NDBEVENT::TE_SUBSCRIBE:
@@ -2034,7 +2049,7 @@ ndb_binlog_thread_handle_schema_event(TH
uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()];
uint8 req_id= pOp->getReqNodeId();
DBUG_ASSERT(req_id != 0 && node_id != 0xFF);
- (void) pthread_mutex_lock(&tmp_share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&tmp_share->mutex);
bitmap_set_bit(&tmp_share->subscriber_bitmap[node_id], req_id);
DBUG_PRINT("info",("SUBSCRIBE[%d] %d", node_id, req_id));
if (ndb_extra_logging)
@@ -2046,8 +2061,8 @@ ndb_binlog_thread_handle_schema_event(TH
tmp_share->subscriber_bitmap[node_id].bitmap[1],
tmp_share->subscriber_bitmap[node_id].bitmap[0]);
}
- (void) pthread_mutex_unlock(&tmp_share->mutex);
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_MUTEX_UNLOCK(&tmp_share->mutex);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
break;
}
case NDBEVENT::TE_UNSUBSCRIBE:
@@ -2055,7 +2070,7 @@ ndb_binlog_thread_handle_schema_event(TH
uint8 node_id= g_node_id_map[pOp->getNdbdNodeId()];
uint8 req_id= pOp->getReqNodeId();
DBUG_ASSERT(req_id != 0 && node_id != 0xFF);
- (void) pthread_mutex_lock(&tmp_share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&tmp_share->mutex);
bitmap_clear_bit(&tmp_share->subscriber_bitmap[node_id], req_id);
DBUG_PRINT("info",("UNSUBSCRIBE[%d] %d", node_id, req_id));
if (ndb_extra_logging)
@@ -2067,8 +2082,8 @@ ndb_binlog_thread_handle_schema_event(TH
tmp_share->subscriber_bitmap[node_id].bitmap[1],
tmp_share->subscriber_bitmap[node_id].bitmap[0]);
}
- (void) pthread_mutex_unlock(&tmp_share->mutex);
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_MUTEX_UNLOCK(&tmp_share->mutex);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
break;
}
default:
@@ -2108,22 +2123,22 @@ ndb_binlog_thread_handle_schema_event_po
build_table_filename(key, sizeof(key), schema->db, schema->name, "", 0);
if (schema_type == SOT_CLEAR_SLOCK)
{
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
NDB_SCHEMA_OBJECT *ndb_schema_object=
(NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects,
(uchar*) key, strlen(key));
if (ndb_schema_object)
{
- pthread_mutex_lock(&ndb_schema_object->mutex);
+ MYSQL_MUTEX_LOCK(&ndb_schema_object->mutex);
memcpy(ndb_schema_object->slock, schema->slock,
sizeof(ndb_schema_object->slock));
DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap",
(uchar*)ndb_schema_object->slock_bitmap.bitmap,
no_bytes_in_map(&ndb_schema_object->slock_bitmap));
- pthread_mutex_unlock(&ndb_schema_object->mutex);
- pthread_cond_signal(&injector_cond);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_object->mutex);
+ MYSQL_COND_SIGNAL(&injector_cond);
}
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
continue;
}
/* ndb_share reference temporary, free below */
@@ -2176,7 +2191,7 @@ ndb_binlog_thread_handle_schema_event_po
{
if (ndb_extra_logging > 9)
sql_print_information("NDB Binlog: renaming files start");
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
char from[FN_REFLEN];
char to[FN_REFLEN];
strxnmov(from, FN_REFLEN-1, share->key, NullS);
@@ -2184,7 +2199,7 @@ ndb_binlog_thread_handle_schema_event_po
strxnmov(to, FN_REFLEN-1, share->key, NullS);
rename_file_ext(from, to, ".ndb");
rename_file_ext(from, to, ".frm");
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (ndb_extra_logging > 9)
sql_print_information("NDB Binlog: renaming files done");
}
@@ -2243,7 +2258,7 @@ ndb_binlog_thread_handle_schema_event_po
free_share(&share);
share= 0;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (ndbcluster_check_if_local_table(schema->db, schema->name))
{
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
@@ -2264,7 +2279,7 @@ ndb_binlog_thread_handle_schema_event_po
while ((err= it++))
sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
break;
case SOT_ONLINE_ALTER_TABLE_PREPARE:
@@ -2285,7 +2300,7 @@ ndb_binlog_thread_handle_schema_event_po
Refresh local frm file and dictionary cache if
remote on-line alter table
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
TABLE_LIST table_list;
bzero((char*) &table_list,sizeof(table_list));
table_list.db= (char *)schema->db;
@@ -2328,21 +2343,21 @@ ndb_binlog_thread_handle_schema_event_po
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
}
if (!share)
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
else
{
if (ndb_extra_logging > 9)
sql_print_information("NDB Binlog: handeling online alter/rename");
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
ndbcluster_binlog_close_table(thd, share);
if ((error= ndbcluster_binlog_open_table(thd, share)))
sql_print_error("NDB Binlog: Failed to re-open table %s.%s",
schema->db, schema->name);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (error)
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
}
if (!error && share)
{
@@ -2375,7 +2390,7 @@ ndb_binlog_thread_handle_schema_event_po
share->new_op= share->op;
}
share->op= tmp_op;
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
if (ndb_extra_logging > 9)
sql_print_information("NDB Binlog: handeling online alter/rename done");
@@ -2388,7 +2403,7 @@ ndb_binlog_thread_handle_schema_event_po
sql_print_information("SOT_ONLINE_ALTER_TABLE_COMMIT %s.%s", schema->db,
schema->name);
if (share)
{
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
if (share->op && share->new_op)
{
Ndb_event_data *event_data= (Ndb_event_data *)
share->op->getCustomData();
@@ -2400,7 +2415,7 @@ ndb_binlog_thread_handle_schema_event_po
share->new_op= 0;
free_share(&share);
}
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
}
break;
}
@@ -2422,7 +2437,7 @@ ndb_binlog_thread_handle_schema_event_po
free_share(&share);
share= 0;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (ndbcluster_check_if_local_table(schema->db, schema->name))
{
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
@@ -2443,7 +2458,7 @@ ndb_binlog_thread_handle_schema_event_po
while ((err= it++))
sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
break;
default:
@@ -2669,27 +2684,27 @@ int ndbcluster_binlog_start()
DBUG_RETURN(-1);
}
- pthread_mutex_init(&injector_mutex, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&injector_cond, NULL);
- pthread_mutex_init(&ndb_schema_share_mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&injector_mutex, key_injector_mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&injector_cond, key_injector_cond, NULL);
+ MYSQL_MUTEX_INIT(&ndb_schema_share_mutex, key_ndb_schema_share_mutex,
MY_MUTEX_INIT_FAST);
/* Create injector thread */
if (pthread_create(&ndb_binlog_thread, &connection_attrib,
ndb_binlog_thread_func, 0))
{
DBUG_PRINT("error", ("Could not create ndb injector thread"));
- pthread_cond_destroy(&injector_cond);
- pthread_mutex_destroy(&injector_mutex);
+ MYSQL_COND_DESTROY(&injector_cond);
+ MYSQL_MUTEX_DESTROY(&injector_mutex);
DBUG_RETURN(-1);
}
ndbcluster_binlog_inited= 1;
/* Wait for the injector thread to start */
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
while (!ndb_binlog_thread_running)
- pthread_cond_wait(&injector_cond, &injector_mutex);
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_COND_WAIT(&injector_cond, &injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
if (ndb_binlog_thread_running < 0)
DBUG_RETURN(-1);
@@ -2792,7 +2807,7 @@ int ndbcluster_create_binlog_setup(THD *
DBUG_ASSERT(! IS_NDB_BLOB_PREFIX(table_name));
DBUG_ASSERT(strlen(key) == key_len);
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
/* Handle any trailing share */
NDB_SHARE *share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
@@ -2804,7 +2819,7 @@ int ndbcluster_create_binlog_setup(THD *
share->op != 0 ||
share->new_op != 0)
{
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(0); // replication already setup, or should not
}
}
@@ -2814,7 +2829,7 @@ int ndbcluster_create_binlog_setup(THD *
if (share->op || share->new_op)
{
my_errno= HA_ERR_TABLE_EXIST;
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(1);
}
if (!share_may_exist || share->connect_count !=
@@ -2857,10 +2872,10 @@ int ndbcluster_create_binlog_setup(THD *
if (!do_event_op)
{
set_binlog_nologging(share);
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(0);
}
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
while (share && !IS_TMP_PREFIX(table_name))
{
@@ -3169,14 +3184,14 @@ ndbcluster_create_event_ops(THD *thd, ND
int retry_sleep= 100;
while (1)
{
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
Ndb *ndb= injector_ndb;
if (do_ndb_schema_share)
ndb= schema_ndb;
if (ndb == 0)
{
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
DBUG_RETURN(-1);
}
@@ -3201,7 +3216,7 @@ ndbcluster_create_event_ops(THD *thd, ND
ndb->getNdbError().code,
ndb->getNdbError().message,
"NDB");
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
DBUG_RETURN(-1);
}
@@ -3264,7 +3279,7 @@ ndbcluster_create_event_ops(THD *thd, ND
op->getNdbError().message,
"NDB");
ndb->dropEventOperation(op);
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
DBUG_RETURN(-1);
}
}
@@ -3310,7 +3325,7 @@ ndbcluster_create_event_ops(THD *thd, ND
share->event_data= event_data;
op->setCustomData(NULL);
ndb->dropEventOperation(op);
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
if (retries)
{
my_sleep(retry_sleep);
@@ -3318,7 +3333,7 @@ ndbcluster_create_event_ops(THD *thd, ND
}
DBUG_RETURN(-1);
}
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
break;
}
@@ -3332,7 +3347,7 @@ ndbcluster_create_event_ops(THD *thd, ND
ndb_apply_status_share= get_share(share);
DBUG_PRINT("NDB_SHARE", ("%s binlog extra use_count: %u",
share->key, share->use_count));
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
}
else if (do_ndb_schema_share)
{
@@ -3340,7 +3355,7 @@ ndbcluster_create_event_ops(THD *thd, ND
ndb_schema_share= get_share(share);
DBUG_PRINT("NDB_SHARE", ("%s binlog extra use_count: %u",
share->key, share->use_count));
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
}
DBUG_PRINT("info",("%s share->op: %p share->use_count: %u",
@@ -3405,13 +3420,13 @@ ndbcluster_handle_alter_table(THD *thd,
DBUG_ENTER("ndbcluster_handle_alter_table");
const char *save_proc_info= thd->proc_info;
thd->proc_info= "Syncing ndb table schema operation and binlog";
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
int max_timeout= opt_ndb_sync_timeout;
while (share->state == NSS_ALTERED)
{
struct timespec abstime;
set_timespec(abstime, 1);
- int ret= pthread_cond_timedwait(&injector_cond,
+ int ret= MYSQL_COND_TIMEDWAIT(&injector_cond,
&share->mutex,
&abstime);
if (thd->killed ||
@@ -3431,7 +3446,7 @@ ndbcluster_handle_alter_table(THD *thd,
type_str, share->key);
}
}
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
thd->proc_info= save_proc_info;
DBUG_RETURN(0);
}
@@ -3473,15 +3488,15 @@ ndbcluster_handle_drop_table(THD *thd, N
#define SYNC_DROP_
#ifdef SYNC_DROP_
THD_SET_PROC_INFO(thd, "Syncing ndb table schema operation and binlog");
- (void) pthread_mutex_lock(&share->mutex);
- safe_mutex_assert_owner(&LOCK_open);
- (void) pthread_mutex_unlock(&LOCK_open);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_open);
int max_timeout= opt_ndb_sync_timeout;
while (share->op)
{
struct timespec abstime;
set_timespec(abstime, 1);
- int ret= pthread_cond_timedwait(&injector_cond,
+ int ret= MYSQL_COND_TIMEDWAIT(&injector_cond,
&share->mutex,
&abstime);
if (thd->killed ||
@@ -3501,12 +3516,12 @@ ndbcluster_handle_drop_table(THD *thd, N
type_str, share->key);
}
}
- (void) pthread_mutex_lock(&LOCK_open);
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_open);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
#else
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
share->op= 0;
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
#endif
THD_SET_PROC_INFO(thd, save_proc_info);
@@ -4114,7 +4129,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema
DBUG_PRINT("enter", ("key: '%s'", key));
if (!have_lock)
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
while (!(ndb_schema_object=
(NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects,
(uchar*) key,
@@ -4140,7 +4155,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema
my_free((uchar*) ndb_schema_object, 0);
break;
}
- pthread_mutex_init(&ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&ndb_schema_object->mutex, key_NSO_mutex,
MY_MUTEX_INIT_FAST);
bitmap_init(&ndb_schema_object->slock_bitmap, ndb_schema_object->slock,
sizeof(ndb_schema_object->slock)*8, FALSE);
bitmap_clear_all(&ndb_schema_object->slock_bitmap);
@@ -4152,7 +4167,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema
DBUG_PRINT("info", ("use_count: %d", ndb_schema_object->use_count));
}
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_RETURN(ndb_schema_object);
}
@@ -4163,12 +4178,12 @@ static void ndb_free_schema_object(NDB_S
DBUG_ENTER("ndb_free_schema_object");
DBUG_PRINT("enter", ("key: '%s'", (*ndb_schema_object)->key));
if (!have_lock)
- pthread_mutex_lock(&ndbcluster_mutex);
+ MYSQL_MUTEX_LOCK(&ndbcluster_mutex);
if (!--(*ndb_schema_object)->use_count)
{
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object);
- pthread_mutex_destroy(&(*ndb_schema_object)->mutex);
+ MYSQL_MUTEX_DESTROY(&(*ndb_schema_object)->mutex);
my_free((uchar*) *ndb_schema_object, MYF(0));
*ndb_schema_object= 0;
}
@@ -4177,7 +4192,7 @@ static void ndb_free_schema_object(NDB_S
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
}
if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndbcluster_mutex);
DBUG_VOID_RETURN;
}
@@ -4196,7 +4211,7 @@ pthread_handler_t ndb_binlog_thread_func
Timer main_timer;
#endif
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
/*
Set up the Thread
*/
@@ -4209,9 +4224,9 @@ pthread_handler_t ndb_binlog_thread_func
/* We need to set thd->thread_id before thd->store_globals, or it will
set an invalid value for thd->variables.pseudo_thread_id.
*/
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->thread_id= thread_id++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thd->thread_stack= (char*) &thd; /* remember where our stack is */
if (thd->store_globals())
@@ -4219,8 +4234,8 @@ pthread_handler_t ndb_binlog_thread_func
thd->cleanup();
delete thd;
ndb_binlog_thread_running= -1;
- pthread_mutex_unlock(&injector_mutex);
- pthread_cond_signal(&injector_cond);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
+ MYSQL_COND_SIGNAL(&injector_cond);
my_thread_end();
pthread_exit(0);
DBUG_RETURN(NULL);
@@ -4244,9 +4259,9 @@ pthread_handler_t ndb_binlog_thread_func
pthread_detach_this_thread();
thd->real_id= pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
threads.append(thd);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thd->lex->start_transaction_opt= 0;
if (!(s_ndb= new Ndb(g_ndb_cluster_connection, "")) ||
@@ -4254,8 +4269,8 @@ pthread_handler_t ndb_binlog_thread_func
{
sql_print_error("NDB Binlog: Getting Schema Ndb object failed");
ndb_binlog_thread_running= -1;
- pthread_mutex_unlock(&injector_mutex);
- pthread_cond_signal(&injector_cond);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
+ MYSQL_COND_SIGNAL(&injector_cond);
goto err;
}
@@ -4265,8 +4280,8 @@ pthread_handler_t ndb_binlog_thread_func
{
sql_print_error("NDB Binlog: Getting Ndb object failed");
ndb_binlog_thread_running= -1;
- pthread_mutex_unlock(&injector_mutex);
- pthread_cond_signal(&injector_cond);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
+ MYSQL_COND_SIGNAL(&injector_cond);
goto err;
}
@@ -4279,7 +4294,7 @@ pthread_handler_t ndb_binlog_thread_func
Used by both sql client thread and binlog thread to interact
with the storage
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
*/
injector_thd= thd;
injector_ndb= i_ndb;
@@ -4292,28 +4307,28 @@ pthread_handler_t ndb_binlog_thread_func
/* Thread start up completed */
ndb_binlog_thread_running= 1;
- pthread_mutex_unlock(&injector_mutex);
- pthread_cond_signal(&injector_cond);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
+ MYSQL_COND_SIGNAL(&injector_cond);
/*
wait for mysql server to start (so that the binlog is started
and thus can receive the first GAP event)
*/
- pthread_mutex_lock(&LOCK_server_started);
+ MYSQL_MUTEX_LOCK(&LOCK_server_started);
while (!mysqld_server_started)
{
struct timespec abstime;
set_timespec(abstime, 1);
- pthread_cond_timedwait(&COND_server_started, &LOCK_server_started,
+ MYSQL_COND_TIMEDWAIT(&COND_server_started, &LOCK_server_started,
&abstime);
if (ndbcluster_terminating)
{
- pthread_mutex_unlock(&LOCK_server_started);
- pthread_mutex_lock(&LOCK_ndb_util_thread);
+ MYSQL_MUTEX_UNLOCK(&LOCK_server_started);
+ MYSQL_MUTEX_LOCK(&LOCK_ndb_util_thread);
goto err;
}
}
- pthread_mutex_unlock(&LOCK_server_started);
+ MYSQL_MUTEX_UNLOCK(&LOCK_server_started);
restart:
/*
Main NDB Injector loop
@@ -4356,7 +4371,7 @@ restart:
{
THD_SET_PROC_INFO(thd, "Waiting for ndbcluster to start");
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
while (!ndb_schema_share ||
(ndb_binlog_running && !ndb_apply_status_share) ||
!ndb_binlog_tables_inited)
@@ -4364,14 +4379,14 @@ restart:
/* ndb not connected yet */
struct timespec abstime;
set_timespec(abstime, 1);
- pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime);
+ MYSQL_COND_TIMEDWAIT(&injector_cond, &injector_mutex, &abstime);
if (ndbcluster_binlog_terminating)
{
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
goto err;
}
}
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
if (thd_ndb == NULL)
{
@@ -4888,12 +4903,12 @@ err:
DBUG_PRINT("info",("Shutting down cluster binlog thread"));
THD_SET_PROC_INFO(thd, "Shutting down");
close_thread_tables(thd);
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
/* don't mess with the injector_ndb anymore from other threads */
injector_thd= 0;
injector_ndb= 0;
schema_ndb= 0;
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
thd->db= 0; // as not to try to free memory
if (ndb_apply_status_share)
@@ -4909,7 +4924,7 @@ err:
if (ndb_schema_share)
{
/* begin protect ndb_schema_share */
- pthread_mutex_lock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_LOCK(&ndb_schema_share_mutex);
/* ndb_share reference binlog extra free */
DBUG_PRINT("NDB_SHARE", ("%s binlog extra free use_count: %u",
ndb_schema_share->key,
@@ -4917,7 +4932,7 @@ err:
free_share(&ndb_schema_share);
ndb_schema_share= 0;
ndb_binlog_tables_inited= FALSE;
- pthread_mutex_unlock(&ndb_schema_share_mutex);
+ MYSQL_MUTEX_UNLOCK(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */
}
@@ -4940,10 +4955,10 @@ err:
delete event_data;
op->setCustomData(NULL);
}
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
share->op= 0;
share->new_op= 0;
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
/* ndb_share reference binlog free */
DBUG_PRINT("NDB_SHARE", ("%s binlog free use_count: %u",
share->key, share->use_count));
@@ -4970,11 +4985,11 @@ err:
op->setCustomData(NULL);
}
DBUG_ASSERT(share != 0);
- (void) pthread_mutex_lock(&share->mutex);
+ (void) MYSQL_MUTEX_LOCK(&share->mutex);
DBUG_ASSERT(share->op == op || share->new_op == op);
share->op= 0;
share->new_op= 0;
- (void) pthread_mutex_unlock(&share->mutex);
+ (void) MYSQL_MUTEX_UNLOCK(&share->mutex);
/* ndb_share reference binlog free */
DBUG_PRINT("NDB_SHARE", ("%s binlog free use_count: %u",
share->key, share->use_count));
@@ -4993,7 +5008,7 @@ err:
ndb_binlog_thread_running= -1;
ndb_binlog_running= FALSE;
- (void) pthread_cond_signal(&injector_cond);
+ (void) MYSQL_COND_SIGNAL(&injector_cond);
DBUG_PRINT("exit", ("ndb_binlog_thread"));
my_thread_end();
@@ -5011,12 +5026,12 @@ ndbcluster_show_status_binlog(THD* thd,
ulonglong ndb_latest_epoch= 0;
DBUG_ENTER("ndbcluster_show_status_binlog");
- pthread_mutex_lock(&injector_mutex);
+ MYSQL_MUTEX_LOCK(&injector_mutex);
if (injector_ndb)
{
char buff1[22],buff2[22],buff3[22],buff4[22],buff5[22];
ndb_latest_epoch= injector_ndb->getLatestGCI();
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
buflen=
snprintf(buf, sizeof(buf),
@@ -5036,7 +5051,7 @@ ndbcluster_show_status_binlog(THD* thd,
DBUG_RETURN(TRUE);
}
else
- pthread_mutex_unlock(&injector_mutex);
+ MYSQL_MUTEX_UNLOCK(&injector_mutex);
DBUG_RETURN(FALSE);
}
=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h 2008-02-05 15:34:12 +0000
+++ b/sql/ha_ndbcluster_binlog.h 2008-10-10 20:34:55 +0000
@@ -139,15 +139,15 @@ extern Ndb_cluster_connection* g_ndb_clu
#ifdef HAVE_NDB_BINLOG
extern pthread_t ndb_binlog_thread;
-extern pthread_mutex_t injector_mutex;
-extern pthread_cond_t injector_cond;
+extern mysql_mutex_t injector_mutex;
+extern mysql_cond_t injector_cond;
extern unsigned char g_node_id_map[max_ndb_nodes];
extern pthread_t ndb_util_thread;
-extern pthread_mutex_t LOCK_ndb_util_thread;
-extern pthread_cond_t COND_ndb_util_thread;
+extern mysql_mutex_t LOCK_ndb_util_thread;
+extern mysql_cond_t COND_ndb_util_thread;
extern int ndbcluster_util_inited;
-extern pthread_mutex_t ndbcluster_mutex;
+extern mysql_mutex_t ndbcluster_mutex;
extern HASH ndbcluster_open_tables;
extern long ndb_number_of_storage_nodes;
=== modified file 'sql/ha_ndbcluster_connection.cc'
--- a/sql/ha_ndbcluster_connection.cc 2007-11-20 14:22:05 +0000
+++ b/sql/ha_ndbcluster_connection.cc 2008-10-10 20:34:55 +0000
@@ -35,7 +35,12 @@ Ndb_cluster_connection* g_ndb_cluster_co
static Ndb_cluster_connection **g_ndb_cluster_connection_pool= NULL;
static ulong g_ndb_cluster_connection_pool_alloc= 0;
static ulong g_ndb_cluster_connection_pool_pos= 0;
-static pthread_mutex_t g_ndb_cluster_connection_pool_mutex;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_ndb_cluster_connection_pool_mutex;
+#endif
+
+static mysql_mutex_t g_ndb_cluster_connection_pool_mutex;
int ndbcluster_connect(int (*connect_callback)(void))
{
@@ -101,8 +106,9 @@ int ndbcluster_connect(int (*connect_cal
my_malloc(g_ndb_cluster_connection_pool_alloc *
sizeof(Ndb_cluster_connection*),
MYF(MY_WME | MY_ZEROFILL));
- pthread_mutex_init(&g_ndb_cluster_connection_pool_mutex,
- MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&g_ndb_cluster_connection_pool_mutex,
+ key_ndb_cluster_connection_pool_mutex,
+ MY_MUTEX_INIT_FAST);
g_ndb_cluster_connection_pool[0]= g_ndb_cluster_connection;
for (unsigned i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
{
@@ -218,7 +224,7 @@ int ndbcluster_disconnect()
delete g_ndb_cluster_connection_pool[i];
}
my_free((uchar*) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_destroy(&g_ndb_cluster_connection_pool_mutex);
+ MYSQL_MUTEX_DESTROY(&g_ndb_cluster_connection_pool_mutex);
g_ndb_cluster_connection_pool= 0;
}
g_ndb_cluster_connection_pool_alloc= 0;
@@ -232,14 +238,14 @@ int ndbcluster_disconnect()
Ndb_cluster_connection *ndb_get_cluster_connection()
{
- pthread_mutex_lock(&g_ndb_cluster_connection_pool_mutex);
+ MYSQL_MUTEX_LOCK(&g_ndb_cluster_connection_pool_mutex);
Ndb_cluster_connection *connection=
g_ndb_cluster_connection_pool[g_ndb_cluster_connection_pool_pos];
g_ndb_cluster_connection_pool_pos++;
if (g_ndb_cluster_connection_pool_pos ==
g_ndb_cluster_connection_pool_alloc)
g_ndb_cluster_connection_pool_pos= 0;
- pthread_mutex_unlock(&g_ndb_cluster_connection_pool_mutex);
+ MYSQL_MUTEX_UNLOCK(&g_ndb_cluster_connection_pool_mutex);
return connection;
}
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2008-08-20 18:05:57 +0000
+++ b/sql/ha_partition.cc 2008-10-10 20:34:55 +0000
@@ -2506,7 +2506,7 @@ int ha_partition::open(const char *name,
for the same table.
*/
if (is_not_tmp_table)
- pthread_mutex_lock(&table_share->LOCK_ha_data);
+ MYSQL_MUTEX_LOCK(&table_share->LOCK_ha_data);
if (!table_share->ha_data)
{
HA_DATA_PARTITION *ha_data;
@@ -2520,7 +2520,7 @@ int ha_partition::open(const char *name,
bzero(ha_data, sizeof(HA_DATA_PARTITION));
}
if (is_not_tmp_table)
- pthread_mutex_unlock(&table_share->LOCK_ha_data);
+ MYSQL_MUTEX_UNLOCK(&table_share->LOCK_ha_data);
/*
Some handlers update statistics as part of the open call. This will in
some cases corrupt the statistics of the partition handler and thus
@@ -6179,7 +6179,7 @@ int ha_partition::indexes_are_disabled(v
#ifdef NOT_USED
static HASH partition_open_tables;
-static pthread_mutex_t partition_mutex;
+static mysql_mutex_t partition_mutex;
static int partition_init= 0;
@@ -6217,7 +6217,7 @@ static PARTITION_SHARE *get_share(const
if (!partition_init)
{
/* Hijack a mutex for init'ing the storage engine */
- pthread_mutex_lock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_LOCK(&LOCK_mysql_create_db);
if (!partition_init)
{
partition_init++;
@@ -6225,9 +6225,9 @@ static PARTITION_SHARE *get_share(const
(void) hash_init(&partition_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) partition_get_key, 0, 0);
}
- pthread_mutex_unlock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mysql_create_db);
}
- pthread_mutex_lock(&partition_mutex);
+ MYSQL_MUTEX_LOCK(&partition_mutex);
length= (uint) strlen(table_name);
if (!(share= (PARTITION_SHARE *) hash_search(&partition_open_tables,
@@ -6238,7 +6238,7 @@ static PARTITION_SHARE *get_share(const
&share, (uint) sizeof(*share),
&tmp_name, (uint) length + 1, NullS)))
{
- pthread_mutex_unlock(&partition_mutex);
+ MYSQL_MUTEX_UNLOCK(&partition_mutex);
return NULL;
}
@@ -6252,12 +6252,12 @@ static PARTITION_SHARE *get_share(const
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
}
share->use_count++;
- pthread_mutex_unlock(&partition_mutex);
+ MYSQL_MUTEX_UNLOCK(&partition_mutex);
return share;
error:
- pthread_mutex_unlock(&partition_mutex);
+ MYSQL_MUTEX_UNLOCK(&partition_mutex);
my_free((uchar*) share, MYF(0));
return NULL;
@@ -6272,15 +6272,15 @@ error:
static int free_share(PARTITION_SHARE *share)
{
- pthread_mutex_lock(&partition_mutex);
+ MYSQL_MUTEX_LOCK(&partition_mutex);
if (!--share->use_count)
{
hash_delete(&partition_open_tables, (uchar *) share);
thr_lock_delete(&share->lock);
- pthread_mutex_destroy(&share->mutex);
+ MYSQL_MUTEX_DESTROY(&share->mutex);
my_free((uchar*) share, MYF(0));
}
- pthread_mutex_unlock(&partition_mutex);
+ MYSQL_MUTEX_UNLOCK(&partition_mutex);
return 0;
}
=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h 2008-08-12 08:20:26 +0000
+++ b/sql/ha_partition.h 2008-10-10 20:34:55 +0000
@@ -32,7 +32,7 @@ typedef struct st_partition_share
{
char *table_name;
uint table_name_length, use_count;
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
THR_LOCK lock;
} PARTITION_SHARE;
#endif
@@ -864,7 +864,7 @@ private:
if(table_share->tmp_table == NO_TMP_TABLE)
{
auto_increment_lock= TRUE;
- pthread_mutex_lock(&table_share->LOCK_ha_data);
+ MYSQL_MUTEX_LOCK(&table_share->LOCK_ha_data);
}
}
virtual void unlock_auto_increment()
@@ -877,7 +877,7 @@ private:
*/
if(auto_increment_lock && !auto_increment_safe_stmt_log_lock)
{
- pthread_mutex_unlock(&table_share->LOCK_ha_data);
+ MYSQL_MUTEX_UNLOCK(&table_share->LOCK_ha_data);
auto_increment_lock= FALSE;
}
}
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2008-09-04 18:30:34 +0000
+++ b/sql/handler.cc 2008-10-10 20:34:55 +0000
@@ -1553,7 +1553,7 @@ bool mysql_xa_recover(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
- pthread_mutex_lock(&LOCK_xid_cache);
+ MYSQL_MUTEX_LOCK(&LOCK_xid_cache);
while ((xs= (XID_STATE*)hash_element(&xid_cache, i++)))
{
if (xs->xa_state==XA_PREPARED)
@@ -1566,13 +1566,13 @@ bool mysql_xa_recover(THD *thd)
&my_charset_bin);
if (protocol->write())
{
- pthread_mutex_unlock(&LOCK_xid_cache);
+ MYSQL_MUTEX_UNLOCK(&LOCK_xid_cache);
DBUG_RETURN(1);
}
}
}
- pthread_mutex_unlock(&LOCK_xid_cache);
+ MYSQL_MUTEX_UNLOCK(&LOCK_xid_cache);
my_eof(thd);
DBUG_RETURN(0);
}
@@ -3508,12 +3508,12 @@ int ha_init_key_cache(const char *name,
if (!key_cache->key_cache_inited)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
ulong tmp_buff_size= (ulong) key_cache->param_buff_size;
uint tmp_block_size= (uint) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
DBUG_RETURN(!init_key_cache(key_cache,
tmp_block_size,
tmp_buff_size,
@@ -3532,12 +3532,12 @@ int ha_resize_key_cache(KEY_CACHE *key_c
if (key_cache->key_cache_inited)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
long tmp_buff_size= (long) key_cache->param_buff_size;
long tmp_block_size= (long) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size,
tmp_buff_size,
division_limit, age_threshold));
@@ -3553,10 +3553,10 @@ int ha_change_key_cache_param(KEY_CACHE
{
if (key_cache->key_cache_inited)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
change_key_cache_param(key_cache, division_limit, age_threshold);
}
return 0;
=== modified file 'sql/hash_filo.h'
--- a/sql/hash_filo.h 2007-05-10 09:59:39 +0000
+++ b/sql/hash_filo.h 2008-10-10 20:34:55 +0000
@@ -34,6 +34,9 @@ class hash_filo_element
friend class hash_filo;
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_hash_filo_lock;
+#endif
class hash_filo
{
@@ -45,7 +48,7 @@ class hash_filo
hash_filo_element *first_link,*last_link;
public:
- pthread_mutex_t lock;
+ mysql_mutex_t lock;
HASH cache;
hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg,
@@ -64,7 +67,7 @@ public:
{
if (cache.array.buffer) /* Avoid problems with thread library */
(void) hash_free(&cache);
- pthread_mutex_destroy(&lock);
+ MYSQL_MUTEX_DESTROY(&lock);
}
}
void clear(bool locked=0)
@@ -72,15 +75,15 @@ public:
if (!init)
{
init=1;
- (void) pthread_mutex_init(&lock,MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&lock, key_hash_filo_lock, MY_MUTEX_INIT_FAST);
}
if (!locked)
- (void) pthread_mutex_lock(&lock);
+ (void) MYSQL_MUTEX_LOCK(&lock);
(void) hash_free(&cache);
(void) hash_init(&cache,hash_charset,size,key_offset,
key_length, get_key, free_element,0);
if (!locked)
- (void) pthread_mutex_unlock(&lock);
+ (void) MYSQL_MUTEX_UNLOCK(&lock);
first_link=last_link=0;
}
=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc 2008-07-08 16:01:41 +0000
+++ b/sql/hostname.cc 2008-10-10 20:34:55 +0000
@@ -49,7 +49,12 @@ public:
};
static hash_filo *hostname_cache;
-static pthread_mutex_t LOCK_hostname;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_hostname;
+#endif
+
+static mysql_mutex_t LOCK_hostname;
void hostname_cache_refresh()
{
@@ -66,7 +71,7 @@ bool hostname_cache_init()
&my_charset_bin)))
return 1;
hostname_cache->clear();
- (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_hostname, key_LOCK_hostname, MY_MUTEX_INIT_SLOW);
return 0;
}
@@ -75,7 +80,7 @@ void hostname_cache_free()
{
if (hostname_cache)
{
- (void) pthread_mutex_destroy(&LOCK_hostname);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_hostname);
delete hostname_cache;
hostname_cache= 0;
}
@@ -85,7 +90,7 @@ static void add_hostname(struct sockaddr
{
if (!(specialflag & SPECIAL_NO_HOST_CACHE))
{
- pthread_mutex_lock(&hostname_cache->lock);
+ MYSQL_MUTEX_LOCK(&hostname_cache->lock);
host_entry *entry;
if (!(entry=(host_entry*) hostname_cache->search((uchar*) in, 0)))
{
@@ -104,7 +109,7 @@ static void add_hostname(struct sockaddr
(void) hostname_cache->add(entry);
}
}
- pthread_mutex_unlock(&hostname_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&hostname_cache->lock);
}
}
@@ -115,25 +120,25 @@ inline void add_wrong_ip(struct sockaddr
void inc_host_errors(struct sockaddr_storage *in)
{
- pthread_mutex_lock(&hostname_cache->lock);
+ MYSQL_MUTEX_LOCK(&hostname_cache->lock);
host_entry *entry;
if ((entry=(host_entry*) hostname_cache->search((uchar*)in, 0)))
entry->errors++;
- pthread_mutex_unlock(&hostname_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&hostname_cache->lock);
}
void reset_host_errors(struct sockaddr_storage *in)
{
- pthread_mutex_lock(&hostname_cache->lock);
+ MYSQL_MUTEX_LOCK(&hostname_cache->lock);
host_entry *entry;
if ((entry=(host_entry*) hostname_cache->search((uchar*)in, 0)))
entry->errors=0;
- pthread_mutex_unlock(&hostname_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&hostname_cache->lock);
}
@@ -177,7 +182,7 @@ char *ip_to_hostname(struct sockaddr_sto
/* Check first if we have name in cache */
if (!(specialflag & SPECIAL_NO_HOST_CACHE))
{
- pthread_mutex_lock(&hostname_cache->lock);
+ MYSQL_MUTEX_LOCK(&hostname_cache->lock);
if ((entry= (host_entry*)hostname_cache->search((uchar *)&in, 0)))
{
if (entry->hostname)
@@ -187,10 +192,10 @@ char *ip_to_hostname(struct sockaddr_sto
DBUG_PRINT("info",("cached data %s", name ? name : "null" ));
*errors= entry->errors;
- pthread_mutex_unlock(&hostname_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&hostname_cache->lock);
DBUG_RETURN(name);
}
- pthread_mutex_unlock(&hostname_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&hostname_cache->lock);
}
if (!(name= my_strdup(hostname_buff, MYF(0))))
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2008-08-07 03:05:33 +0000
+++ b/sql/item_func.cc 2008-10-10 20:34:55 +0000
@@ -3261,7 +3261,12 @@ bool udf_handler::get_arguments() { retu
** User level locks
*/
-pthread_mutex_t LOCK_user_locks;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_user_locks;
+PSI_cond_key key_ULL_cond;
+#endif
+
+mysql_mutex_t LOCK_user_locks;
static HASH hash_user_locks;
class User_level_lock
@@ -3272,7 +3277,7 @@ class User_level_lock
public:
int count;
bool locked;
- pthread_cond_t cond;
+ mysql_cond_t cond;
my_thread_id thread_id;
void set_thread(THD *thd) { thread_id= thd->thread_id; }
@@ -3280,7 +3285,7 @@ public:
:key_length(length),count(1),locked(1), thread_id(id)
{
key= (uchar*) my_memdup(key_arg,length,MYF(0));
- pthread_cond_init(&cond,NULL);
+ MYSQL_COND_INIT(&cond, key_ULL_cond, NULL);
if (key)
{
if (my_hash_insert(&hash_user_locks,(uchar*) this))
@@ -3297,7 +3302,7 @@ public:
hash_delete(&hash_user_locks,(uchar*) this);
my_free(key, MYF(0));
}
- pthread_cond_destroy(&cond);
+ MYSQL_COND_DESTROY(&cond);
}
inline bool initialized() { return key != 0; }
friend void item_user_lock_release(User_level_lock *ull);
@@ -3317,7 +3322,7 @@ static bool item_user_lock_inited= 0;
void item_user_lock_init(void)
{
- pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW);
+ MYSQL_MUTEX_INIT(&LOCK_user_locks, key_LOCK_user_locks, MY_MUTEX_INIT_SLOW);
hash_init(&hash_user_locks,system_charset_info,
16,0,0,(hash_get_key) ull_get_key,NULL,0);
item_user_lock_inited= 1;
@@ -3329,7 +3334,7 @@ void item_user_lock_free(void)
{
item_user_lock_inited= 0;
hash_free(&hash_user_locks);
- pthread_mutex_destroy(&LOCK_user_locks);
+ MYSQL_MUTEX_DESTROY(&LOCK_user_locks);
}
}
@@ -3338,7 +3343,7 @@ void item_user_lock_release(User_level_l
ull->locked=0;
ull->thread_id= 0;
if (--ull->count)
- pthread_cond_signal(&ull->cond);
+ MYSQL_COND_SIGNAL(&ull->cond);
else
delete ull;
}
@@ -3402,7 +3407,7 @@ void debug_sync_point(const char* lock_n
*/
DBUG_ASSERT(thd->ull == NULL);
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
/*
If the lock has not been aquired by some client, we do not want to
create an entry for it, since we immediately release the lock. In
@@ -3413,7 +3418,7 @@ void debug_sync_point(const char* lock_n
(uchar*) lock_name,
lock_name_len))))
{
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
DBUG_VOID_RETURN;
}
ull->count++;
@@ -3437,7 +3442,7 @@ void debug_sync_point(const char* lock_n
set_timespec(abstime,lock_timeout);
while (ull->locked && !thd->killed)
{
- int error= pthread_cond_timedwait(&ull->cond, &LOCK_user_locks,
&abstime);
+ int error= MYSQL_COND_TIMEDWAIT(&ull->cond, &LOCK_user_locks,
&abstime);
if (error == ETIMEDOUT || error == ETIME)
break;
}
@@ -3453,19 +3458,19 @@ void debug_sync_point(const char* lock_n
ull->set_thread(thd);
thd->ull=ull;
}
- pthread_mutex_unlock(&LOCK_user_locks);
- pthread_mutex_lock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&thd->mysys_var->mutex);
thd_proc_info(thd, 0);
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
- pthread_mutex_unlock(&thd->mysys_var->mutex);
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
if (thd->ull)
{
item_user_lock_release(thd->ull);
thd->ull=0;
}
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
DBUG_VOID_RETURN;
}
@@ -3479,13 +3484,13 @@ void debug_sync_point(const char* lock_n
@param lock the associated mutex
@param abstime the amount of time in seconds to wait
- @retval return value from pthread_cond_timedwait
+ @retval return value from MYSQL_COND_TIMEDWAIT
*/
#define INTERRUPT_INTERVAL (5 * ULL(1000000000))
-static int interruptible_wait(THD *thd, pthread_cond_t *cond,
- pthread_mutex_t *lock, double time)
+static int interruptible_wait(THD *thd, mysql_cond_t *cond,
+ mysql_mutex_t *lock, double time)
{
int error;
struct timespec abstime;
@@ -3501,7 +3506,7 @@ static int interruptible_wait(THD *thd,
timeout-= slice;
set_timespec_nsec(abstime, slice);
- error= pthread_cond_timedwait(cond, lock, &abstime);
+ error= MYSQL_COND_TIMEDWAIT(cond, lock, &abstime);
if (error == ETIMEDOUT || error == ETIME)
{
/* Return error if timed out or connection is broken. */
@@ -3544,11 +3549,11 @@ longlong Item_func_get_lock::val_int()
if (thd->slave_thread)
DBUG_RETURN(1);
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
if (!res || !res->length())
{
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
null_value=1;
DBUG_RETURN(0);
}
@@ -3571,13 +3576,13 @@ longlong Item_func_get_lock::val_int()
if (!ull || !ull->initialized())
{
delete ull;
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
null_value=1; // Probably out of memory
DBUG_RETURN(0);
}
ull->set_thread(thd);
thd->ull=ull;
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
DBUG_PRINT("info", ("made new lock"));
DBUG_RETURN(1); // Got new lock
}
@@ -3627,13 +3632,13 @@ longlong Item_func_get_lock::val_int()
error=0;
DBUG_PRINT("info", ("got the lock"));
}
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
- pthread_mutex_lock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&thd->mysys_var->mutex);
thd_proc_info(thd, 0);
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
- pthread_mutex_unlock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&thd->mysys_var->mutex);
DBUG_RETURN(!error ? 1 : 0);
}
@@ -3664,7 +3669,7 @@ longlong Item_func_release_lock::val_int
null_value=0;
result=0;
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
if (!(ull= ((User_level_lock*) hash_search(&hash_user_locks,
(const uchar*) res->ptr(),
(size_t) res->length()))))
@@ -3685,7 +3690,7 @@ longlong Item_func_release_lock::val_int
thd->ull=0;
}
}
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
DBUG_RETURN(result);
}
@@ -3785,13 +3790,16 @@ void Item_func_benchmark::print(String *
str->append(')');
}
+#ifdef HAVE_PSI_INTERFACE
+PSI_cond_key key_Item_func_sleep_cond;
+#endif
/** This function is just used to create tests with time gaps. */
longlong Item_func_sleep::val_int()
{
THD *thd= current_thd;
- pthread_cond_t cond;
+ mysql_cond_t cond;
double timeout;
int error;
@@ -3799,19 +3807,19 @@ longlong Item_func_sleep::val_int()
timeout= args[0]->val_real();
/*
- On 64-bit OSX pthread_cond_timedwait() waits forever
+ On 64-bit OSX MYSQL_COND_TIMEDWAIT() waits forever
if passed abstime time has already been exceeded by
the system time.
When given a very short timeout (< 10 mcs) just return
immediately.
We assume that the lines between this test and the call
- to pthread_cond_timedwait() will be executed in less than 0.00001 sec.
+ to MYSQL_COND_TIMEDWAIT() will be executed in less than 0.00001 sec.
*/
if (timeout < 0.00001)
return 0;
- pthread_cond_init(&cond, NULL);
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_COND_INIT(&cond, key_Item_func_sleep_cond, NULL);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
thd_proc_info(thd, "User sleep");
thd->mysys_var->current_mutex= &LOCK_user_locks;
@@ -3826,13 +3834,13 @@ longlong Item_func_sleep::val_int()
error= 0;
}
thd_proc_info(thd, 0);
- pthread_mutex_unlock(&LOCK_user_locks);
- pthread_mutex_lock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
- pthread_mutex_unlock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&thd->mysys_var->mutex);
- pthread_cond_destroy(&cond);
+ MYSQL_COND_DESTROY(&cond);
return test(!error); // Return 1 killed
}
@@ -5306,10 +5314,10 @@ longlong Item_func_is_free_lock::val_int
return 0;
}
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(),
(size_t) res->length());
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
if (!ull || !ull->locked)
return 1;
return 0;
@@ -5325,10 +5333,10 @@ longlong Item_func_is_used_lock::val_int
if (!res || !res->length())
return 0;
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(),
(size_t) res->length());
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
if (!ull || !ull->locked)
return 0;
@@ -5765,13 +5773,13 @@ void uuid_short_init()
(((ulonglong) server_start_time) << 24));
}
-pthread_mutex_t LOCK_uuid_short;
+mysql_mutex_t LOCK_uuid_short;
longlong Item_func_uuid_short::val_int()
{
ulonglong val;
- pthread_mutex_lock(&LOCK_uuid_short);
+ MYSQL_MUTEX_LOCK(&LOCK_uuid_short);
val= uuid_value++;
- pthread_mutex_unlock(&LOCK_uuid_short);
+ MYSQL_MUTEX_UNLOCK(&LOCK_uuid_short);
return (longlong) val;
}
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2008-07-25 17:21:55 +0000
+++ b/sql/item_strfunc.cc 2008-10-10 20:34:55 +0000
@@ -612,18 +612,18 @@ String *Item_func_des_encrypt::val_str(S
if (arg_count == 1)
{
/* Protect against someone doing FLUSH DES_KEY_FILE */
- pthread_mutex_lock(&LOCK_des_key_file);
+ MYSQL_MUTEX_LOCK(&LOCK_des_key_file);
keyschedule= des_keyschedule[key_number=des_default_key];
- pthread_mutex_unlock(&LOCK_des_key_file);
+ MYSQL_MUTEX_UNLOCK(&LOCK_des_key_file);
}
else if (args[1]->result_type() == INT_RESULT)
{
key_number= (uint) args[1]->val_int();
if (key_number > 9)
goto error;
- pthread_mutex_lock(&LOCK_des_key_file);
+ MYSQL_MUTEX_LOCK(&LOCK_des_key_file);
keyschedule= des_keyschedule[key_number];
- pthread_mutex_unlock(&LOCK_des_key_file);
+ MYSQL_MUTEX_UNLOCK(&LOCK_des_key_file);
}
else
{
@@ -709,9 +709,9 @@ String *Item_func_des_decrypt::val_str(S
key_number > 9)
goto error;
- pthread_mutex_lock(&LOCK_des_key_file);
+ MYSQL_MUTEX_LOCK(&LOCK_des_key_file);
keyschedule= des_keyschedule[key_number];
- pthread_mutex_unlock(&LOCK_des_key_file);
+ MYSQL_MUTEX_UNLOCK(&LOCK_des_key_file);
}
else
{
@@ -1838,17 +1838,17 @@ String *Item_func_encrypt::val_str(Strin
return 0;
salt_ptr= salt_str->c_ptr();
}
- pthread_mutex_lock(&LOCK_crypt);
+ MYSQL_MUTEX_LOCK(&LOCK_crypt);
char *tmp= crypt(res->c_ptr(),salt_ptr);
if (!tmp)
{
- pthread_mutex_unlock(&LOCK_crypt);
+ MYSQL_MUTEX_UNLOCK(&LOCK_crypt);
null_value= 1;
return 0;
}
str->set(tmp, (uint) strlen(tmp), &my_charset_bin);
str->copy();
- pthread_mutex_unlock(&LOCK_crypt);
+ MYSQL_MUTEX_UNLOCK(&LOCK_crypt);
return str;
#else
null_value=1;
=== modified file 'sql/lock.cc'
--- a/sql/lock.cc 2008-08-08 01:33:43 +0000
+++ b/sql/lock.cc 2008-10-10 20:34:55 +0000
@@ -1104,7 +1104,7 @@ bool lock_global_read_lock(THD *thd)
{
const char *old_message;
const char *new_message= "Waiting to get readlock";
- (void) pthread_mutex_lock(&LOCK_global_read_lock);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_global_read_lock);
#if defined(ENABLED_DEBUG_SYNC)
/*
@@ -1136,7 +1136,7 @@ bool lock_global_read_lock(THD *thd)
waiting_for_read_lock++;
while (protect_against_global_read_lock && !thd->killed)
- pthread_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
+ MYSQL_COND_WAIT(&COND_global_read_lock, &LOCK_global_read_lock);
waiting_for_read_lock--;
if (thd->killed)
{
@@ -1163,13 +1163,13 @@ bool lock_global_read_lock(THD *thd)
if (mdl_acquire_global_shared_lock(&thd->mdl_context))
{
/* Our thread was killed -- return back to initial state. */
- pthread_mutex_lock(&LOCK_global_read_lock);
+ MYSQL_MUTEX_LOCK(&LOCK_global_read_lock);
if (!(--global_read_lock))
{
DBUG_PRINT("signal", ("Broadcasting COND_global_read_lock"));
- pthread_cond_broadcast(&COND_global_read_lock);
+ MYSQL_COND_BROADCAST(&COND_global_read_lock);
}
- pthread_mutex_unlock(&LOCK_global_read_lock);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_read_lock);
thd->global_read_lock= 0;
DBUG_RETURN(1);
}
@@ -1196,16 +1196,16 @@ void unlock_global_read_lock(THD *thd)
mdl_release_global_shared_lock(&thd->mdl_context);
- pthread_mutex_lock(&LOCK_global_read_lock);
+ MYSQL_MUTEX_LOCK(&LOCK_global_read_lock);
tmp= --global_read_lock;
if (thd->global_read_lock == MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT)
--global_read_lock_blocks_commit;
- pthread_mutex_unlock(&LOCK_global_read_lock);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_read_lock);
/* Send the signal outside the mutex to avoid a context switch */
if (!tmp)
{
DBUG_PRINT("signal", ("Broadcasting COND_global_read_lock"));
- pthread_cond_broadcast(&COND_global_read_lock);
+ MYSQL_COND_BROADCAST(&COND_global_read_lock);
}
thd->global_read_lock= 0;
@@ -1229,9 +1229,9 @@ bool wait_if_global_read_lock(THD *thd,
threads could not close their tables. This would make a pretty
deadlock.
*/
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
- (void) pthread_mutex_lock(&LOCK_global_read_lock);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_global_read_lock);
if ((need_exit_cond= must_wait))
{
const char *new_message= "Waiting for release of readlock";
@@ -1241,7 +1241,7 @@ bool wait_if_global_read_lock(THD *thd,
if (is_not_commit)
my_message(ER_CANT_UPDATE_WITH_READLOCK,
ER(ER_CANT_UPDATE_WITH_READLOCK), MYF(0));
- (void) pthread_mutex_unlock(&LOCK_global_read_lock);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_global_read_lock);
/*
We allow FLUSHer to COMMIT; we assume FLUSHer knows what it does.
This allowance is needed to not break existing versions of innobackup
@@ -1278,7 +1278,7 @@ bool wait_if_global_read_lock(THD *thd,
(!abort_on_refresh || thd->version == refresh_version))
{
DBUG_PRINT("signal", ("Waiting for COND_global_read_lock"));
- (void) pthread_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
+ (void) MYSQL_COND_WAIT(&COND_global_read_lock, &LOCK_global_read_lock);
DBUG_PRINT("signal", ("Got COND_global_read_lock"));
}
if (thd->killed)
@@ -1297,7 +1297,7 @@ bool wait_if_global_read_lock(THD *thd,
if (unlikely(need_exit_cond))
thd->exit_cond(old_message); // this unlocks LOCK_global_read_lock
else
- pthread_mutex_unlock(&LOCK_global_read_lock);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_read_lock);
DBUG_RETURN(result);
}
@@ -1308,15 +1308,15 @@ void start_waiting_global_read_lock(THD
DBUG_ENTER("start_waiting_global_read_lock");
if (unlikely(thd->global_read_lock))
DBUG_VOID_RETURN;
- (void) pthread_mutex_lock(&LOCK_global_read_lock);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_global_read_lock);
DBUG_ASSERT(protect_against_global_read_lock);
tmp= (!--protect_against_global_read_lock &&
(waiting_for_read_lock || global_read_lock_blocks_commit));
DBUG_PRINT("sql_lock", ("protect_against_global_read_lock decr: %u",
protect_against_global_read_lock));
- (void) pthread_mutex_unlock(&LOCK_global_read_lock);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_global_read_lock);
if (tmp)
- pthread_cond_broadcast(&COND_global_read_lock);
+ MYSQL_COND_BROADCAST(&COND_global_read_lock);
DBUG_VOID_RETURN;
}
@@ -1332,7 +1332,7 @@ bool make_global_read_lock_block_commit(
*/
if (thd->global_read_lock != GOT_GLOBAL_READ_LOCK)
DBUG_RETURN(0);
- pthread_mutex_lock(&LOCK_global_read_lock);
+ MYSQL_MUTEX_LOCK(&LOCK_global_read_lock);
/* increment this BEFORE waiting on cond (otherwise race cond) */
global_read_lock_blocks_commit++;
/* For testing we set up some blocking, to see if we can be killed */
@@ -1341,7 +1341,7 @@ bool make_global_read_lock_block_commit(
old_message= thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock,
"Waiting for all running commits to finish");
while (protect_against_global_read_lock && !thd->killed)
- pthread_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
+ MYSQL_COND_WAIT(&COND_global_read_lock, &LOCK_global_read_lock);
DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop",
protect_against_global_read_lock--;);
if ((error= test(thd->killed)))
@@ -1359,7 +1359,7 @@ bool make_global_read_lock_block_commit(
Due to a bug in a threading library it could happen that a signal
did not reach its target. A condition for this was that the same
condition variable was used with different mutexes in
- pthread_cond_wait(). Some time ago we changed LOCK_open to
+ MYSQL_COND_WAIT(). Some time ago we changed LOCK_open to
LOCK_global_read_lock in global read lock handling. So COND_refresh
was used with LOCK_open and LOCK_global_read_lock.
@@ -1374,8 +1374,8 @@ bool make_global_read_lock_block_commit(
void broadcast_refresh(void)
{
- pthread_cond_broadcast(&COND_refresh);
- pthread_cond_broadcast(&COND_global_read_lock);
+ MYSQL_COND_BROADCAST(&COND_refresh);
+ MYSQL_COND_BROADCAST(&COND_global_read_lock);
}
=== modified file 'sql/log.cc'
--- a/sql/log.cc 2008-09-11 18:21:54 +0000
+++ b/sql/log.cc 2008-10-10 20:34:55 +0000
@@ -144,24 +144,24 @@ char *make_backup_log_name(char *buff, c
class Mutex_sentry
{
public:
- Mutex_sentry(pthread_mutex_t *mutex)
+ Mutex_sentry(mysql_mutex_t *mutex)
: m_mutex(mutex)
{
if (m_mutex)
- pthread_mutex_lock(mutex);
+ MYSQL_MUTEX_LOCK(mutex);
}
~Mutex_sentry()
{
if (m_mutex)
- pthread_mutex_unlock(m_mutex);
+ MYSQL_MUTEX_UNLOCK(m_mutex);
#ifndef DBUG_OFF
m_mutex= 0;
#endif
}
private:
- pthread_mutex_t *m_mutex;
+ mysql_mutex_t *m_mutex;
// It's not allowed to copy this object in any way
Mutex_sentry(Mutex_sentry const&);
@@ -1302,7 +1302,7 @@ bool LOGGER::error_log_print(enum loglev
void LOGGER::cleanup_base()
{
DBUG_ASSERT(inited == 1);
- rwlock_destroy(&LOCK_logger);
+ MYSQL_RWLOCK_DESTROY(&LOCK_logger);
if (table_log_handler)
{
table_log_handler->cleanup();
@@ -1342,7 +1342,7 @@ void LOGGER::init_base()
init_error_log(LOG_FILE);
file_log_handler->init_pthread_objects();
- my_rwlock_init(&LOCK_logger, NULL);
+ MYSQL_RWLOCK_INIT(&LOCK_logger, key_LOCK_logger, NULL);
}
@@ -2703,7 +2703,7 @@ void MYSQL_LOG::init_pthread_objects()
{
DBUG_ASSERT(inited == 0);
inited= 1;
- (void) pthread_mutex_init(&LOCK_log, MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_log, key_LOG_LOCK_log, MY_MUTEX_INIT_SLOW);
}
/*
@@ -2754,7 +2754,7 @@ void MYSQL_LOG::cleanup()
if (inited)
{
inited= 0;
- (void) pthread_mutex_destroy(&LOCK_log);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_log);
close(0);
}
DBUG_VOID_RETURN;
@@ -2802,7 +2802,7 @@ void MYSQL_QUERY_LOG::reopen_file()
DBUG_VOID_RETURN;
}
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
save_name= name;
name= 0; // Don't free name
@@ -2815,7 +2815,7 @@ void MYSQL_QUERY_LOG::reopen_file()
open(save_name, log_type, 0, io_cache_type);
my_free(save_name, MYF(0));
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_VOID_RETURN;
}
@@ -2857,7 +2857,7 @@ bool MYSQL_QUERY_LOG::write(time_t event
struct tm start;
uint time_buff_len= 0;
- (void) pthread_mutex_lock(&LOCK_log);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_log);
/* Test if someone closed between the is_open test and lock */
if (is_open())
@@ -2903,7 +2903,7 @@ bool MYSQL_QUERY_LOG::write(time_t event
goto err;
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
return FALSE;
err:
@@ -2912,7 +2912,7 @@ err:
write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
return TRUE;
}
@@ -2955,11 +2955,11 @@ bool MYSQL_QUERY_LOG::write(THD *thd, ti
bool error= 0;
DBUG_ENTER("MYSQL_QUERY_LOG::write");
- (void) pthread_mutex_lock(&LOCK_log);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_log);
if (!is_open())
{
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(0);
}
@@ -3068,7 +3068,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, ti
}
}
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(error);
}
@@ -3300,7 +3300,7 @@ bool MYSQL_BACKUP_LOG::write(THD *thd, s
save_time_zone_used= thd->time_zone_used;
- (void) pthread_mutex_lock(&LOCK_log);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_log);
/*
Test if someone closed between the is_open test and lock
@@ -3350,7 +3350,7 @@ bool MYSQL_BACKUP_LOG::write(THD *thd, s
goto err;
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
thd->time_zone_used= save_time_zone_used;
return FALSE;
err:
@@ -3360,7 +3360,7 @@ err:
write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
thd->time_zone_used= save_time_zone_used;
return TRUE;
}
@@ -3392,7 +3392,7 @@ bool MYSQL_BACKUP_LOG::write(THD *thd, u
save_time_zone_used= thd->time_zone_used;
- (void) pthread_mutex_lock(&LOCK_log);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_log);
/*
Test if someone closed between the is_open test and lock
@@ -3424,7 +3424,7 @@ bool MYSQL_BACKUP_LOG::write(THD *thd, u
goto err;
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
thd->time_zone_used= save_time_zone_used;
return FALSE;
err:
@@ -3434,7 +3434,7 @@ err:
write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
}
- (void) pthread_mutex_unlock(&LOCK_log);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_log);
thd->time_zone_used= save_time_zone_used;
return TRUE;
}
@@ -3531,7 +3531,7 @@ ulonglong MYSQL_BACKUP_LOG::get_next_bac
m_next_id == 0 means we need to read the next id from the file (on startup).
m_next_id > 0 means use this value
*/
- pthread_mutex_lock(&LOCK_backupid);
+ MYSQL_MUTEX_LOCK(&LOCK_backupid);
if (!m_next_id)
{
file_path= make_backup_log_name(buff, BACKUP_SETTINGS_NAME.str, ".obx");
@@ -3598,7 +3598,7 @@ err:
err_end:
m_next_id= id;
- pthread_mutex_unlock(&LOCK_backupid);
+ MYSQL_MUTEX_UNLOCK(&LOCK_backupid);
DBUG_PRINT("backup_log",("The next id is %lu.\n", (ulong)id));
if(read_id)
my_free(read_id, MYF(0));
@@ -3626,7 +3626,7 @@ void MYSQL_BACKUP_LOG::reopen_file(bool
DBUG_VOID_RETURN;
}
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
save_name= name;
name= 0; // Don't free name
@@ -3639,7 +3639,7 @@ void MYSQL_BACKUP_LOG::reopen_file(bool
open(save_name, log_type, 0, io_cache_type, history);
my_free(save_name, MYF(0));
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_VOID_RETURN;
}
@@ -3699,9 +3699,9 @@ void MYSQL_BIN_LOG::cleanup()
close(LOG_CLOSE_INDEX|LOG_CLOSE_STOP_EVENT);
delete description_event_for_queue;
delete description_event_for_exec;
- (void) pthread_mutex_destroy(&LOCK_log);
- (void) pthread_mutex_destroy(&LOCK_index);
- (void) pthread_cond_destroy(&update_cond);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_log);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_index);
+ (void) MYSQL_COND_DESTROY(&update_cond);
}
DBUG_VOID_RETURN;
}
@@ -3722,9 +3722,9 @@ void MYSQL_BIN_LOG::init_pthread_objects
{
DBUG_ASSERT(inited == 0);
inited= 1;
- (void) pthread_mutex_init(&LOCK_log, MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_index, MY_MUTEX_INIT_SLOW);
- (void) pthread_cond_init(&update_cond, 0);
+ (void) MYSQL_MUTEX_INIT(&LOCK_log, key_LOG_LOCK_log, MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_index, key_BINLOG_LOCK_index, MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_COND_INIT(&update_cond, key_BINLOG_update_cond, 0);
}
@@ -3918,9 +3918,9 @@ shutdown the MySQL server and restart it
int MYSQL_BIN_LOG::get_current_log(LOG_INFO* linfo)
{
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
int ret = raw_get_current_log(linfo);
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
return ret;
}
@@ -4021,8 +4021,8 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO
move from under our feet
*/
if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_index);
/* As the file is flushed, we can't get an error here */
(void) reinit_io_cache(&index_file, READ_CACHE, (my_off_t) 0, 0, 0);
@@ -4054,7 +4054,7 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO
}
if (need_lock)
- pthread_mutex_unlock(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
DBUG_RETURN(error);
}
@@ -4090,8 +4090,8 @@ int MYSQL_BIN_LOG::find_next_log(LOG_INF
char *fname= linfo->log_file_name;
if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_index);
/* As the file is flushed, we can't get an error here */
(void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
@@ -4108,7 +4108,7 @@ int MYSQL_BIN_LOG::find_next_log(LOG_INF
err:
if (need_lock)
- pthread_mutex_unlock(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
return error;
}
@@ -4142,8 +4142,8 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
We need to get both locks to be sure that no one is trying to
write to the index log file.
*/
- pthread_mutex_lock(&LOCK_log);
- pthread_mutex_lock(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
/*
The following mutex is needed to ensure that no threads call
@@ -4151,7 +4151,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
thread. If the transaction involved MyISAM tables, it should go
into binlog even on rollback.
*/
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
/* Save variables so that we can reopen the log */
save_name=name;
@@ -4231,9 +4231,9 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
my_free((uchar*) save_name, MYF(0));
err:
- pthread_mutex_unlock(&LOCK_thread_count);
- pthread_mutex_unlock(&LOCK_index);
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(error);
}
@@ -4286,20 +4286,20 @@ int MYSQL_BIN_LOG::purge_first_log(Relay
DBUG_ASSERT(rli->slave_running == 1);
DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->event_relay_log_name));
- pthread_mutex_lock(&LOCK_index);
- pthread_mutex_lock(&rli->log_space_lock);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&rli->log_space_lock);
rli->relay_log.purge_logs(rli->group_relay_log_name, included,
0, 0, &rli->log_space_total);
// Tell the I/O thread to take the relay_log_space_limit into account
rli->ignore_log_space_limit= 0;
- pthread_mutex_unlock(&rli->log_space_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->log_space_lock);
/*
Ok to broadcast after the critical region as there is no risk of
the mutex being destroyed by this thread later - this helps save
context switches
*/
- pthread_cond_broadcast(&rli->log_space_cond);
+ MYSQL_COND_BROADCAST(&rli->log_space_cond);
/*
Read the next log file name from the index file and pass it back to
@@ -4345,7 +4345,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay
flush_relay_log_info(rli);
err:
- pthread_mutex_unlock(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
DBUG_RETURN(error);
}
@@ -4403,7 +4403,7 @@ int MYSQL_BIN_LOG::purge_logs(const char
DBUG_PRINT("info",("to_log= %s",to_log));
if (need_mutex)
- pthread_mutex_lock(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
if ((error=find_log_pos(&log_info, to_log, 0 /*no mutex*/)))
goto err;
@@ -4534,7 +4534,7 @@ int MYSQL_BIN_LOG::purge_logs(const char
err:
if (need_mutex)
- pthread_mutex_unlock(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
DBUG_RETURN(error);
}
@@ -4566,7 +4566,7 @@ int MYSQL_BIN_LOG::purge_logs_before_dat
DBUG_ENTER("purge_logs_before_date");
- pthread_mutex_lock(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
/*
Delete until we find curren file
@@ -4673,7 +4673,7 @@ int MYSQL_BIN_LOG::purge_logs_before_dat
error= update_log_index(&log_info, 1);
err:
- pthread_mutex_unlock(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
DBUG_RETURN(error);
}
#endif /* HAVE_REPLICATION */
@@ -4749,11 +4749,11 @@ void MYSQL_BIN_LOG::new_file_impl(bool n
}
if (need_lock)
- pthread_mutex_lock(&LOCK_log);
- pthread_mutex_lock(&LOCK_index);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_log);
- safe_mutex_assert_owner(&LOCK_index);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_log);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_index);
/*
if binlog is used as tc log, be sure all xids are "unlogged",
@@ -4767,12 +4767,12 @@ void MYSQL_BIN_LOG::new_file_impl(bool n
if (prepared_xids)
{
tc_log_page_waits++;
- pthread_mutex_lock(&LOCK_prep_xids);
+ MYSQL_MUTEX_LOCK(&LOCK_prep_xids);
while (prepared_xids) {
DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids));
- pthread_cond_wait(&COND_prep_xids, &LOCK_prep_xids);
+ MYSQL_COND_WAIT(&COND_prep_xids, &LOCK_prep_xids);
}
- pthread_mutex_unlock(&LOCK_prep_xids);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prep_xids);
}
/* Reuse old name if not binlog and not update log */
@@ -4830,8 +4830,8 @@ void MYSQL_BIN_LOG::new_file_impl(bool n
end:
if (need_lock)
- pthread_mutex_unlock(&LOCK_log);
- pthread_mutex_unlock(&LOCK_index);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_index);
DBUG_VOID_RETURN;
}
@@ -4840,7 +4840,7 @@ end:
bool MYSQL_BIN_LOG::append(Log_event* ev)
{
bool error = 0;
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
DBUG_ENTER("MYSQL_BIN_LOG::append");
DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
@@ -4859,7 +4859,7 @@ bool MYSQL_BIN_LOG::append(Log_event* ev
new_file_without_locking();
err:
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
signal_update(); // Safe as we don't call close
DBUG_RETURN(error);
}
@@ -4874,7 +4874,7 @@ bool MYSQL_BIN_LOG::appendv(const char*
DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
- safe_mutex_assert_owner(&LOCK_log);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_log);
do
{
if (my_b_append(&log_file,(uchar*) buf,len))
@@ -4898,7 +4898,7 @@ err:
bool MYSQL_BIN_LOG::flush_and_sync()
{
int err=0, fd=log_file.file;
- safe_mutex_assert_owner(&LOCK_log);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_log);
if (flush_io_cache(&log_file))
return 1;
if (++sync_binlog_counter >= sync_binlog_period && sync_binlog_period)
@@ -5136,14 +5136,14 @@ MYSQL_BIN_LOG::flush_and_set_pending_row
m_table_map_version below, and that change has to be protected
by the LOCK_log mutex.
*/
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
/*
Write pending event to log file or transaction cache
*/
if (pending->write(file))
{
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(1);
}
@@ -5177,7 +5177,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_row
}
}
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
}
thd->binlog_set_pending_rows_event(event);
@@ -5220,7 +5220,7 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
thd->locked_tables_mode && thd->lex->requires_prelocking();
thd->binlog_flush_pending_rows_event(end_stmt);
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
/*
In most cases this is only called if 'is_open()' is true; in fact this is
@@ -5240,7 +5240,7 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
(!binlog_filter->db_ok(local_db)))
{
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(0);
}
#endif /* HAVE_REPLICATION */
@@ -5378,7 +5378,7 @@ err:
if (event_info->flags & LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F)
++m_table_map_version;
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(error);
}
@@ -5455,7 +5455,7 @@ bool general_log_write(THD *thd, enum en
void MYSQL_BIN_LOG::rotate_and_purge(uint flags)
{
if (!(flags & RP_LOCK_LOG_IS_ALREADY_LOCKED))
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
if ((flags & RP_FORCE_ROTATE) ||
(my_b_tell(&log_file) >= (my_off_t) max_size))
{
@@ -5470,15 +5470,15 @@ void MYSQL_BIN_LOG::rotate_and_purge(uin
#endif
}
if (!(flags & RP_LOCK_LOG_IS_ALREADY_LOCKED))
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
}
uint MYSQL_BIN_LOG::next_file_id()
{
uint res;
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
res = file_id++;
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
return res;
}
@@ -5648,7 +5648,7 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
{
DBUG_ENTER("MYSQL_BIN_LOG::write(THD *, IO_CACHE *, Log_event *)");
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
/* NULL would represent nothing to replicate after ROLLBACK */
DBUG_ASSERT(commit_event != NULL);
@@ -5727,14 +5727,14 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
*/
if (commit_event && commit_event->get_type_code() == XID_EVENT)
{
- pthread_mutex_lock(&LOCK_prep_xids);
+ MYSQL_MUTEX_LOCK(&LOCK_prep_xids);
prepared_xids++;
- pthread_mutex_unlock(&LOCK_prep_xids);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prep_xids);
}
else
rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
}
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(0);
@@ -5744,7 +5744,7 @@ err:
write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
}
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_RETURN(1);
}
@@ -5766,7 +5766,7 @@ void MYSQL_BIN_LOG::wait_for_update_rela
"Slave has read all relay log; "
"waiting for the slave I/O "
"thread to update it" );
- pthread_cond_wait(&update_cond, &LOCK_log);
+ MYSQL_COND_WAIT(&update_cond, &LOCK_log);
thd->exit_cond(old_msg);
DBUG_VOID_RETURN;
}
@@ -5798,9 +5798,9 @@ int MYSQL_BIN_LOG::wait_for_update_bin_l
"Master has sent all binlog to slave; "
"waiting for binlog to be updated");
if (!timeout)
- pthread_cond_wait(&update_cond, &LOCK_log);
+ MYSQL_COND_WAIT(&update_cond, &LOCK_log);
else
- ret= pthread_cond_timedwait(&update_cond, &LOCK_log,
+ ret= MYSQL_COND_TIMEDWAIT(&update_cond, &LOCK_log,
const_cast<struct timespec *>(timeout));
DBUG_RETURN(ret);
}
@@ -5887,10 +5887,10 @@ void MYSQL_BIN_LOG::set_max_size(ulong m
it's like if the SET command was never run.
*/
DBUG_ENTER("MYSQL_BIN_LOG::set_max_size");
- pthread_mutex_lock(&LOCK_log);
+ MYSQL_MUTEX_LOCK(&LOCK_log);
if (is_open())
max_size= max_size_arg;
- pthread_mutex_unlock(&LOCK_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_log);
DBUG_VOID_RETURN;
}
@@ -5962,7 +5962,7 @@ bool flush_error_log()
char err_renamed[FN_REFLEN], *end;
end= strmake(err_renamed,log_error_file,FN_REFLEN-4);
strmov(end, "-old");
- pthread_mutex_lock(&LOCK_error_log);
+ MYSQL_MUTEX_LOCK(&LOCK_error_log);
#ifdef __WIN__
char err_temp[FN_REFLEN+4];
/*
@@ -6001,7 +6001,7 @@ bool flush_error_log()
else
result= 1;
#endif
- pthread_mutex_unlock(&LOCK_error_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_error_log);
}
return result;
}
@@ -6009,7 +6009,7 @@ bool flush_error_log()
void MYSQL_BIN_LOG::signal_update()
{
DBUG_ENTER("MYSQL_BIN_LOG::signal_update");
- pthread_cond_broadcast(&update_cond);
+ MYSQL_COND_BROADCAST(&update_cond);
DBUG_VOID_RETURN;
}
@@ -6075,7 +6075,7 @@ static void print_buffer_to_file(enum lo
DBUG_ENTER("print_buffer_to_file");
DBUG_PRINT("enter",("buffer: %s", buffer));
- pthread_mutex_lock(&LOCK_error_log);
+ MYSQL_MUTEX_LOCK(&LOCK_error_log);
skr= my_time(0);
localtime_r(&skr, &tm_tmp);
@@ -6094,7 +6094,7 @@ static void print_buffer_to_file(enum lo
fflush(stderr);
- pthread_mutex_unlock(&LOCK_error_log);
+ MYSQL_MUTEX_UNLOCK(&LOCK_error_log);
DBUG_VOID_RETURN;
}
@@ -6268,8 +6268,8 @@ int TC_LOG_MMAP::open(const char *opt_na
pg->next=pg+1;
pg->waiters=0;
pg->state=POOL;
- pthread_mutex_init(&pg->lock, MY_MUTEX_INIT_FAST);
- pthread_cond_init (&pg->cond, 0);
+ MYSQL_MUTEX_INIT(&pg->lock, key_PAGE_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT (&pg->cond, key_PAGE_cond, 0);
pg->start=(my_xid *)(data + i*tc_log_page_size);
pg->ptr=pg->start;
pg->end=(my_xid *)(pg->start + tc_log_page_size);
@@ -6289,11 +6289,11 @@ int TC_LOG_MMAP::open(const char *opt_na
my_msync(fd, data, tc_log_page_size, MS_SYNC);
inited=5;
- pthread_mutex_init(&LOCK_sync, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&LOCK_active, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&LOCK_pool, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_active, 0);
- pthread_cond_init(&COND_pool, 0);
+ MYSQL_MUTEX_INIT(&LOCK_sync, key_LOCK_sync, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_active, key_LOCK_active, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_pool, key_LOCK_pool, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_active, key_COND_active, 0);
+ MYSQL_COND_INIT(&COND_pool, key_COND_pool, 0);
inited=6;
@@ -6327,7 +6327,7 @@ void TC_LOG_MMAP::get_active_from_pool()
int best_free;
if (syncing)
- pthread_mutex_lock(&LOCK_pool);
+ MYSQL_MUTEX_LOCK(&LOCK_pool);
do
{
@@ -6360,7 +6360,7 @@ void TC_LOG_MMAP::get_active_from_pool()
pool_last=*best_p;
if (syncing)
- pthread_mutex_unlock(&LOCK_pool);
+ MYSQL_MUTEX_UNLOCK(&LOCK_pool);
}
/**
@@ -6375,7 +6375,7 @@ int TC_LOG_MMAP::overflow()
let's check the behaviour of tc_log_page_waits first
*/
tc_log_page_waits++;
- pthread_cond_wait(&COND_pool, &LOCK_pool);
+ MYSQL_COND_WAIT(&COND_pool, &LOCK_pool);
return 1; // always return 1
}
@@ -6412,7 +6412,7 @@ int TC_LOG_MMAP::log_xid(THD *thd, my_xi
PAGE *p;
ulong cookie;
- pthread_mutex_lock(&LOCK_active);
+ MYSQL_MUTEX_LOCK(&LOCK_active);
/*
if active page is full - just wait...
@@ -6422,14 +6422,14 @@ int TC_LOG_MMAP::log_xid(THD *thd, my_xi
unlog() does not signal COND_active.
*/
while (unlikely(active && active->free == 0))
- pthread_cond_wait(&COND_active, &LOCK_active);
+ MYSQL_COND_WAIT(&COND_active, &LOCK_active);
/* no active page ? take one from the pool */
if (active == 0)
get_active_from_pool();
p=active;
- pthread_mutex_lock(&p->lock);
+ MYSQL_MUTEX_LOCK(&p->lock);
/* searching for an empty slot */
while (*p->ptr)
@@ -6445,9 +6445,9 @@ int TC_LOG_MMAP::log_xid(THD *thd, my_xi
p->state= DIRTY;
/* to sync or not to sync - this is the question */
- pthread_mutex_unlock(&LOCK_active);
- pthread_mutex_lock(&LOCK_sync);
- pthread_mutex_unlock(&p->lock);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active);
+ MYSQL_MUTEX_LOCK(&LOCK_sync);
+ MYSQL_MUTEX_UNLOCK(&p->lock);
if (syncing)
{ // somebody's syncing. let's wait
@@ -6457,24 +6457,24 @@ int TC_LOG_MMAP::log_xid(THD *thd, my_xi
as p->state may be not DIRTY when we come here
*/
while (p->state == DIRTY && syncing)
- pthread_cond_wait(&p->cond, &LOCK_sync);
+ MYSQL_COND_WAIT(&p->cond, &LOCK_sync);
p->waiters--;
err= p->state == ERROR;
if (p->state != DIRTY) // page was synced
{
if (p->waiters == 0)
- pthread_cond_signal(&COND_pool); // in case somebody's waiting
- pthread_mutex_unlock(&LOCK_sync);
+ MYSQL_COND_SIGNAL(&COND_pool); // in case somebody's waiting
+ MYSQL_MUTEX_UNLOCK(&LOCK_sync);
goto done; // we're done
}
} // page was not synced! do it now
DBUG_ASSERT(active == p && syncing == 0);
- pthread_mutex_lock(&LOCK_active);
+ MYSQL_MUTEX_LOCK(&LOCK_active);
syncing=p; // place is vacant - take it
active=0; // page is not active anymore
- pthread_cond_broadcast(&COND_active); // in case somebody's waiting
- pthread_mutex_unlock(&LOCK_active);
- pthread_mutex_unlock(&LOCK_sync);
+ MYSQL_COND_BROADCAST(&COND_active); // in case somebody's waiting
+ MYSQL_MUTEX_UNLOCK(&LOCK_active);
+ MYSQL_MUTEX_UNLOCK(&LOCK_sync);
err= sync();
done:
@@ -6494,20 +6494,20 @@ int TC_LOG_MMAP::sync()
err= my_msync(fd, syncing->start, 1, MS_SYNC);
/* page is synced. let's move it to the pool */
- pthread_mutex_lock(&LOCK_pool);
+ MYSQL_MUTEX_LOCK(&LOCK_pool);
pool_last->next=syncing;
pool_last=syncing;
syncing->next=0;
syncing->state= err ? ERROR : POOL;
- pthread_cond_broadcast(&syncing->cond); // signal "sync done"
- pthread_cond_signal(&COND_pool); // in case somebody's waiting
- pthread_mutex_unlock(&LOCK_pool);
+ MYSQL_COND_BROADCAST(&syncing->cond); // signal "sync done"
+ MYSQL_COND_SIGNAL(&COND_pool); // in case somebody's waiting
+ MYSQL_MUTEX_UNLOCK(&LOCK_pool);
/* marking 'syncing' slot free */
- pthread_mutex_lock(&LOCK_sync);
+ MYSQL_MUTEX_LOCK(&LOCK_sync);
syncing=0;
- pthread_cond_signal(&active->cond); // wake up a new syncer
- pthread_mutex_unlock(&LOCK_sync);
+ MYSQL_COND_SIGNAL(&active->cond); // wake up a new syncer
+ MYSQL_MUTEX_UNLOCK(&LOCK_sync);
return err;
}
@@ -6525,15 +6525,15 @@ void TC_LOG_MMAP::unlog(ulong cookie, my
DBUG_ASSERT(x >= p->start && x < p->end);
*x=0;
- pthread_mutex_lock(&p->lock);
+ MYSQL_MUTEX_LOCK(&p->lock);
p->free++;
DBUG_ASSERT(p->free <= p->size);
set_if_smaller(p->ptr, x);
if (p->free == p->size) // the page is completely empty
statistic_decrement(tc_log_cur_pages_used, &LOCK_status);
if (p->waiters == 0) // the page is in pool and ready to rock
- pthread_cond_signal(&COND_pool); // ping ... for overflow()
- pthread_mutex_unlock(&p->lock);
+ MYSQL_COND_SIGNAL(&COND_pool); // ping ... for overflow()
+ MYSQL_MUTEX_UNLOCK(&p->lock);
}
void TC_LOG_MMAP::close()
@@ -6541,10 +6541,10 @@ void TC_LOG_MMAP::close()
uint i;
switch (inited) {
case 6:
- pthread_mutex_destroy(&LOCK_sync);
- pthread_mutex_destroy(&LOCK_active);
- pthread_mutex_destroy(&LOCK_pool);
- pthread_cond_destroy(&COND_pool);
+ MYSQL_MUTEX_DESTROY(&LOCK_sync);
+ MYSQL_MUTEX_DESTROY(&LOCK_active);
+ MYSQL_MUTEX_DESTROY(&LOCK_pool);
+ MYSQL_COND_DESTROY(&COND_pool);
case 5:
data[0]='A'; // garble the first (signature) byte, in case my_delete fails
case 4:
@@ -6552,8 +6552,8 @@ void TC_LOG_MMAP::close()
{
if (pages[i].ptr == 0)
break;
- pthread_mutex_destroy(&pages[i].lock);
- pthread_cond_destroy(&pages[i].cond);
+ MYSQL_MUTEX_DESTROY(&pages[i].lock);
+ MYSQL_COND_DESTROY(&pages[i].cond);
}
case 3:
my_free((uchar*)pages, MYF(0));
@@ -6668,8 +6668,8 @@ int TC_LOG_BINLOG::open(const char *opt_
DBUG_ASSERT(total_ha_2pc > 1);
DBUG_ASSERT(opt_name && opt_name[0]);
- pthread_mutex_init(&LOCK_prep_xids, MY_MUTEX_INIT_FAST);
- pthread_cond_init (&COND_prep_xids, 0);
+ MYSQL_MUTEX_INIT(&LOCK_prep_xids, key_BINLOG_LOCK_prep_xids, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_prep_xids, key_BINLOG_COND_prep_xids, 0);
if (!my_b_inited(&index_file))
{
@@ -6749,8 +6749,8 @@ err:
void TC_LOG_BINLOG::close()
{
DBUG_ASSERT(prepared_xids==0);
- pthread_mutex_destroy(&LOCK_prep_xids);
- pthread_cond_destroy (&COND_prep_xids);
+ MYSQL_MUTEX_DESTROY(&LOCK_prep_xids);
+ MYSQL_COND_DESTROY (&COND_prep_xids);
}
/**
@@ -6777,13 +6777,13 @@ int TC_LOG_BINLOG::log_xid(THD *thd, my_
void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
{
- pthread_mutex_lock(&LOCK_prep_xids);
+ MYSQL_MUTEX_LOCK(&LOCK_prep_xids);
DBUG_ASSERT(prepared_xids > 0);
if (--prepared_xids == 0) {
DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids));
- pthread_cond_signal(&COND_prep_xids);
+ MYSQL_COND_SIGNAL(&COND_prep_xids);
}
- pthread_mutex_unlock(&LOCK_prep_xids);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prep_xids);
rotate_and_purge(0); // as ::write() did not rotate
}
=== modified file 'sql/log.h'
--- a/sql/log.h 2008-08-27 17:30:49 +0000
+++ b/sql/log.h 2008-10-10 20:34:55 +0000
@@ -92,6 +92,17 @@ public:
};
#ifdef HAVE_MMAP
+
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_PAGE_lock;
+extern PSI_cond_key key_PAGE_cond;
+extern PSI_mutex_key key_LOCK_sync;
+extern PSI_mutex_key key_LOCK_active;
+extern PSI_mutex_key key_LOCK_pool;
+extern PSI_cond_key key_COND_active;
+extern PSI_cond_key key_COND_pool;
+#endif
+
class TC_LOG_MMAP: public TC_LOG
{
public: // only to keep Sun Forte on sol9x86 happy
@@ -109,8 +120,8 @@ class TC_LOG_MMAP: public TC_LOG
int size, free; // max and current number of free xid slots on the page
int waiters; // number of waiters on condition
PAGE_STATE state; // see above
- pthread_mutex_t lock; // to access page data or control structure
- pthread_cond_t cond; // to wait for a sync
+ mysql_mutex_t lock; // to access page data or control structure
+ mysql_cond_t cond; // to wait for a sync
} PAGE;
char logname[FN_REFLEN];
@@ -125,8 +136,8 @@ class TC_LOG_MMAP: public TC_LOG
one has to use active->lock.
Same for LOCK_pool and LOCK_sync
*/
- pthread_mutex_t LOCK_active, LOCK_pool, LOCK_sync;
- pthread_cond_t COND_pool, COND_active;
+ mysql_mutex_t LOCK_active, LOCK_pool, LOCK_sync;
+ mysql_cond_t COND_pool, COND_active;
public:
TC_LOG_MMAP(): inited(0) {}
@@ -165,6 +176,10 @@ extern TC_LOG_DUMMY tc_log_dummy;
#define LOG_CLOSE_TO_BE_OPENED 2
#define LOG_CLOSE_STOP_EVENT 4
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOG_INFO_lock;
+#endif
+
class Relay_log_info;
typedef struct st_log_info
@@ -173,15 +188,15 @@ typedef struct st_log_info
my_off_t index_file_offset, index_file_start_offset;
my_off_t pos;
bool fatal; // if the purge happens to give us a negative offset
- pthread_mutex_t lock;
+ mysql_mutex_t lock;
st_log_info()
: index_file_offset(0), index_file_start_offset(0),
pos(0), fatal(0)
{
log_file_name[0] = '\0';
- pthread_mutex_init(&lock, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&lock, key_LOG_INFO_lock, MY_MUTEX_INIT_FAST);
}
- ~st_log_info() { pthread_mutex_destroy(&lock);}
+ ~st_log_info() { MYSQL_MUTEX_DESTROY(&lock);}
} LOG_INFO;
/*
@@ -206,6 +221,10 @@ enum enum_log_state { LOG_OPENED, LOG_CL
(mmap+fsync is two times faster than write+fsync)
*/
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOG_LOCK_log;
+#endif
+
class MYSQL_LOG
{
public:
@@ -225,7 +244,7 @@ public:
int generate_new_name(char *new_name, const char *log_name);
protected:
/* LOCK_log is inited by init_pthread_objects() */
- pthread_mutex_t LOCK_log;
+ mysql_mutex_t LOCK_log;
char *name;
char log_file_name[FN_REFLEN];
char time_buff[20], db[NAME_LEN + 1];
@@ -267,18 +286,22 @@ private:
time_t last_time;
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_backupid;
+#endif
+
class MYSQL_BACKUP_LOG: public MYSQL_LOG
{
public:
MYSQL_BACKUP_LOG ()
{
headers_written= FALSE;
- pthread_mutex_init(&LOCK_backupid, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_backupid, key_LOCK_backupid, MY_MUTEX_INIT_FAST);
m_next_id= 0;
}
~MYSQL_BACKUP_LOG()
{
- pthread_mutex_destroy(&LOCK_backupid);
+ MYSQL_MUTEX_DESTROY(&LOCK_backupid);
}
void reopen_file(bool history);
bool write(THD *thd, st_backup_history *history_data);
@@ -314,17 +337,24 @@ private:
bool write_str(const char *str);
bool headers_written;
ulonglong m_next_id; ///< the next available backup_id
- pthread_mutex_t LOCK_backupid; ///< mutex for backupid generation
+ mysql_mutex_t LOCK_backupid; ///< mutex for backupid generation
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_BINLOG_LOCK_index;
+extern PSI_mutex_key key_BINLOG_LOCK_prep_xids;
+extern PSI_cond_key key_BINLOG_COND_prep_xids;
+extern PSI_cond_key key_BINLOG_update_cond;
+#endif
+
class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
{
private:
/* LOCK_log and LOCK_index are inited by init_pthread_objects() */
- pthread_mutex_t LOCK_index;
- pthread_mutex_t LOCK_prep_xids;
- pthread_cond_t COND_prep_xids;
- pthread_cond_t update_cond;
+ mysql_mutex_t LOCK_index;
+ mysql_mutex_t LOCK_prep_xids;
+ mysql_cond_t COND_prep_xids;
+ mysql_cond_t update_cond;
ulonglong bytes_written;
IO_CACHE index_file;
char index_file_name[FN_REFLEN];
@@ -477,11 +507,11 @@ public:
inline char* get_index_fname() { return index_file_name;}
inline char* get_log_fname() { return log_file_name; }
inline char* get_name() { return name; }
- inline pthread_mutex_t* get_log_lock() { return &LOCK_log; }
+ inline mysql_mutex_t* get_log_lock() { return &LOCK_log; }
inline IO_CACHE* get_log_file() { return &log_file; }
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
+ inline void lock_index() { MYSQL_MUTEX_LOCK(&LOCK_index);}
+ inline void unlock_index() { MYSQL_MUTEX_UNLOCK(&LOCK_index);}
inline IO_CACHE *get_index_file() { return &index_file;}
inline uint32 get_open_count() { return open_count; }
};
@@ -623,6 +653,9 @@ public:
{ return &mysql_backup_progress_log; }
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_logger;
+#endif
/*
Class which manages slow, general, error log, backup history, and
@@ -630,7 +663,7 @@ public:
*/
class LOGGER
{
- rw_lock_t LOCK_logger;
+ mysql_rwlock_t LOCK_logger;
/* flag to check whether logger mutex is initialized */
uint inited;
@@ -652,9 +685,9 @@ public:
LOGGER() : inited(0), table_log_handler(NULL),
file_log_handler(NULL), is_log_tables_initialized(FALSE)
{}
- void lock_shared() { rw_rdlock(&LOCK_logger); }
- void lock_exclusive() { rw_wrlock(&LOCK_logger); }
- void unlock() { rw_unlock(&LOCK_logger); }
+ void lock_shared() { MYSQL_RWLOCK_RDLOCK(&LOCK_logger); }
+ void lock_exclusive() { MYSQL_RWLOCK_WRLOCK(&LOCK_logger); }
+ void unlock() { MYSQL_RWLOCK_UNLOCK(&LOCK_logger); }
bool is_log_table_enabled(uint log_table_type);
bool log_command(THD *thd, enum enum_server_command command);
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2008-09-04 18:30:34 +0000
+++ b/sql/log_event.cc 2008-10-10 20:34:55 +0000
@@ -874,7 +874,7 @@ bool Log_event::write_header(IO_CACHE* f
*/
int Log_event::read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock)
+ mysql_mutex_t* log_lock)
{
ulong data_len;
int result=0;
@@ -882,7 +882,7 @@ int Log_event::read_log_event(IO_CACHE*
DBUG_ENTER("Log_event::read_log_event");
if (log_lock)
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
if (my_b_read(file, (uchar*) buf, sizeof(buf)))
{
/*
@@ -940,14 +940,14 @@ int Log_event::read_log_event(IO_CACHE*
end:
if (log_lock)
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
DBUG_RETURN(result);
}
#endif /* !MYSQL_CLIENT */
#ifndef MYSQL_CLIENT
-#define UNLOCK_MUTEX if (log_lock) pthread_mutex_unlock(log_lock);
-#define LOCK_MUTEX if (log_lock) pthread_mutex_lock(log_lock);
+#define UNLOCK_MUTEX if (log_lock) MYSQL_MUTEX_UNLOCK(log_lock);
+#define LOCK_MUTEX if (log_lock) MYSQL_MUTEX_LOCK(log_lock);
#else
#define UNLOCK_MUTEX
#define LOCK_MUTEX
@@ -959,7 +959,7 @@ end:
Allocates memory; The caller is responsible for clean-up.
*/
Log_event* Log_event::read_log_event(IO_CACHE* file,
- pthread_mutex_t* log_lock,
+ mysql_mutex_t* log_lock,
const Format_description_log_event
*description_event)
#else
@@ -2914,9 +2914,9 @@ int Query_log_event::do_apply_event(Rela
thd->set_time((time_t)when);
thd->query_length= q_len_arg;
thd->query= (char*)query_arg;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query_id = next_query_id();
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thd->variables.pseudo_thread_id= thread_id; // for temp tables
DBUG_PRINT("query",("%s",thd->query));
@@ -3117,7 +3117,7 @@ Default database: '%s'. Query: '%s'",
} /* End of if (db_ok(... */
end:
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
/*
Probably we have set thd->query, thd->db, thd->catalog to point to places
in the data_buf of this event. Now the event is going to be deleted
@@ -3133,7 +3133,7 @@ end:
DBUG_PRINT("info", ("end: query= 0"));
thd->query= 0; // just to be sure
thd->query_length= 0;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
close_thread_tables(thd);
/*
As a disk space optimization, future masters will not log an event for
@@ -4355,9 +4355,9 @@ int Load_log_event::do_apply_event(NET*
if (rpl_filter->db_ok(thd->db))
{
thd->set_time((time_t)when);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query_id = next_query_id();
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
/*
Initing thd->row_count is not necessary in theory as this variable has no
influence in the case of the slave SQL thread (it is used to generate a
@@ -4511,12 +4511,12 @@ int Load_log_event::do_apply_event(NET*
error:
thd->net.vio = 0;
const char *remember_db= thd->db;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->catalog= 0;
thd->set_db(NULL, 0); /* will free the current database */
thd->query= 0;
thd->query_length= 0;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
close_thread_tables(thd);
DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error",
@@ -4701,7 +4701,7 @@ int Rotate_log_event::do_update_pos(Rela
DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident));
DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf)));
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
rli->event_relay_log_pos= my_b_tell(rli->cur_log);
/*
If we are in a transaction or in a group: the only normal case is
@@ -4750,8 +4750,8 @@ int Rotate_log_event::do_update_pos(Rela
thd->variables.auto_increment_increment=
thd->variables.auto_increment_offset= 1;
}
- pthread_mutex_unlock(&rli->data_lock);
- pthread_cond_broadcast(&rli->data_cond);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
+ MYSQL_COND_BROADCAST(&rli->data_cond);
flush_relay_log_info(rli);
DBUG_RETURN(0);
@@ -5550,8 +5550,8 @@ Slave_log_event::Slave_log_event(THD* th
Master_info* mi = rli->mi;
// TODO: re-write this better without holding both locks at the same time
- pthread_mutex_lock(&mi->data_lock);
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&mi->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
master_host_len = strlen(mi->host);
master_log_len = strlen(rli->group_master_log_name);
// on OOM, just do not initialize the structure and print the error
@@ -5569,8 +5569,8 @@ Slave_log_event::Slave_log_event(THD* th
}
else
sql_print_error("Out of memory while recording slave event");
- pthread_mutex_unlock(&rli->data_lock);
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_VOID_RETURN;
}
#endif /* !MYSQL_CLIENT */
@@ -6335,7 +6335,7 @@ int Execute_load_log_event::do_apply_eve
goto err;
}
if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
- (pthread_mutex_t*)0,
+ (mysql_mutex_t*)0,
rli->relay_log.description_event_for_exec)) ||
lev->get_type_code() != NEW_LOAD_EVENT)
{
@@ -7858,9 +7858,9 @@ int Table_map_log_event::do_apply_event(
DBUG_ASSERT(rli->sql_thd == thd);
/* Step the query id to mark what columns that are actually used. */
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query_id= next_query_id();
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (!(memory= my_multi_malloc(MYF(MY_WME),
&table_list, (uint) sizeof(RPL_TABLE_LIST),
=== modified file 'sql/log_event.h'
--- a/sql/log_event.h 2008-09-09 08:19:21 +0000
+++ b/sql/log_event.h 2008-10-10 20:34:55 +0000
@@ -920,11 +920,11 @@ public:
constructor and pass description_event as an argument.
*/
static Log_event* read_log_event(IO_CACHE* file,
- pthread_mutex_t* log_lock,
+ mysql_mutex_t* log_lock,
const Format_description_log_event
*description_event);
static int read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock);
+ mysql_mutex_t* log_lock);
/*
init_show_field_list() prepares the column names and types for the
output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc 2008-08-13 10:36:29 +0000
+++ b/sql/mdl.cc 2008-10-10 20:34:55 +0000
@@ -66,9 +66,13 @@ struct MDL_LOCK
}
};
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_mdl;
+PSI_cond_key key_COND_mdl;
+#endif
-pthread_mutex_t LOCK_mdl;
-pthread_cond_t COND_mdl;
+mysql_mutex_t LOCK_mdl;
+mysql_cond_t COND_mdl;
HASH mdl_locks;
/**
@@ -117,8 +121,8 @@ extern "C" uchar *mdl_locks_key(const uc
void mdl_init()
{
mdl_initialized= 1;
- pthread_mutex_init(&LOCK_mdl, NULL);
- pthread_cond_init(&COND_mdl, NULL);
+ MYSQL_MUTEX_INIT(&LOCK_mdl, key_LOCK_mdl, NULL);
+ MYSQL_COND_INIT(&COND_mdl, key_COND_mdl, NULL);
hash_init(&mdl_locks, &my_charset_bin, 16 /* FIXME */, 0, 0,
mdl_locks_key, 0, 0);
global_lock.waiting_shared= global_lock.active_shared= 0;
@@ -139,8 +143,8 @@ void mdl_destroy()
{
mdl_initialized= 0;
DBUG_ASSERT(!mdl_locks.records);
- pthread_mutex_destroy(&LOCK_mdl);
- pthread_cond_destroy(&COND_mdl);
+ MYSQL_MUTEX_DESTROY(&LOCK_mdl);
+ MYSQL_COND_DESTROY(&COND_mdl);
hash_free(&mdl_locks);
}
}
@@ -465,7 +469,7 @@ static inline const char* mdl_enter_cond
const char *calling_file,
const unsigned int calling_line)
{
- safe_mutex_assert_owner(&LOCK_mdl);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_mdl);
mysys_var->current_mutex= &LOCK_mdl;
mysys_var->current_cond= &COND_mdl;
@@ -485,11 +489,11 @@ static inline void mdl_exit_cond(MDL_CON
{
DBUG_ASSERT(&LOCK_mdl == mysys_var->current_mutex);
- pthread_mutex_unlock(&LOCK_mdl);
- pthread_mutex_lock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&mysys_var->mutex);
mysys_var->current_mutex= 0;
mysys_var->current_cond= 0;
- pthread_mutex_unlock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&mysys_var->mutex);
(void) set_thd_proc_info(context->thd, old_msg, calling_func,
calling_file, calling_line);
@@ -718,7 +722,7 @@ bool mdl_acquire_shared_lock(MDL_CONTEXT
DBUG_ASSERT(lock_data->ctx == context);
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
if (context->has_global_shared_lock &&
lock_data->type == MDL_SHARED_UPGRADABLE)
@@ -727,11 +731,11 @@ bool mdl_acquire_shared_lock(MDL_CONTEXT
return TRUE;
}
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
if (!can_grant_global_lock(lock_data))
{
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
*retry= TRUE;
return TRUE;
}
@@ -741,7 +745,7 @@ bool mdl_acquire_shared_lock(MDL_CONTEXT
{
if (!(lock= get_lock_object()))
{
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
return TRUE;
}
/*
@@ -754,7 +758,7 @@ bool mdl_acquire_shared_lock(MDL_CONTEXT
if (my_hash_insert(&mdl_locks, (uchar*)lock))
{
release_lock_object(lock);
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
return TRUE;
}
lock_data->state= MDL_ACQUIRED;
@@ -776,7 +780,7 @@ bool mdl_acquire_shared_lock(MDL_CONTEXT
else
*retry= TRUE;
}
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
return *retry;
}
@@ -809,7 +813,7 @@ bool mdl_acquire_exclusive_locks(MDL_CON
I_P_List_iterator<MDL_LOCK_DATA, MDL_LOCK_DATA_context> it(context->locks);
st_my_thread_var *mysys_var= my_thread_var;
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
if (context->has_global_shared_lock)
{
@@ -817,7 +821,7 @@ bool mdl_acquire_exclusive_locks(MDL_CON
return TRUE;
}
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
old_msg= MDL_ENTER_COND(context, mysys_var);
@@ -891,7 +895,7 @@ bool mdl_acquire_exclusive_locks(MDL_CON
if (!lock_data)
break;
if (signalled)
- pthread_cond_wait(&COND_mdl, &LOCK_mdl);
+ MYSQL_COND_WAIT(&COND_mdl, &LOCK_mdl);
else
{
/*
@@ -902,7 +906,7 @@ bool mdl_acquire_exclusive_locks(MDL_CON
*/
struct timespec abstime;
set_timespec(abstime, 10);
- pthread_cond_timedwait(&COND_mdl, &LOCK_mdl, &abstime);
+ MYSQL_COND_TIMEDWAIT(&COND_mdl, &LOCK_mdl, &abstime);
}
if (mysys_var->abort)
goto err;
@@ -935,7 +939,7 @@ err:
lock_data->state= MDL_INITIALIZED;
}
/* May be some pending requests for shared locks can be satisfied now. */
- pthread_cond_broadcast(&COND_mdl);
+ MYSQL_COND_BROADCAST(&COND_mdl);
MDL_EXIT_COND(context, mysys_var, old_msg);
return TRUE;
}
@@ -967,7 +971,7 @@ bool mdl_upgrade_shared_lock_to_exclusiv
DBUG_ENTER("mdl_upgrade_shared_lock_to_exclusive");
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
DBUG_ASSERT(lock_data->state == MDL_ACQUIRED);
@@ -979,7 +983,7 @@ bool mdl_upgrade_shared_lock_to_exclusiv
lock= lock_data->lock;
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
old_msg= MDL_ENTER_COND(context, mysys_var);
@@ -1022,7 +1026,7 @@ bool mdl_upgrade_shared_lock_to_exclusiv
}
if (signalled)
- pthread_cond_wait(&COND_mdl, &LOCK_mdl);
+ MYSQL_COND_WAIT(&COND_mdl, &LOCK_mdl);
else
{
/*
@@ -1034,7 +1038,7 @@ bool mdl_upgrade_shared_lock_to_exclusiv
struct timespec abstime;
set_timespec(abstime, 10);
DBUG_PRINT("info", ("Failed to wake-up from table-level lock ... sleeping"));
- pthread_cond_timedwait(&COND_mdl, &LOCK_mdl, &abstime);
+ MYSQL_COND_TIMEDWAIT(&COND_mdl, &LOCK_mdl, &abstime);
}
if (mysys_var->abort)
{
@@ -1043,7 +1047,7 @@ bool mdl_upgrade_shared_lock_to_exclusiv
lock->active_shared_waiting_upgrade.remove(lock_data);
lock->active_shared.push_front(lock_data);
/* Pending requests for shared locks can be satisfied now. */
- pthread_cond_broadcast(&COND_mdl);
+ MYSQL_COND_BROADCAST(&COND_mdl);
MDL_EXIT_COND(context, mysys_var, old_msg);
DBUG_RETURN(TRUE);
}
@@ -1095,11 +1099,11 @@ bool mdl_try_acquire_exclusive_lock(MDL_
DBUG_ASSERT(lock_data->type == MDL_EXCLUSIVE &&
lock_data->state == MDL_INITIALIZED);
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
*conflict= FALSE;
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
if (!(lock= (MDL_LOCK *)hash_search(&mdl_locks, (uchar*)lock_data->key,
lock_data->key_length)))
@@ -1116,7 +1120,7 @@ bool mdl_try_acquire_exclusive_lock(MDL_
lock_data->state= MDL_ACQUIRED;
lock_data->lock= lock;
global_lock.active_intention_exclusive++;
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
return FALSE;
}
@@ -1124,7 +1128,7 @@ bool mdl_try_acquire_exclusive_lock(MDL_
*conflict= TRUE;
err:
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
return TRUE;
}
@@ -1146,16 +1150,16 @@ bool mdl_acquire_global_shared_lock(MDL_
st_my_thread_var *mysys_var= my_thread_var;
const char *old_msg;
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
DBUG_ASSERT(!context->has_global_shared_lock);
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
global_lock.waiting_shared++;
old_msg= MDL_ENTER_COND(context, mysys_var);
while (!mysys_var->abort && global_lock.active_intention_exclusive)
- pthread_cond_wait(&COND_mdl, &LOCK_mdl);
+ MYSQL_COND_WAIT(&COND_mdl, &LOCK_mdl);
global_lock.waiting_shared--;
if (mysys_var->abort)
@@ -1195,7 +1199,7 @@ bool mdl_wait_for_locks(MDL_CONTEXT *con
const char *old_msg;
st_my_thread_var *mysys_var= my_thread_var;
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
while (!mysys_var->abort)
{
@@ -1210,7 +1214,7 @@ bool mdl_wait_for_locks(MDL_CONTEXT *con
COND_mdl because of above scenario.
*/
mysql_ha_flush(context->thd);
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
old_msg= MDL_ENTER_COND(context, mysys_var);
it.rewind();
while ((lock_data= it++))
@@ -1230,10 +1234,10 @@ bool mdl_wait_for_locks(MDL_CONTEXT *con
}
if (!lock_data)
{
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
break;
}
- pthread_cond_wait(&COND_mdl, &LOCK_mdl);
+ MYSQL_COND_WAIT(&COND_mdl, &LOCK_mdl);
/* As a side-effect MDL_EXIT_COND() unlocks LOCK_mdl. */
MDL_EXIT_COND(context, mysys_var, old_msg);
}
@@ -1319,9 +1323,9 @@ void mdl_release_locks(MDL_CONTEXT *cont
I_P_List_iterator<MDL_LOCK_DATA, MDL_LOCK_DATA_context> it(context->locks);
DBUG_ENTER("mdl_release_locks");
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
while ((lock_data= it++))
{
DBUG_PRINT("info", ("found lock to release lock_data=%p", lock_data));
@@ -1346,8 +1350,8 @@ void mdl_release_locks(MDL_CONTEXT *cont
*/
}
/* Inefficient but will do for a while */
- pthread_cond_broadcast(&COND_mdl);
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_COND_BROADCAST(&COND_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
DBUG_VOID_RETURN;
}
@@ -1362,16 +1366,16 @@ void mdl_release_locks(MDL_CONTEXT *cont
void mdl_release_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data)
{
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
release_lock(lock_data);
#ifndef DBUG_OFF
lock_data->lock= 0;
#endif
lock_data->state= MDL_INITIALIZED;
- pthread_cond_broadcast(&COND_mdl);
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_COND_BROADCAST(&COND_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
}
@@ -1424,7 +1428,7 @@ void mdl_downgrade_exclusive_lock(MDL_CO
{
MDL_LOCK *lock;
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
DBUG_ASSERT(lock_data->state == MDL_ACQUIRED);
@@ -1433,12 +1437,12 @@ void mdl_downgrade_exclusive_lock(MDL_CO
lock= lock_data->lock;
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
lock->active_exclusive.remove(lock_data);
lock_data->type= MDL_SHARED_UPGRADABLE;
lock->active_shared.push_front(lock_data);
- pthread_cond_broadcast(&COND_mdl);
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_COND_BROADCAST(&COND_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
}
@@ -1450,14 +1454,14 @@ void mdl_downgrade_exclusive_lock(MDL_CO
void mdl_release_global_shared_lock(MDL_CONTEXT *context)
{
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
DBUG_ASSERT(context->has_global_shared_lock);
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
global_lock.active_shared--;
context->has_global_shared_lock= FALSE;
- pthread_cond_broadcast(&COND_mdl);
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_COND_BROADCAST(&COND_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
}
@@ -1543,12 +1547,12 @@ bool mdl_has_pending_conflicting_lock(MD
bool result;
DBUG_ASSERT(is_shared(lock_data) && lock_data->state == MDL_ACQUIRED);
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
- pthread_mutex_lock(&LOCK_mdl);
+ MYSQL_MUTEX_LOCK(&LOCK_mdl);
result= !(lock_data->lock->waiting_exclusive.is_empty() &&
lock_data->lock->active_shared_waiting_upgrade.is_empty());
- pthread_mutex_unlock(&LOCK_mdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mdl);
return result;
}
=== modified file 'sql/mdl.h'
--- a/sql/mdl.h 2008-06-20 13:11:20 +0000
+++ b/sql/mdl.h 2008-10-10 20:34:55 +0000
@@ -253,7 +253,7 @@ extern "C" const char *set_thd_proc_info
const char *calling_file,
const unsigned int calling_line);
#ifndef DBUG_OFF
-extern pthread_mutex_t LOCK_open;
+extern mysql_mutex_t LOCK_open;
#endif
#endif
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h 2008-09-19 09:55:21 +0000
+++ b/sql/mysql_priv.h 2008-10-10 20:34:55 +0000
@@ -1344,7 +1344,7 @@ bool open_new_frm(THD *thd, TABLE_SHARE
uint ha_open_flags, TABLE *outparam,
TABLE_LIST *table_desc, MEM_ROOT *mem_root);
void execute_init_command(THD *thd, sys_var_str *init_command_var,
- rw_lock_t *var_mutex);
+ mysql_rwlock_t *var_mutex);
extern Field *not_found_field;
extern Field *view_ref_found;
@@ -1385,7 +1385,7 @@ struct st_des_keyschedule
extern char *des_key_file;
extern struct st_des_keyschedule des_keyschedule[10];
extern uint des_default_key;
-extern pthread_mutex_t LOCK_des_key_file;
+extern mysql_mutex_t LOCK_des_key_file;
bool load_des_key_file(const char *file_name);
#endif /* HAVE_OPENSSL */
@@ -1593,8 +1593,8 @@ int setup_conds(THD *thd, TABLE_LIST *ta
COND **conds);
int setup_ftfuncs(SELECT_LEX* select);
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
-void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
- pthread_cond_t *cond);
+void wait_for_condition(THD *thd, mysql_mutex_t *mutex,
+ mysql_cond_t *cond);
int open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags);
/* open_and_lock_tables with optional derived handling */
int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived,
@@ -1773,7 +1773,7 @@ void release_ddl_log();
void execute_ddl_log_recovery();
bool execute_ddl_log_entry(THD *thd, uint first_entry);
-extern pthread_mutex_t LOCK_gdl;
+extern mysql_mutex_t LOCK_gdl;
#define WFRM_WRITE_SHADOW 1
#define WFRM_INSTALL_SHADOW 2
@@ -2072,7 +2072,53 @@ extern FILE *bootstrap_file;
extern int bootstrap_error;
extern FILE *stderror_file;
extern pthread_key(MEM_ROOT**,THR_MALLOC);
-extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
+
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_mysql_create_db;
+extern PSI_mutex_key key_LOCK_Acl;
+extern PSI_mutex_key key_LOCK_open;
+extern PSI_mutex_key key_LOCK_lock_db;
+extern PSI_mutex_key key_LOCK_thread_count;
+extern PSI_mutex_key key_LOCK_mapped_file;
+extern PSI_mutex_key key_LOCK_user_locks;
+extern PSI_mutex_key key_LOCK_status;
+extern PSI_mutex_key key_LOCK_error_log;
+extern PSI_mutex_key key_LOCK_delayed_insert;
+extern PSI_mutex_key key_LOCK_uuid_short;
+extern PSI_mutex_key key_LOCK_delayed_status;
+extern PSI_mutex_key key_LOCK_delayed_create;
+extern PSI_mutex_key key_LOCK_crypt;
+extern PSI_mutex_key key_LOCK_timezone;
+extern PSI_mutex_key key_LOCK_slave_list;
+extern PSI_mutex_key key_LOCK_active_mi;
+extern PSI_mutex_key key_LOCK_manager;
+extern PSI_mutex_key key_LOCK_global_read_lock;
+extern PSI_mutex_key key_LOCK_global_system_variables;
+extern PSI_mutex_key key_LOCK_user_conn;
+extern PSI_mutex_key key_LOCK_prepared_stmt_count;
+extern PSI_mutex_key key_LOCK_bytes_sent;
+extern PSI_mutex_key key_LOCK_bytes_received;
+extern PSI_mutex_key key_LOCK_connection_count;
+#ifdef HAVE_OPENSSL
+extern PSI_mutex_key key_LOCK_des_key_file;
+#endif
+extern PSI_mutex_key key_LOCK_server_started;
+extern PSI_cond_key key_COND_server_started;
+extern PSI_rwlock_key key_LOCK_grant;
+extern PSI_rwlock_key key_LOCK_sys_init_connect;
+extern PSI_rwlock_key key_LOCK_sys_init_slave;
+extern PSI_rwlock_key key_LOCK_system_variables_hash;
+extern PSI_cond_key key_COND_refresh;
+extern PSI_cond_key key_COND_thread_count;
+extern PSI_cond_key key_COND_manager;
+extern PSI_cond_key key_COND_global_read_lock;
+extern PSI_cond_key key_COND_thread_cache;
+extern PSI_cond_key key_COND_flush_thread_cache;
+extern PSI_mutex_key key_LOCK_rpl_status;
+extern PSI_cond_key key_COND_rpl_status;
+#endif
+
+extern mysql_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status,
LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_short,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
@@ -2081,15 +2127,15 @@ extern pthread_mutex_t LOCK_mysql_create
LOCK_prepared_stmt_count,
LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
#ifdef HAVE_OPENSSL
-extern pthread_mutex_t LOCK_des_key_file;
+extern mysql_mutex_t LOCK_des_key_file;
#endif
-extern pthread_mutex_t LOCK_server_started;
-extern pthread_cond_t COND_server_started;
+extern mysql_mutex_t LOCK_server_started;
+extern mysql_cond_t COND_server_started;
extern int mysqld_server_started;
-extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
-extern rw_lock_t LOCK_system_variables_hash;
-extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
-extern pthread_cond_t COND_global_read_lock;
+extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
+extern mysql_rwlock_t LOCK_system_variables_hash;
+extern mysql_cond_t COND_refresh, COND_thread_count, COND_manager;
+extern mysql_cond_t COND_global_read_lock;
extern pthread_attr_t connection_attrib;
extern I_List<THD> threads;
extern I_List<NAMED_LIST> key_caches;
@@ -2428,9 +2474,9 @@ inline const char *table_case_name(HA_CR
inline ulong sql_rnd_with_mutex()
{
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
return tmp;
}
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2008-09-08 11:05:26 +0000
+++ b/sql/mysqld.cc 2008-10-10 20:34:55 +0000
@@ -423,7 +423,7 @@ static I_List<THD> thread_cache;
static double long_query_time;
static ulong opt_my_crc_dbug_check;
-static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
+static mysql_cond_t COND_thread_cache, COND_flush_thread_cache;
/* Global variables */
@@ -682,7 +682,7 @@ SHOW_COMP_OPTION have_community_features
pthread_key(MEM_ROOT**,THR_MALLOC);
pthread_key(THD*, THR_THD);
-pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
+mysql_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
LOCK_error_log,
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
@@ -698,17 +698,17 @@ pthread_mutex_t LOCK_mysql_create_db, LO
in the server, respectively. As PREPARE/DEALLOCATE rate in a loaded
server may be fairly high, we need a dedicated lock.
*/
-pthread_mutex_t LOCK_prepared_stmt_count;
+mysql_mutex_t LOCK_prepared_stmt_count;
#ifdef HAVE_OPENSSL
-pthread_mutex_t LOCK_des_key_file;
+mysql_mutex_t LOCK_des_key_file;
#endif
-rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
-rw_lock_t LOCK_system_variables_hash;
-pthread_cond_t COND_refresh, COND_thread_count, COND_global_read_lock;
+mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
+mysql_rwlock_t LOCK_system_variables_hash;
+mysql_cond_t COND_refresh, COND_thread_count, COND_global_read_lock;
pthread_t signal_thread;
pthread_attr_t connection_attrib;
-pthread_mutex_t LOCK_server_started;
-pthread_cond_t COND_server_started;
+mysql_mutex_t LOCK_server_started;
+mysql_cond_t COND_server_started;
int mysqld_server_started= 0;
@@ -755,7 +755,7 @@ static uint thr_kill_signal;
#undef getpid
#include <process.h>
-static pthread_cond_t COND_handler_count;
+static mysql_cond_t COND_handler_count;
static uint handler_count;
static bool start_mode=0, use_opt_args;
static int opt_argc;
@@ -810,7 +810,7 @@ scheduler_functions thread_scheduler;
#ifndef HAVE_YASSL
typedef struct CRYPTO_dynlock_value
{
- rw_lock_t lock;
+ mysql_rwlock_t lock;
} openssl_lock_t;
static openssl_lock_t *openssl_stdlocks;
@@ -888,20 +888,20 @@ static void close_connections(void)
flush_thread_cache();
/* kill flush thread */
- (void) pthread_mutex_lock(&LOCK_manager);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_manager);
if (manager_thread_in_use)
{
DBUG_PRINT("quit", ("killing manager thread: 0x%llx",
(ulonglong)manager_thread));
- (void) pthread_cond_signal(&COND_manager);
+ (void) MYSQL_COND_SIGNAL(&COND_manager);
}
- (void) pthread_mutex_unlock(&LOCK_manager);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_manager);
/* kill connection thread */
#if !defined(__WIN__) && !defined(__NETWARE__)
DBUG_PRINT("quit", ("waiting for select thread: 0x%llx",
(ulonglong)select_thread));
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
while (select_thread_in_use)
{
@@ -917,18 +917,18 @@ static void close_connections(void)
set_timespec(abstime, 2);
for (uint tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
{
- error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count,
+ error=MYSQL_COND_TIMEDWAIT(&COND_thread_count,&LOCK_thread_count,
&abstime);
if (error != EINTR)
break;
}
#ifdef EXTRA_DEBUG
if (error != 0 && error != ETIMEDOUT && !count++)
- sql_print_error("Got error %d from pthread_cond_timedwait",error);
+ sql_print_error("Got error %d from MYSQL_COND_TIMEDWAIT",error);
#endif
close_server_sock();
}
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
#endif /* __WIN__ */
@@ -985,7 +985,7 @@ static void close_connections(void)
*/
THD *tmp;
- (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count); // For unlink from list
I_List_iterator<THD> it(threads);
while ((tmp=it++))
@@ -1001,17 +1001,17 @@ static void close_connections(void)
if (tmp->mysys_var)
{
tmp->mysys_var->abort=1;
- pthread_mutex_lock(&tmp->mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&tmp->mysys_var->mutex);
if (tmp->mysys_var->current_cond)
{
- pthread_mutex_lock(tmp->mysys_var->current_mutex);
- pthread_cond_broadcast(tmp->mysys_var->current_cond);
- pthread_mutex_unlock(tmp->mysys_var->current_mutex);
+ MYSQL_MUTEX_LOCK(tmp->mysys_var->current_mutex);
+ MYSQL_COND_BROADCAST(tmp->mysys_var->current_cond);
+ MYSQL_MUTEX_UNLOCK(tmp->mysys_var->current_mutex);
}
- pthread_mutex_unlock(&tmp->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&tmp->mysys_var->mutex);
}
}
- (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count); // For unlink from list
Events::deinit();
end_slave();
@@ -1028,11 +1028,11 @@ static void close_connections(void)
for (;;)
{
DBUG_PRINT("quit",("Locking LOCK_thread_count"));
- (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count); // For unlink from list
if (!(tmp=threads.get()))
{
DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
break;
}
#ifndef __bsdi__ // Bug in BSDI kernel
@@ -1047,17 +1047,17 @@ static void close_connections(void)
}
#endif
DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
/* All threads has now been aborted */
DBUG_PRINT("quit",("Waiting for threads to die (count=%u)",thread_count));
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
while (thread_count)
{
- (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
+ (void) MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
}
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_PRINT("quit",("close_connections thread"));
DBUG_VOID_RETURN;
@@ -1412,12 +1412,12 @@ void clean_up(bool print_message)
DBUG_PRINT("quit", ("Error messages freed"));
/* Tell main we are ready */
logger.cleanup_end();
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
DBUG_PRINT("quit", ("got thread count lock"));
ready_to_exit=1;
/* do the broadcast inside the lock to ensure that my_end() is not called */
- (void) pthread_cond_broadcast(&COND_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_COND_BROADCAST(&COND_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
my_uuid_end();
/*
@@ -1454,51 +1454,51 @@ static void wait_for_signal_thread_to_en
static void clean_up_mutexes()
{
- (void) pthread_mutex_destroy(&LOCK_mysql_create_db);
- (void) pthread_mutex_destroy(&LOCK_lock_db);
- (void) pthread_mutex_destroy(&LOCK_Acl);
- (void) rwlock_destroy(&LOCK_grant);
- (void) pthread_mutex_destroy(&LOCK_open);
- (void) pthread_mutex_destroy(&LOCK_thread_count);
- (void) pthread_mutex_destroy(&LOCK_mapped_file);
- (void) pthread_mutex_destroy(&LOCK_status);
- (void) pthread_mutex_destroy(&LOCK_error_log);
- (void) pthread_mutex_destroy(&LOCK_delayed_insert);
- (void) pthread_mutex_destroy(&LOCK_delayed_status);
- (void) pthread_mutex_destroy(&LOCK_delayed_create);
- (void) pthread_mutex_destroy(&LOCK_manager);
- (void) pthread_mutex_destroy(&LOCK_crypt);
- (void) pthread_mutex_destroy(&LOCK_bytes_sent);
- (void) pthread_mutex_destroy(&LOCK_bytes_received);
- (void) pthread_mutex_destroy(&LOCK_user_conn);
- (void) pthread_mutex_destroy(&LOCK_connection_count);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_mysql_create_db);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_lock_db);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_Acl);
+ (void) MYSQL_RWLOCK_DESTROY(&LOCK_grant);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_open);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_mapped_file);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_status);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_error_log);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_delayed_insert);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_delayed_status);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_delayed_create);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_manager);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_crypt);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_bytes_sent);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_bytes_received);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_connection_count);
Events::destroy_mutexes();
#ifdef HAVE_OPENSSL
- (void) pthread_mutex_destroy(&LOCK_des_key_file);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_des_key_file);
#ifndef HAVE_YASSL
for (int i= 0; i < CRYPTO_num_locks(); ++i)
- (void) rwlock_destroy(&openssl_stdlocks[i].lock);
+ (void) MYSQL_RWLOCK_DESTROY(&openssl_stdlocks[i].lock);
OPENSSL_free(openssl_stdlocks);
#endif
#endif
#ifdef HAVE_REPLICATION
- (void) pthread_mutex_destroy(&LOCK_rpl_status);
- (void) pthread_cond_destroy(&COND_rpl_status);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_rpl_status);
+ (void) MYSQL_COND_DESTROY(&COND_rpl_status);
#endif
- (void) pthread_mutex_destroy(&LOCK_active_mi);
- (void) rwlock_destroy(&LOCK_sys_init_connect);
- (void) rwlock_destroy(&LOCK_sys_init_slave);
- (void) pthread_mutex_destroy(&LOCK_global_system_variables);
- (void) pthread_mutex_destroy(&LOCK_uuid_short);
- (void) rwlock_destroy(&LOCK_system_variables_hash);
- (void) pthread_mutex_destroy(&LOCK_global_read_lock);
- (void) pthread_mutex_destroy(&LOCK_prepared_stmt_count);
- (void) pthread_cond_destroy(&COND_thread_count);
- (void) pthread_cond_destroy(&COND_refresh);
- (void) pthread_cond_destroy(&COND_global_read_lock);
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_active_mi);
+ (void) MYSQL_RWLOCK_DESTROY(&LOCK_sys_init_connect);
+ (void) MYSQL_RWLOCK_DESTROY(&LOCK_sys_init_slave);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_global_system_variables);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_uuid_short);
+ (void) MYSQL_RWLOCK_DESTROY(&LOCK_system_variables_hash);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_global_read_lock);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_prepared_stmt_count);
+ (void) MYSQL_COND_DESTROY(&COND_thread_count);
+ (void) MYSQL_COND_DESTROY(&COND_refresh);
+ (void) MYSQL_COND_DESTROY(&COND_global_read_lock);
+ (void) MYSQL_COND_DESTROY(&COND_thread_cache);
+ (void) MYSQL_COND_DESTROY(&COND_flush_thread_cache);
+ (void) MYSQL_COND_DESTROY(&COND_manager);
DDL_blocker_class::destroy_DDL_blocker_class_instance();
}
@@ -1906,7 +1906,7 @@ void close_connection(THD *thd, uint err
"(not connected)",
errcode ? ER(errcode) : ""));
if (lock)
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->killed= THD::KILL_CONNECTION;
if ((vio= thd->net.vio) != 0)
{
@@ -1915,7 +1915,7 @@ void close_connection(THD *thd, uint err
vio_close(vio); /* vio is freed in delete thd */
}
if (lock)
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
#endif /* EMBEDDED_LIBRARY */
@@ -1953,11 +1953,11 @@ void unlink_thd(THD *thd)
DBUG_PRINT("enter", ("thd: %p", thd));
thd->cleanup();
- pthread_mutex_lock(&LOCK_connection_count);
+ MYSQL_MUTEX_LOCK(&LOCK_connection_count);
--connection_count;
- pthread_mutex_unlock(&LOCK_connection_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_connection_count);
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
delete thd;
DBUG_VOID_RETURN;
@@ -1982,7 +1982,7 @@ void unlink_thd(THD *thd)
static bool cache_thread()
{
- safe_mutex_assert_owner(&LOCK_thread_count);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_thread_count);
if (cached_thread_count < thread_cache_size &&
! abort_loop && !kill_cached_threads)
{
@@ -1990,10 +1990,10 @@ static bool cache_thread()
DBUG_PRINT("info", ("Adding thread to cache"));
cached_thread_count++;
while (!abort_loop && ! wake_thread && ! kill_cached_threads)
- (void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
+ (void) MYSQL_COND_WAIT(&COND_thread_cache, &LOCK_thread_count);
cached_thread_count--;
if (kill_cached_threads)
- pthread_cond_signal(&COND_flush_thread_cache);
+ MYSQL_COND_SIGNAL(&COND_flush_thread_cache);
if (wake_thread)
{
THD *thd;
@@ -2041,14 +2041,14 @@ bool one_thread_per_connection_end(THD *
unlink_thd(thd);
if (put_in_cache)
put_in_cache= cache_thread();
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (put_in_cache)
DBUG_RETURN(0); // Thread is reused
/* It's safe to broadcast outside a lock (COND... is not deleted here) */
DBUG_PRINT("signal", ("Broadcasting COND_thread_count"));
my_thread_end();
- (void) pthread_cond_broadcast(&COND_thread_count);
+ (void) MYSQL_COND_BROADCAST(&COND_thread_count);
pthread_exit(0);
DBUG_RETURN(0); // Impossible
@@ -2057,15 +2057,15 @@ bool one_thread_per_connection_end(THD *
void flush_thread_cache()
{
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
kill_cached_threads++;
while (cached_thread_count)
{
- pthread_cond_broadcast(&COND_thread_cache);
- pthread_cond_wait(&COND_flush_thread_cache,&LOCK_thread_count);
+ MYSQL_COND_BROADCAST(&COND_thread_cache);
+ MYSQL_COND_WAIT(&COND_flush_thread_cache,&LOCK_thread_count);
}
kill_cached_threads--;
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
@@ -2788,15 +2788,15 @@ static void start_signal_handler(void)
#endif
#endif
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
if ((error=pthread_create(&signal_thread,&thr_attr,signal_hand,0)))
{
sql_print_error("Can't create interrupt-thread (error %d, errno: %d)",
error,errno);
exit(1);
}
- (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
(void) pthread_attr_destroy(&thr_attr);
DBUG_VOID_RETURN;
@@ -2854,11 +2854,11 @@ pthread_handler_t signal_hand(void *arg
This works by waiting for start_signal_handler to free mutex,
after which we signal it that we are ready.
At this pointer there is no other threads running, so there
- should not be any other pthread_cond_signal() calls.
+ should not be any other MYSQL_COND_SIGNAL() calls.
*/
- (void) pthread_mutex_lock(&LOCK_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
- (void) pthread_cond_broadcast(&COND_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
+ (void) MYSQL_COND_BROADCAST(&COND_thread_count);
(void) pthread_sigmask(SIG_BLOCK,&set,NULL);
for (;;)
@@ -3696,36 +3696,36 @@ You should consider changing lower_case_
static int init_thread_environment()
{
- (void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_open, NULL);
- (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
- (void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
- (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_uuid_short, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_mysql_create_db, key_LOCK_mysql_create_db,
MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_lock_db, key_LOCK_lock_db, MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_Acl, key_LOCK_Acl, MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_open, key_LOCK_open, NULL);
+ (void) MYSQL_MUTEX_INIT(&LOCK_thread_count,key_LOCK_thread_count,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_mapped_file, key_LOCK_mapped_file,
MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_status, key_LOCK_status, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_error_log, key_LOCK_error_log, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_delayed_insert, key_LOCK_delayed_insert,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_delayed_status, key_LOCK_delayed_status,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_delayed_create, key_LOCK_delayed_create,
MY_MUTEX_INIT_SLOW);
+ (void) MYSQL_MUTEX_INIT(&LOCK_manager, key_LOCK_manager, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_crypt, key_LOCK_crypt, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_bytes_sent, key_LOCK_bytes_sent, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_bytes_received, key_LOCK_bytes_received,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_user_conn, key_LOCK_user_conn, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_active_mi, key_LOCK_active_mi, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_global_system_variables,
key_LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_RWLOCK_INIT(&LOCK_system_variables_hash,
key_LOCK_system_variables_hash, NULL);
+ (void) MYSQL_MUTEX_INIT(&LOCK_global_read_lock, key_LOCK_global_read_lock,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_prepared_stmt_count, key_LOCK_prepared_stmt_count,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_uuid_short, key_LOCK_uuid_short, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_connection_count, key_LOCK_connection_count,
MY_MUTEX_INIT_FAST);
#ifdef HAVE_OPENSSL
- (void) pthread_mutex_init(&LOCK_des_key_file,MY_MUTEX_INIT_FAST);
+ (void) MYSQL_MUTEX_INIT(&LOCK_des_key_file, key_LOCK_des_key_file,
MY_MUTEX_INIT_FAST);
#ifndef HAVE_YASSL
openssl_stdlocks= (openssl_lock_t*) OPENSSL_malloc(CRYPTO_num_locks() *
sizeof(openssl_lock_t));
for (int i= 0; i < CRYPTO_num_locks(); ++i)
- (void) my_rwlock_init(&openssl_stdlocks[i].lock, NULL);
+ (void) MYSQL_RWLOCK_INIT(&openssl_stdlocks[i].lock, key_openssl_lock, NULL);
CRYPTO_set_dynlock_create_callback(openssl_dynlock_create);
CRYPTO_set_dynlock_destroy_callback(openssl_dynlock_destroy);
CRYPTO_set_dynlock_lock_callback(openssl_lock);
@@ -3733,21 +3733,21 @@ static int init_thread_environment()
CRYPTO_set_id_callback(openssl_id_function);
#endif
#endif
- (void) my_rwlock_init(&LOCK_sys_init_connect, NULL);
- (void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
- (void) my_rwlock_init(&LOCK_grant, NULL);
- (void) pthread_cond_init(&COND_thread_count,NULL);
- (void) pthread_cond_init(&COND_refresh,NULL);
- (void) pthread_cond_init(&COND_global_read_lock,NULL);
- (void) pthread_cond_init(&COND_thread_cache,NULL);
- (void) pthread_cond_init(&COND_flush_thread_cache,NULL);
- (void) pthread_cond_init(&COND_manager,NULL);
+ (void) MYSQL_RWLOCK_INIT(&LOCK_sys_init_connect, key_LOCK_sys_init_connect, NULL);
+ (void) MYSQL_RWLOCK_INIT(&LOCK_sys_init_slave, key_LOCK_sys_init_slave, NULL);
+ (void) MYSQL_RWLOCK_INIT(&LOCK_grant, key_LOCK_grant, NULL);
+ (void) MYSQL_COND_INIT(&COND_thread_count, key_COND_thread_count, NULL);
+ (void) MYSQL_COND_INIT(&COND_refresh, key_COND_refresh, NULL);
+ (void) MYSQL_COND_INIT(&COND_global_read_lock, key_COND_global_read_lock, NULL);
+ (void) MYSQL_COND_INIT(&COND_thread_cache, key_COND_thread_cache, NULL);
+ (void) MYSQL_COND_INIT(&COND_flush_thread_cache, key_COND_flush_thread_cache,
NULL);
+ (void) MYSQL_COND_INIT(&COND_manager, key_COND_manager, NULL);
#ifdef HAVE_REPLICATION
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
+ (void) MYSQL_MUTEX_INIT(&LOCK_rpl_status, key_LOCK_rpl_status, MY_MUTEX_INIT_FAST);
+ (void) MYSQL_COND_INIT(&COND_rpl_status, key_COND_rpl_status, NULL);
#endif
- (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_server_started,NULL);
+ (void) MYSQL_MUTEX_INIT(&LOCK_server_started, key_LOCK_server_started,
MY_MUTEX_INIT_FAST);
+ (void) MYSQL_COND_INIT(&COND_server_started, key_COND_server_started, NULL);
/*
Initialize the DDL blocker
@@ -3786,7 +3786,7 @@ static unsigned long openssl_id_function
static openssl_lock_t *openssl_dynlock_create(const char *file, int line)
{
openssl_lock_t *lock= new openssl_lock_t;
- my_rwlock_init(&lock->lock, NULL);
+ MYSQL_RWLOCK_INIT(&lock->lock, key_openssl_lock, NULL);
return lock;
}
@@ -3794,7 +3794,7 @@ static openssl_lock_t *openssl_dynlock_c
static void openssl_dynlock_destroy(openssl_lock_t *lock, const char *file,
int line)
{
- rwlock_destroy(&lock->lock);
+ MYSQL_RWLOCK_DESTROY(&lock->lock);
delete lock;
}
@@ -3820,16 +3820,16 @@ static void openssl_lock(int mode, opens
switch (mode) {
case CRYPTO_LOCK|CRYPTO_READ:
what = "read lock";
- err = rw_rdlock(&lock->lock);
+ err = MYSQL_RWLOCK_RDLOCK(&lock->lock);
break;
case CRYPTO_LOCK|CRYPTO_WRITE:
what = "write lock";
- err = rw_wrlock(&lock->lock);
+ err = MYSQL_RWLOCK_WRLOCK(&lock->lock);
break;
case CRYPTO_UNLOCK|CRYPTO_READ:
case CRYPTO_UNLOCK|CRYPTO_WRITE:
what = "unlock";
- err = rw_unlock(&lock->lock);
+ err = MYSQL_RWLOCK_UNLOCK(&lock->lock);
break;
default:
/* Unknown locking mode. */
@@ -4374,8 +4374,8 @@ static void handle_connections_methods()
}
#endif
- pthread_mutex_lock(&LOCK_thread_count);
- (void) pthread_cond_init(&COND_handler_count,NULL);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
+ (void) MYSQL_COND_INIT(&COND_handler_count, key_COND_handler_count, NULL);
handler_count=0;
#ifdef __NT__
if (hPipe != INVALID_HANDLE_VALUE)
@@ -4413,17 +4413,17 @@ static void handle_connections_methods()
#endif
while (handler_count > 0)
- pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_WAIT(&COND_handler_count,&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
void decrement_handler_count()
{
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
handler_count--;
- pthread_cond_signal(&COND_handler_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_SIGNAL(&COND_handler_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
my_thread_end();
}
#else
@@ -4663,10 +4663,10 @@ int main(int argc, char **argv)
/* Signal threads waiting for server to be started */
- pthread_mutex_lock(&LOCK_server_started);
+ MYSQL_MUTEX_LOCK(&LOCK_server_started);
mysqld_server_started= 1;
- pthread_cond_signal(&COND_server_started);
- pthread_mutex_unlock(&LOCK_server_started);
+ MYSQL_COND_SIGNAL(&COND_server_started);
+ MYSQL_MUTEX_UNLOCK(&LOCK_server_started);
#if defined(__NT__) || defined(HAVE_SMEM)
handle_connections_methods();
@@ -4689,21 +4689,21 @@ int main(int argc, char **argv)
#ifdef EXTRA_DEBUG2
sql_print_error("Before Lock_thread_count");
#endif
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
DBUG_PRINT("quit", ("Got thread_count mutex"));
select_thread_in_use=0; // For close_connections
- (void) pthread_mutex_unlock(&LOCK_thread_count);
- (void) pthread_cond_broadcast(&COND_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
+ (void) MYSQL_COND_BROADCAST(&COND_thread_count);
#ifdef EXTRA_DEBUG2
sql_print_error("After lock_thread_count");
#endif
#endif /* __WIN__ */
/* Wait until cleanup is done */
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
while (!ready_to_exit)
- pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
if (Service.IsNT() && start_mode)
@@ -4939,13 +4939,13 @@ static void bootstrap(FILE *file)
DBUG_VOID_RETURN;
}
/* Wait for thread to die */
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
while (thread_count)
{
- (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
+ (void) MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
}
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
#else
thd->mysql= 0;
handle_bootstrap((void *)thd);
@@ -4982,10 +4982,10 @@ static bool read_init_file(char *file_na
void handle_connection_in_main_thread(THD *thd)
{
- safe_mutex_assert_owner(&LOCK_thread_count);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_thread_count);
thread_cache_size=0; // Safety
threads.append(thd);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
handle_one_connection((void*) thd);
}
@@ -5001,7 +5001,7 @@ void create_thread_to_handle_connection(
/* Get thread from cache */
thread_cache.append(thd);
wake_thread++;
- pthread_cond_signal(&COND_thread_cache);
+ MYSQL_COND_SIGNAL(&COND_thread_cache);
}
else
{
@@ -5022,26 +5022,26 @@ void create_thread_to_handle_connection(
error));
thread_count--;
thd->killed= THD::KILL_CONNECTION; // Safety
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
- pthread_mutex_lock(&LOCK_connection_count);
+ MYSQL_MUTEX_LOCK(&LOCK_connection_count);
--connection_count;
- pthread_mutex_unlock(&LOCK_connection_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_connection_count);
statistic_increment(aborted_connects,&LOCK_status);
/* Can't use my_error() since store_globals has not been called. */
my_snprintf(error_message_buff, sizeof(error_message_buff),
ER(ER_CANT_CREATE_THREAD), error);
net_send_error(thd, ER_CANT_CREATE_THREAD, error_message_buff);
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
close_connection(thd,0,0);
delete thd;
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
return;
/* purecov: end */
}
}
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_PRINT("info",("Thread created"));
}
@@ -5068,11 +5068,11 @@ static void create_new_thread(THD *thd)
only (max_connections + 1) connections.
*/
- pthread_mutex_lock(&LOCK_connection_count);
+ MYSQL_MUTEX_LOCK(&LOCK_connection_count);
if (connection_count >= max_connections + 1 || abort_loop)
{
- pthread_mutex_unlock(&LOCK_connection_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_connection_count);
DBUG_PRINT("error",("Too many connections"));
close_connection(thd, ER_CON_COUNT_ERROR, 1);
@@ -5085,11 +5085,11 @@ static void create_new_thread(THD *thd)
if (connection_count > max_used_connections)
max_used_connections= connection_count;
- pthread_mutex_unlock(&LOCK_connection_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_connection_count);
/* Start a new thread to handle connection. */
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
/*
The initialization of thread_id is done in create_embedded_thd() for
@@ -7197,11 +7197,11 @@ static int show_rpl_status(THD *thd, SHO
static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
{
var->type= SHOW_MY_BOOL;
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
var->value= buff;
*((my_bool *)buff)= (my_bool) (active_mi && active_mi->slave_running
&&
active_mi->rli.slave_running);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
return 0;
}
@@ -7211,41 +7211,41 @@ static int show_slave_retried_trans(THD
TODO: with multimaster, have one such counter per line in
SHOW SLAVE STATUS, and have the sum over all lines here.
*/
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
if (active_mi)
{
var->type= SHOW_LONG;
var->value= buff;
- pthread_mutex_lock(&active_mi->rli.data_lock);
+ MYSQL_MUTEX_LOCK(&active_mi->rli.data_lock);
*((long *)buff)= (long)active_mi->rli.retried_trans;
- pthread_mutex_unlock(&active_mi->rli.data_lock);
+ MYSQL_MUTEX_UNLOCK(&active_mi->rli.data_lock);
}
else
var->type= SHOW_UNDEF;
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
return 0;
}
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
{
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
if (active_mi)
{
var->type= SHOW_LONGLONG;
var->value= buff;
- pthread_mutex_lock(&active_mi->rli.data_lock);
+ MYSQL_MUTEX_LOCK(&active_mi->rli.data_lock);
*((longlong *)buff)= active_mi->received_heartbeats;
- pthread_mutex_unlock(&active_mi->rli.data_lock);
+ MYSQL_MUTEX_UNLOCK(&active_mi->rli.data_lock);
}
else
var->type= SHOW_UNDEF;
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
return 0;
}
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
{
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
if (active_mi)
{
var->type= SHOW_CHAR;
@@ -7254,7 +7254,7 @@ static int show_heartbeat_period(THD *th
}
else
var->type= SHOW_UNDEF;
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
return 0;
}
@@ -7273,9 +7273,9 @@ static int show_prepared_stmt_count(THD
{
var->type= SHOW_LONG;
var->value= buff;
- pthread_mutex_lock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_LOCK(&LOCK_prepared_stmt_count);
*((long *)buff)= (long)prepared_stmt_count;
- pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prepared_stmt_count);
return 0;
}
@@ -8973,7 +8973,7 @@ static void create_pid_file()
/** Clear most status variables. */
void refresh_status(THD *thd)
{
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
/* Add thread's status variabes to global status */
add_to_status(&global_status_var, &thd->status_var);
@@ -8987,7 +8987,7 @@ void refresh_status(THD *thd)
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters);
flush_status_time= time((time_t*) 0);
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
/*
Set max_used_connections to the number of currently open
@@ -8995,9 +8995,9 @@ void refresh_status(THD *thd)
deadlocks. Status reset becomes not atomic, but status data is
not exact anyway.
*/
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
max_used_connections= thread_count-delayed_insert_threads;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
@@ -9025,3 +9025,118 @@ template class I_List<NAMED_LIST>;
template class I_List<Statement>;
template class I_List_iterator<Statement>;
#endif
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_mysql_create_db;
+PSI_mutex_key key_LOCK_Acl;
+PSI_mutex_key key_LOCK_open;
+PSI_mutex_key key_LOCK_lock_db;
+PSI_mutex_key key_LOCK_thread_count;
+PSI_mutex_key key_LOCK_mapped_file;
+PSI_mutex_key key_LOCK_status;
+PSI_mutex_key key_LOCK_error_log;
+PSI_mutex_key key_LOCK_delayed_insert;
+PSI_mutex_key key_LOCK_uuid_short;
+PSI_mutex_key key_LOCK_delayed_status;
+PSI_mutex_key key_LOCK_delayed_create;
+PSI_mutex_key key_LOCK_crypt;
+PSI_mutex_key key_LOCK_timezone;
+PSI_mutex_key key_LOCK_slave_list;
+PSI_mutex_key key_LOCK_active_mi;
+PSI_mutex_key key_LOCK_manager;
+PSI_mutex_key key_LOCK_global_read_lock;
+PSI_mutex_key key_LOCK_global_system_variables;
+PSI_mutex_key key_LOCK_user_conn;
+PSI_mutex_key key_LOCK_prepared_stmt_count;
+PSI_mutex_key key_LOCK_bytes_sent;
+PSI_mutex_key key_LOCK_bytes_received;
+PSI_mutex_key key_LOCK_connection_count;
+PSI_mutex_key key_LOCK_server_started;
+PSI_cond_key key_COND_server_started;
+PSI_rwlock_key key_LOCK_grant;
+PSI_rwlock_key key_LOCK_sys_init_connect;
+PSI_rwlock_key key_LOCK_sys_init_slave;
+PSI_rwlock_key key_LOCK_system_variables_hash;
+PSI_cond_key key_COND_refresh;
+PSI_cond_key key_COND_thread_count;
+PSI_cond_key key_COND_manager;
+PSI_cond_key key_COND_global_read_lock;
+PSI_cond_key key_COND_thread_cache;
+PSI_cond_key key_COND_flush_thread_cache;
+PSI_mutex_key key_LOCK_rpl_status;
+PSI_cond_key key_COND_rpl_status;
+
+PSI_mutex_key key_LOCK_delete;
+PSI_mutex_key key_hash_filo_lock;
+PSI_mutex_key key_LOCK_ha_data;
+
+PSI_mutex_key key_LOG_LOCK_log;
+
+PSI_mutex_key key_BINLOG_LOCK_index;
+PSI_mutex_key key_BINLOG_LOCK_prep_xids;
+PSI_cond_key key_BINLOG_COND_prep_xids;
+PSI_cond_key key_BINLOG_update_cond;
+
+PSI_mutex_key key_LOCK_logger;
+PSI_mutex_key key_LOG_INFO_lock;
+PSI_mutex_key key_LOCK_backupid;
+PSI_rwlock_key key_QCQ_lock;
+PSI_mutex_key key_structure_guard_mutex;
+PSI_cond_key key_COND_cache_status_changed;
+PSI_mutex_key key_RLI_run_lock;
+PSI_mutex_key key_RLI_data_lock;
+PSI_mutex_key key_RLI_log_space_lock;
+PSI_cond_key key_RLI_data_cond;
+PSI_cond_key key_RLI_start_cond;
+PSI_cond_key key_RLI_stop_cond;
+PSI_cond_key key_RLI_log_space_cond;
+PSI_mutex_key key_MI_run_lock;
+PSI_mutex_key key_MI_data_lock;
+PSI_cond_key key_MI_data_cond;
+PSI_cond_key key_MI_start_cond;
+PSI_cond_key key_MI_stop_cond;
+PSI_mutex_key key_LOCK_scheduler_state;
+PSI_cond_key key_Event_scheduler_COND_state;
+PSI_mutex_key key_LOCK_event_metadata;
+PSI_mutex_key key_LOCK_event_queue;
+PSI_cond_key key_COND_queue_state;
+PSI_mutex_key key_THR_LOCK_DDL_blocker;
+PSI_mutex_key key_THR_LOCK_DDL_is_blocked;
+PSI_mutex_key key_THR_LOCK_DDL_blocker_blocked;
+PSI_cond_key key_COND_DDL_blocker;
+PSI_cond_key key_COND_process_blocked;
+PSI_cond_key key_COND_DDL_blocker_blocked;
+PSI_mutex_key key_THR_LOCK_thread;
+PSI_cond_key key_COND_thread_wait;
+PSI_mutex_key key_THR_LOCK_caller;
+PSI_cond_key key_COND_caller_wait;
+PSI_mutex_key key_BRC_run_lock;
+PSI_mutex_key key_NDB_SHARE_mutex;
+
+
+
+#ifdef HAVE_OPENSSL
+PSI_mutex_key key_LOCK_des_key_file;
+#endif
+
+#ifdef HAVE_MMAP
+PSI_mutex_key key_PAGE_lock;
+PSI_cond_key key_PAGE_cond;
+PSI_mutex_key key_LOCK_sync;
+PSI_mutex_key key_LOCK_active;
+PSI_mutex_key key_LOCK_pool;
+PSI_cond_key key_COND_active;
+PSI_cond_key key_COND_pool;
+#endif
+
+void init_psi_server_keys()
+{
+}
+
+#endif
+
+
+
+
+
+
=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc 2008-05-29 15:44:11 +0000
+++ b/sql/net_serv.cc 2008-10-10 20:34:55 +0000
@@ -90,7 +90,7 @@ void sql_print_error(const char *format,
*/
extern uint test_flags;
extern ulong bytes_sent, bytes_received, net_big_packet_count;
-extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
+extern mysql_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
#ifndef MYSQL_INSTANCE_MANAGER
#ifdef HAVE_QUERY_CACHE
#define USE_QUERY_CACHE
=== modified file 'sql/repl_failsafe.cc'
--- a/sql/repl_failsafe.cc 2008-08-07 17:52:43 +0000
+++ b/sql/repl_failsafe.cc 2008-10-10 20:34:55 +0000
@@ -39,8 +39,8 @@
RPL_STATUS rpl_status=RPL_NULL;
-pthread_mutex_t LOCK_rpl_status;
-pthread_cond_t COND_rpl_status;
+mysql_mutex_t LOCK_rpl_status;
+mysql_cond_t COND_rpl_status;
HASH slave_list;
const char *rpl_role_type[] = {"MASTER","SLAVE",NullS};
@@ -83,9 +83,9 @@ static int init_failsafe_rpl_thread(THD*
my_net_init(&thd->net, 0);
thd->net.read_timeout = slave_net_timeout;
thd->max_client_packet_length=thd->net.max_packet;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (init_thr_lock() || thd->store_globals())
{
@@ -110,11 +110,11 @@ static int init_failsafe_rpl_thread(THD*
void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
{
- pthread_mutex_lock(&LOCK_rpl_status);
+ MYSQL_MUTEX_LOCK(&LOCK_rpl_status);
if (rpl_status == from_status || rpl_status == RPL_ANY)
rpl_status = to_status;
- pthread_cond_signal(&COND_rpl_status);
- pthread_mutex_unlock(&LOCK_rpl_status);
+ MYSQL_COND_SIGNAL(&COND_rpl_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_rpl_status);
}
@@ -143,7 +143,7 @@ void unregister_slave(THD* thd, bool onl
if (thd->server_id)
{
if (need_mutex)
- pthread_mutex_lock(&LOCK_slave_list);
+ MYSQL_MUTEX_LOCK(&LOCK_slave_list);
SLAVE_INFO* old_si;
if ((old_si = (SLAVE_INFO*)hash_search(&slave_list,
@@ -152,7 +152,7 @@ void unregister_slave(THD* thd, bool onl
hash_delete(&slave_list, (uchar*)old_si);
if (need_mutex)
- pthread_mutex_unlock(&LOCK_slave_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_slave_list);
}
}
@@ -193,10 +193,10 @@ int register_slave(THD* thd, uchar* pack
si->master_id= server_id;
si->thd= thd;
- pthread_mutex_lock(&LOCK_slave_list);
+ MYSQL_MUTEX_LOCK(&LOCK_slave_list);
unregister_slave(thd,0,0);
res= my_hash_insert(&slave_list, (uchar*) si);
- pthread_mutex_unlock(&LOCK_slave_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_slave_list);
return res;
err:
@@ -223,7 +223,7 @@ void init_slave_list()
{
hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0,
(hash_get_key) slave_list_key, (hash_free_key) slave_info_free, 0);
- pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_slave_list, key_LOCK_slave_list, MY_MUTEX_INIT_FAST);
}
void end_slave_list()
@@ -232,7 +232,7 @@ void end_slave_list()
if (hash_inited(&slave_list))
{
hash_free(&slave_list);
- pthread_mutex_destroy(&LOCK_slave_list);
+ MYSQL_MUTEX_DESTROY(&LOCK_slave_list);
}
}
@@ -244,7 +244,7 @@ static int find_target_pos(LEX_MASTER_IN
for (;;)
{
Log_event* ev;
- if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*) 0, 0)))
+ if (!(ev = Log_event::read_log_event(log, (mysql_mutex_t*) 0, 0)))
{
if (log->error > 0)
strmov(errmsg, "Binary log truncated in the middle of event");
@@ -286,7 +286,7 @@ int translate_master(THD* thd, LEX_MASTE
char last_log_name[FN_REFLEN];
IO_CACHE log;
File file = -1, last_file = -1;
- pthread_mutex_t *log_lock;
+ mysql_mutex_t *log_lock;
const char* errmsg_p;
Slave_log_event* sev = 0;
my_off_t last_pos = 0;
@@ -316,7 +316,7 @@ int translate_master(THD* thd, LEX_MASTE
bzero((char*) &log,sizeof(log));
log_lock = mysql_bin_log.get_log_lock();
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
for (;;)
{
@@ -389,11 +389,11 @@ found_log:
mi_inited:
error = 0;
err:
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
end_io_cache(&log);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->current_linfo = 0;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (file >= 0)
(void) my_close(file, MYF(MY_WME));
if (last_file >= 0 && last_file != file)
@@ -418,7 +418,7 @@ static Slave_log_event* find_slave_event
for (i = 0; i < 2; i++)
{
- if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*)0, 0)))
+ if (!(ev = Log_event::read_log_event(log, (mysql_mutex_t*)0, 0)))
{
my_snprintf(errmsg, SLAVE_ERRMSG_SIZE,
"Error reading event in log '%s'",
@@ -540,7 +540,7 @@ HOSTS";
goto err;
}
- pthread_mutex_lock(&LOCK_slave_list);
+ MYSQL_MUTEX_LOCK(&LOCK_slave_list);
while ((row= mysql_fetch_row(res)))
{
@@ -555,7 +555,7 @@ HOSTS";
if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME))))
{
error= "the slave is out of memory";
- pthread_mutex_unlock(&LOCK_slave_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_slave_list);
goto err;
}
si->server_id = log_server_id;
@@ -571,7 +571,7 @@ HOSTS";
strmake(si->password, row[3], sizeof(si->password)-1);
}
}
- pthread_mutex_unlock(&LOCK_slave_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_slave_list);
err:
if (res)
@@ -609,13 +609,13 @@ pthread_handler_t handle_failsafe_rpl(vo
sql_print_error("Could not initialize failsafe replication thread");
goto err;
}
- pthread_mutex_lock(&LOCK_rpl_status);
+ MYSQL_MUTEX_LOCK(&LOCK_rpl_status);
msg= thd->enter_cond(&COND_rpl_status,
&LOCK_rpl_status, "Waiting for request");
while (!thd->killed && !abort_loop)
{
bool break_req_chain = 0;
- pthread_cond_wait(&COND_rpl_status, &LOCK_rpl_status);
+ MYSQL_COND_WAIT(&COND_rpl_status, &LOCK_rpl_status);
thd_proc_info(thd, "Processing request");
while (!break_req_chain)
{
@@ -668,7 +668,7 @@ bool show_slave_hosts(THD* thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
- pthread_mutex_lock(&LOCK_slave_list);
+ MYSQL_MUTEX_LOCK(&LOCK_slave_list);
for (uint i = 0; i < slave_list.records; ++i)
{
@@ -686,11 +686,11 @@ bool show_slave_hosts(THD* thd)
protocol->store((uint32) si->master_id);
if (protocol->write())
{
- pthread_mutex_unlock(&LOCK_slave_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_slave_list);
DBUG_RETURN(TRUE);
}
}
- pthread_mutex_unlock(&LOCK_slave_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_slave_list);
my_eof(thd);
DBUG_RETURN(FALSE);
}
=== modified file 'sql/repl_failsafe.h'
--- a/sql/repl_failsafe.h 2007-08-16 06:52:50 +0000
+++ b/sql/repl_failsafe.h 2008-10-10 20:34:55 +0000
@@ -25,8 +25,8 @@ typedef enum {RPL_AUTH_MASTER=0,RPL_ACTI
RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS;
extern RPL_STATUS rpl_status;
-extern pthread_mutex_t LOCK_rpl_status;
-extern pthread_cond_t COND_rpl_status;
+extern mysql_mutex_t LOCK_rpl_status;
+extern mysql_cond_t COND_rpl_status;
extern TYPELIB rpl_role_typelib, rpl_status_typelib;
extern const char* rpl_role_type[], *rpl_status_type[];
=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc 2008-03-14 22:21:29 +0000
+++ b/sql/rpl_mi.cc 2008-10-10 20:34:55 +0000
@@ -41,20 +41,20 @@ Master_info::Master_info()
ssl_cipher[0]= 0; ssl_key[0]= 0;
bzero((char*) &file, sizeof(file));
- pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&data_cond, NULL);
- pthread_cond_init(&start_cond, NULL);
- pthread_cond_init(&stop_cond, NULL);
+ MYSQL_MUTEX_INIT(&run_lock, key_MI_run_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&data_lock, key_MI_data_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&data_cond, key_MI_data_cond, NULL);
+ MYSQL_COND_INIT(&start_cond, key_MI_start_cond, NULL);
+ MYSQL_COND_INIT(&stop_cond, key_MI_stop_cond, NULL);
}
Master_info::~Master_info()
{
- pthread_mutex_destroy(&run_lock);
- pthread_mutex_destroy(&data_lock);
- pthread_cond_destroy(&data_cond);
- pthread_cond_destroy(&start_cond);
- pthread_cond_destroy(&stop_cond);
+ MYSQL_MUTEX_DESTROY(&run_lock);
+ MYSQL_MUTEX_DESTROY(&data_lock);
+ MYSQL_COND_DESTROY(&data_cond);
+ MYSQL_COND_DESTROY(&start_cond);
+ MYSQL_COND_DESTROY(&stop_cond);
}
@@ -131,7 +131,7 @@ int init_master_info(Master_info* mi, co
keep other threads from reading bogus info
*/
- pthread_mutex_lock(&mi->data_lock);
+ MYSQL_MUTEX_LOCK(&mi->data_lock);
fd = mi->fd;
/* does master.info exist ? */
@@ -140,7 +140,7 @@ int init_master_info(Master_info* mi, co
{
if (abort_if_no_master_info_file)
{
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(0);
}
/*
@@ -313,7 +313,7 @@ file '%s')", fname);
reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1);
if ((error=test(flush_master_info(mi, 1))))
sql_print_error("Failed to flush master info file");
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(error);
errwithmsg:
@@ -326,7 +326,7 @@ err:
end_io_cache(&mi->file);
}
mi->fd= -1;
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(1);
}
=== modified file 'sql/rpl_mi.h'
--- a/sql/rpl_mi.h 2008-02-03 09:00:49 +0000
+++ b/sql/rpl_mi.h 2008-10-10 20:34:55 +0000
@@ -55,6 +55,14 @@
*****************************************************************************/
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_MI_run_lock;
+extern PSI_mutex_key key_MI_data_lock;
+extern PSI_cond_key key_MI_data_cond;
+extern PSI_cond_key key_MI_start_cond;
+extern PSI_cond_key key_MI_stop_cond;
+#endif
+
class Master_info : public Slave_reporting_capability
{
public:
@@ -75,8 +83,8 @@ class Master_info : public Slave_reporti
File fd; // we keep the file open, so we need to remember the file pointer
IO_CACHE file;
- pthread_mutex_t data_lock,run_lock;
- pthread_cond_t data_cond,start_cond,stop_cond;
+ mysql_mutex_t data_lock,run_lock;
+ mysql_cond_t data_cond,start_cond,stop_cond;
THD *io_thd;
MYSQL* mysql;
uint32 file_id; /* for 3.23 load data infile */
=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc 2008-08-08 01:33:43 +0000
+++ b/sql/rpl_rli.cc 2008-10-10 20:34:55 +0000
@@ -54,13 +54,13 @@ Relay_log_info::Relay_log_info()
bzero((char*) &info_file, sizeof(info_file));
bzero((char*) &cache_buf, sizeof(cache_buf));
cached_charset_invalidate();
- pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&data_cond, NULL);
- pthread_cond_init(&start_cond, NULL);
- pthread_cond_init(&stop_cond, NULL);
- pthread_cond_init(&log_space_cond, NULL);
+ MYSQL_MUTEX_INIT(&run_lock, key_RLI_run_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&data_lock, key_RLI_data_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&log_space_lock, key_RLI_log_space_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&data_cond, key_RLI_data_cond, NULL);
+ MYSQL_COND_INIT(&start_cond, key_RLI_start_cond, NULL);
+ MYSQL_COND_INIT(&stop_cond, key_RLI_stop_cond, NULL);
+ MYSQL_COND_INIT(&log_space_cond, key_RLI_log_space_cond, NULL);
relay_log.init_pthread_objects();
DBUG_VOID_RETURN;
}
@@ -70,13 +70,13 @@ Relay_log_info::~Relay_log_info()
{
DBUG_ENTER("Relay_log_info::~Relay_log_info");
- pthread_mutex_destroy(&run_lock);
- pthread_mutex_destroy(&data_lock);
- pthread_mutex_destroy(&log_space_lock);
- pthread_cond_destroy(&data_cond);
- pthread_cond_destroy(&start_cond);
- pthread_cond_destroy(&stop_cond);
- pthread_cond_destroy(&log_space_cond);
+ MYSQL_MUTEX_DESTROY(&run_lock);
+ MYSQL_MUTEX_DESTROY(&data_lock);
+ MYSQL_MUTEX_DESTROY(&log_space_lock);
+ MYSQL_COND_DESTROY(&data_cond);
+ MYSQL_COND_DESTROY(&start_cond);
+ MYSQL_COND_DESTROY(&stop_cond);
+ MYSQL_COND_DESTROY(&log_space_cond);
relay_log.cleanup();
DBUG_VOID_RETURN;
}
@@ -95,7 +95,7 @@ int init_relay_log_info(Relay_log_info*
if (rli->inited) // Set if this function called
DBUG_RETURN(0);
fn_format(fname, info_fname, mysql_data_home, "", 4+32);
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
info_fd = rli->info_fd;
rli->cur_log_fd = -1;
rli->slave_skip_counter=0;
@@ -152,7 +152,7 @@ int init_relay_log_info(Relay_log_info*
(max_relay_log_size ? max_relay_log_size :
max_binlog_size), 1))
{
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
sql_print_error("Failed in open_log() called from init_relay_log_info()");
DBUG_RETURN(1);
}
@@ -221,7 +221,7 @@ Failed to open the existing relay log in
my_close(info_fd, MYF(0));
rli->info_fd= -1;
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
DBUG_RETURN(1);
}
}
@@ -284,7 +284,7 @@ Failed to open the existing relay log in
goto err;
}
rli->inited= 1;
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
DBUG_RETURN(error);
err:
@@ -294,7 +294,7 @@ err:
my_close(info_fd, MYF(0));
rli->info_fd= -1;
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
DBUG_RETURN(1);
}
@@ -403,10 +403,10 @@ int init_relay_log_pos(Relay_log_info* r
DBUG_PRINT("info", ("pos: %lu", (ulong) pos));
*errmsg=0;
- pthread_mutex_t *log_lock=rli->relay_log.get_log_lock();
+ mysql_mutex_t *log_lock=rli->relay_log.get_log_lock();
if (need_data_lock)
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
/*
Slave threads are not the only users of init_relay_log_pos(). CHANGE MASTER
@@ -426,7 +426,7 @@ int init_relay_log_pos(Relay_log_info* r
rli->relay_log.description_event_for_exec= new
Format_description_log_event(3);
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
/* Close log file and free buffers if it's already open */
if (rli->cur_log_fd >= 0)
@@ -566,12 +566,12 @@ err:
*/
if (!relay_log_purge)
rli->log_space_limit= 0;
- pthread_cond_broadcast(&rli->data_cond);
+ MYSQL_COND_BROADCAST(&rli->data_cond);
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
if (need_data_lock)
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
if (!rli->relay_log.description_event_for_exec->is_valid() && !*errmsg)
*errmsg= "Invalid Format_description log event; could be out of memory";
@@ -622,7 +622,7 @@ int Relay_log_info::wait_for_pos(THD* th
log_name->c_ptr(), (ulong) log_pos, (ulong) timeout));
set_timespec(abstime,timeout);
- pthread_mutex_lock(&data_lock);
+ MYSQL_MUTEX_LOCK(&data_lock);
msg= thd->enter_cond(&data_cond, &data_lock,
"Waiting for the slave SQL thread to "
"advance position");
@@ -741,20 +741,20 @@ int Relay_log_info::wait_for_pos(THD* th
if (timeout > 0)
{
/*
- Note that pthread_cond_timedwait checks for the timeout
+ Note that MYSQL_COND_TIMEDWAIT checks for the timeout
before for the condition ; i.e. it returns ETIMEDOUT
if the system time equals or exceeds the time specified by abstime
before the condition variable is signaled or broadcast, _or_ if
the absolute time specified by abstime has already passed at the time
of the call.
- For that reason, pthread_cond_timedwait will do the "timeoutting" job
+ For that reason, MYSQL_COND_TIMEDWAIT will do the "timeoutting" job
even if its condition is always immediately signaled (case of a loaded
master).
*/
- error=pthread_cond_timedwait(&data_cond, &data_lock, &abstime);
+ error=MYSQL_COND_TIMEDWAIT(&data_cond, &data_lock, &abstime);
}
else
- pthread_cond_wait(&data_cond, &data_lock);
+ MYSQL_COND_WAIT(&data_cond, &data_lock);
DBUG_PRINT("info",("Got signal of master update or timed out"));
if (error == ETIMEDOUT || error == ETIME)
{
@@ -790,7 +790,7 @@ void Relay_log_info::inc_group_relay_log
DBUG_ENTER("Relay_log_info::inc_group_relay_log_pos");
if (!skip_lock)
- pthread_mutex_lock(&data_lock);
+ MYSQL_MUTEX_LOCK(&data_lock);
inc_event_relay_log_pos();
group_relay_log_pos= event_relay_log_pos;
strmake(group_relay_log_name,event_relay_log_name,
@@ -834,9 +834,9 @@ void Relay_log_info::inc_group_relay_log
{
group_master_log_pos= log_pos;
}
- pthread_cond_broadcast(&data_cond);
+ MYSQL_COND_BROADCAST(&data_cond);
if (!skip_lock)
- pthread_mutex_unlock(&data_lock);
+ MYSQL_MUTEX_UNLOCK(&data_lock);
DBUG_VOID_RETURN;
}
@@ -905,7 +905,7 @@ int purge_relay_logs(Relay_log_info* rli
DBUG_ASSERT(rli->mi->slave_running == 0);
rli->slave_skip_counter=0;
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
/*
we close the relay log fd possibly left open by the slave SQL thread,
@@ -947,7 +947,7 @@ err:
char buf[22];
#endif
DBUG_PRINT("info",("log_space_total: %s",llstr(rli->log_space_total,buf)));
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
DBUG_RETURN(error);
}
=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h 2008-05-23 13:54:03 +0000
+++ b/sql/rpl_rli.h 2008-10-10 20:34:55 +0000
@@ -49,6 +49,16 @@ class Master_info;
*****************************************************************************/
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_RLI_run_lock;
+extern PSI_mutex_key key_RLI_data_lock;
+extern PSI_mutex_key key_RLI_log_space_lock;
+extern PSI_cond_key key_RLI_data_cond;
+extern PSI_cond_key key_RLI_start_cond;
+extern PSI_cond_key key_RLI_stop_cond;
+extern PSI_cond_key key_RLI_log_space_cond;
+#endif
+
class Relay_log_info : public Slave_reporting_capability
{
public:
@@ -112,14 +122,14 @@ public:
standard lock acquistion order to avoid deadlocks:
run_lock, data_lock, relay_log.LOCK_log, relay_log.LOCK_index
*/
- pthread_mutex_t data_lock,run_lock;
+ mysql_mutex_t data_lock,run_lock;
/*
start_cond is broadcast when SQL thread is started
stop_cond - when stopped
data_cond - when data protected by data_lock changes
*/
- pthread_cond_t start_cond, stop_cond, data_cond;
+ mysql_cond_t start_cond, stop_cond, data_cond;
/* parent Master_info structure */
Master_info *mi;
@@ -201,8 +211,8 @@ public:
volatile uint32 slave_skip_counter;
volatile ulong abort_pos_wait; /* Incremented on change master */
volatile ulong slave_run_id; /* Incremented on slave start */
- pthread_mutex_t log_space_lock;
- pthread_cond_t log_space_cond;
+ mysql_mutex_t log_space_lock;
+ mysql_cond_t log_space_cond;
THD * sql_thd;
#ifndef DBUG_OFF
int events_till_abort;
=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc 2008-06-27 19:07:13 +0000
+++ b/sql/scheduler.cc 2008-10-10 20:34:55 +0000
@@ -56,7 +56,7 @@ scheduler_functions::scheduler_functions
static bool no_threads_end(THD *thd, bool put_in_cache)
{
unlink_thd(thd);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
return 1; // Abort handle_one_connection
}
@@ -102,7 +102,11 @@ static bool kill_pool_threads;
static struct event thd_add_event;
static struct event thd_kill_event;
-static pthread_mutex_t LOCK_thd_add; /* protects thds_need_adding */
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_thd_add;
+#endif
+
+static mysql_mutex_t LOCK_thd_add; /* protects thds_need_adding */
static LIST *thds_need_adding; /* list of thds to add to libevent queue */
static int thd_add_pipe[2]; /* pipe to signal add a connection to libevent*/
@@ -112,7 +116,10 @@ static int thd_kill_pipe[2]; /* pipe to
LOCK_event_loop protects the non-thread safe libevent calls (event_add and
event_del) and thds_need_processing and thds_waiting_for_io.
*/
-static pthread_mutex_t LOCK_event_loop;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_event_loop;
+#endif
+static mysql_mutex_t LOCK_event_loop;
static LIST *thds_need_processing; /* list of thds that needs some processing */
static LIST *thds_waiting_for_io; /* list of thds with added events */
@@ -222,9 +229,9 @@ void thd_scheduler::thread_detach()
if (thread_attached)
{
THD* thd = (THD*)list.data;
- pthread_mutex_lock(&thd->LOCK_delete);
+ MYSQL_MUTEX_LOCK(&thd->LOCK_delete);
thd->mysys_var= NULL;
- pthread_mutex_unlock(&thd->LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&thd->LOCK_delete);
thread_attached= FALSE;
#ifndef DBUG_OFF
/*
@@ -269,8 +276,8 @@ static bool libevent_init(void)
killed_threads= 0;
kill_pool_threads= FALSE;
- pthread_mutex_init(&LOCK_event_loop, NULL);
- pthread_mutex_init(&LOCK_thd_add, NULL);
+ MYSQL_MUTEX_INIT(&LOCK_event_loop, key_LOCK_event_loop, NULL);
+ MYSQL_MUTEX_INIT(&LOCK_thd_add, key_LOCK_thd_add, NULL);
/* set up the pipe used to add new thds to the event pool */
if (init_pipe(thd_add_pipe))
@@ -299,7 +306,7 @@ static bool libevent_init(void)
}
/* Set up the thread pool */
created_threads= killed_threads= 0;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
for (i= 0; i < thread_pool_size; i++)
{
@@ -310,7 +317,7 @@ static bool libevent_init(void)
{
sql_print_error("Can't create completion port thread (error %d)",
error);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
libevent_end(); // Cleanup
DBUG_RETURN(TRUE);
}
@@ -318,8 +325,8 @@ static bool libevent_init(void)
/* Wait until all threads are created */
while (created_threads != thread_pool_size)
- pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_WAIT(&COND_thread_count,&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_PRINT("info", ("%u threads created", (uint) thread_pool_size));
DBUG_RETURN(FALSE);
@@ -339,7 +346,7 @@ static bool li