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
2693 Marc Alff 2008-09-29
New tree
modified:
.bzr-mysql/default.conf
=== 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 libevent_init(void)
void libevent_io_callback(int, short, void *ctx)
{
- safe_mutex_assert_owner(&LOCK_event_loop);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_event_loop);
THD *thd= (THD*)ctx;
thds_waiting_for_io= list_delete(thds_waiting_for_io, &thd->scheduler.list);
thds_need_processing= list_add(thds_need_processing, &thd->scheduler.list);
@@ -354,7 +361,7 @@ void libevent_io_callback(int, short, vo
void libevent_kill_thd_callback(int Fd, short, void*)
{
- safe_mutex_assert_owner(&LOCK_event_loop);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_event_loop);
/* clear the pending events */
char c;
@@ -392,21 +399,21 @@ void libevent_kill_thd_callback(int Fd,
void libevent_add_thd_callback(int Fd, short, void *)
{
- safe_mutex_assert_owner(&LOCK_event_loop);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_event_loop);
/* clear the pending events */
char c;
while (read(Fd, &c, sizeof(c)) == sizeof(c))
{}
- pthread_mutex_lock(&LOCK_thd_add);
+ MYSQL_MUTEX_LOCK(&LOCK_thd_add);
while (thds_need_adding)
{
/* pop the first thd off the list */
THD* thd= (THD*)thds_need_adding->data;
thds_need_adding= list_delete(thds_need_adding, thds_need_adding);
- pthread_mutex_unlock(&LOCK_thd_add);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thd_add);
if (!thd->scheduler.logged_in || libevent_should_close_connection(thd))
{
@@ -431,9 +438,9 @@ void libevent_add_thd_callback(int Fd, s
&thd->scheduler.list);
}
}
- pthread_mutex_lock(&LOCK_thd_add);
+ MYSQL_MUTEX_LOCK(&LOCK_thd_add);
}
- pthread_mutex_unlock(&LOCK_thd_add);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thd_add);
}
@@ -453,14 +460,14 @@ static void libevent_add_connection(THD
if (thd->scheduler.init(thd))
{
sql_print_error("Scheduler init error in libevent_add_new_connection\n");
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
libevent_connection_close(thd);
DBUG_VOID_RETURN;
}
threads.append(thd);
libevent_thd_add(thd);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
@@ -509,7 +516,7 @@ static void libevent_connection_close(TH
}
thd->scheduler.thread_detach();
unlink_thd(thd); /* locks LOCK_thread_count and deletes thd */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
@@ -546,16 +553,16 @@ pthread_handler_t libevent_thread_proc(v
Signal libevent_init() when all threads has been created and are ready to
receive events.
*/
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
created_threads++;
if (created_threads == thread_pool_size)
- (void) pthread_cond_signal(&COND_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_COND_SIGNAL(&COND_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
for (;;)
{
THD *thd= NULL;
- (void) pthread_mutex_lock(&LOCK_event_loop);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_event_loop);
/* get thd(s) to process */
while (!thds_need_processing)
@@ -563,7 +570,7 @@ pthread_handler_t libevent_thread_proc(v
if (kill_pool_threads)
{
/* the flag that we should die has been set */
- (void) pthread_mutex_unlock(&LOCK_event_loop);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_event_loop);
goto thread_exit;
}
event_loop(EVLOOP_ONCE);
@@ -574,7 +581,7 @@ pthread_handler_t libevent_thread_proc(v
thds_need_processing= list_delete(thds_need_processing,
thds_need_processing);
- (void) pthread_mutex_unlock(&LOCK_event_loop);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_event_loop);
/* now we process the connection (thd) */
@@ -621,10 +628,10 @@ pthread_handler_t libevent_thread_proc(v
thread_exit:
DBUG_PRINT("exit", ("ending thread"));
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
killed_threads++;
- pthread_cond_broadcast(&COND_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_COND_BROADCAST(&COND_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
my_thread_end();
pthread_exit(0);
DBUG_RETURN(0); /* purify: deadcode */
@@ -672,12 +679,12 @@ static void libevent_thd_add(THD* thd)
char c=0;
/* release any audit resources, this thd is going to sleep */
mysql_audit_release(thd);
- pthread_mutex_lock(&LOCK_thd_add);
+ MYSQL_MUTEX_LOCK(&LOCK_thd_add);
/* queue for libevent */
thds_need_adding= list_add(thds_need_adding, &thd->scheduler.list);
/* notify libevent */
write(thd_add_pipe[1], &c, sizeof(c));
- pthread_mutex_unlock(&LOCK_thd_add);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thd_add);
}
@@ -691,7 +698,7 @@ static void libevent_end()
DBUG_PRINT("enter", ("created_threads: %d killed_threads: %u",
created_threads, killed_threads));
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
kill_pool_threads= TRUE;
while (killed_threads != created_threads)
@@ -700,9 +707,9 @@ static void libevent_end()
char c= 0;
write(thd_add_pipe[1], &c, sizeof(c));
- pthread_cond_wait(&COND_thread_count, &LOCK_thread_count);
+ MYSQL_COND_WAIT(&COND_thread_count, &LOCK_thread_count);
}
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
event_del(&thd_add_event);
close(thd_add_pipe[0]);
@@ -712,8 +719,8 @@ static void libevent_end()
close(thd_kill_pipe[1]);
event_base_free(base);
- (void) pthread_mutex_destroy(&LOCK_event_loop);
- (void) pthread_mutex_destroy(&LOCK_thd_add);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_event_loop);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_thd_add);
DBUG_VOID_RETURN;
}
=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc 2008-09-16 08:34:30 +0000
+++ b/sql/set_var.cc 2008-10-10 20:34:55 +0000
@@ -909,7 +909,7 @@ bool sys_var_str::check(THD *thd, set_va
'var' parameter is NULL pointer.
*/
-bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex,
+bool update_sys_var_str(sys_var_str *var_str, mysql_rwlock_t *var_mutex,
set_var *var)
{
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
@@ -922,11 +922,11 @@ bool update_sys_var_str(sys_var_str *var
Replace the old value in such a way that the any thread using
the value will work.
*/
- rw_wrlock(var_mutex);
+ MYSQL_RWLOCK_WRLOCK(var_mutex);
old_value= var_str->value;
var_str->value= res;
var_str->value_length= new_length;
- rw_unlock(var_mutex);
+ MYSQL_RWLOCK_UNLOCK(var_mutex);
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
return 0;
}
@@ -1201,9 +1201,9 @@ bool sys_var_set_slave_mode::check(THD *
bool sys_var_set_slave_mode::update(THD *thd, set_var *var)
{
bool rc;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
rc= sys_var_set::update(thd, var);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return rc;
}
@@ -1402,7 +1402,7 @@ bool sys_var_long_ptr_global::check(THD
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
- pthread_mutex_lock(guard);
+ MYSQL_MUTEX_LOCK(guard);
if (option_limits)
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
else
@@ -1419,7 +1419,7 @@ bool sys_var_long_ptr_global::update(THD
*value= (ulong) tmp;
}
- pthread_mutex_unlock(guard);
+ MYSQL_MUTEX_UNLOCK(guard);
return 0;
}
@@ -1427,22 +1427,22 @@ bool sys_var_long_ptr_global::update(THD
void sys_var_long_ptr_global::set_default(THD *thd, enum_var_type type)
{
my_bool not_used;
- pthread_mutex_lock(guard);
+ MYSQL_MUTEX_LOCK(guard);
*value= (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
option_limits, ¬_used);
- pthread_mutex_unlock(guard);
+ MYSQL_MUTEX_UNLOCK(guard);
}
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (option_limits)
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
else
*value= (ulonglong) tmp;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return 0;
}
@@ -1450,10 +1450,10 @@ bool sys_var_ulonglong_ptr::update(THD *
void sys_var_ulonglong_ptr::set_default(THD *thd, enum_var_type type)
{
my_bool not_used;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
option_limits, ¬_used);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
@@ -1561,9 +1561,9 @@ bool sys_var_thd_ha_rows::update(THD *th
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.*offset= (ha_rows) tmp;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.*offset= (ha_rows) tmp;
@@ -1577,11 +1577,11 @@ void sys_var_thd_ha_rows::set_default(TH
{
my_bool not_used;
/* We will not come here if option_limits is not set */
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.*offset=
(ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
option_limits, ¬_used);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.*offset= global_system_variables.*offset;
@@ -1613,9 +1613,9 @@ bool sys_var_thd_ulonglong::update(THD *
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.*offset= (ulonglong) tmp;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.*offset= (ulonglong) tmp;
@@ -1628,11 +1628,11 @@ void sys_var_thd_ulonglong::set_default(
if (type == OPT_GLOBAL)
{
my_bool not_used;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.*offset=
getopt_ull_limit_value((ulonglong) option_limits->def_value,
option_limits, ¬_used);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.*offset= global_system_variables.*offset;
@@ -1803,56 +1803,56 @@ Item *sys_var::item(THD *thd, enum_var_t
case SHOW_INT:
{
uint value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
value= *(uint*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return new Item_uint((ulonglong) value);
}
case SHOW_LONG:
{
ulong value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
value= *(ulong*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return new Item_uint((ulonglong) value);
}
case SHOW_LONGLONG:
{
longlong value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
value= *(longlong*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return new Item_int(value);
}
case SHOW_DOUBLE:
{
double value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
value= *(double*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
/* 6, as this is for now only used with microseconds */
return new Item_float(value, 6);
}
case SHOW_HA_ROWS:
{
ha_rows value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
value= *(ha_rows*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return new Item_int((ulonglong) value);
}
case SHOW_MY_BOOL:
{
int32 value;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
value= *(my_bool*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return new Item_int(value,1);
}
case SHOW_CHAR_PTR:
{
Item *tmp;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
char *str= *(char**) value_ptr(thd, var_type, base);
if (str)
{
@@ -1865,13 +1865,13 @@ Item *sys_var::item(THD *thd, enum_var_t
tmp= new Item_null();
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
}
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return tmp;
}
case SHOW_CHAR:
{
Item *tmp;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
char *str= (char*) value_ptr(thd, var_type, base);
if (str)
tmp= new Item_string(str, strlen(str),
@@ -1881,7 +1881,7 @@ Item *sys_var::item(THD *thd, enum_var_t
tmp= new Item_null();
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
}
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return tmp;
}
default:
@@ -1957,10 +1957,10 @@ void sys_var_thd_date_time_format::updat
if (type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
old= (global_system_variables.*offset);
(global_system_variables.*offset)= new_value;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
{
@@ -2272,7 +2272,7 @@ static KEY_CACHE zero_key_cache;
KEY_CACHE *get_key_cache(LEX_STRING *cache_name)
{
- safe_mutex_assert_owner(&LOCK_global_system_variables);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_global_system_variables);
if (!cache_name || ! cache_name->length)
cache_name= &default_key_cache_base;
return ((KEY_CACHE*) find_named(&key_caches,
@@ -2300,7 +2300,7 @@ bool sys_var_key_buffer_size::update(THD
if (!base_name->length)
base_name= &default_key_cache_base;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
key_cache= get_key_cache(base_name);
if (!key_cache)
@@ -2343,9 +2343,9 @@ bool sys_var_key_buffer_size::update(THD
key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str,
base_name->length, &list);
key_cache->in_init= 1;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
error= reassign_keycache_tables(thd, key_cache, dflt_key_cache);
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
key_cache->in_init= 0;
}
/*
@@ -2360,18 +2360,18 @@ bool sys_var_key_buffer_size::update(THD
/* If key cache didn't existed initialize it, else resize it */
key_cache->in_init= 1;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
if (!key_cache->key_cache_inited)
error= (bool) (ha_init_key_cache("", key_cache));
else
error= (bool)(ha_resize_key_cache(key_cache));
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
key_cache->in_init= 0;
end:
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return error;
}
@@ -2391,7 +2391,7 @@ bool sys_var_key_cache_long::update(THD
if (!base_name->length)
base_name= &default_key_cache_base;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
KEY_CACHE *key_cache= get_key_cache(base_name);
if (!key_cache && !(key_cache= create_key_cache(base_name->str,
@@ -2418,15 +2418,15 @@ bool sys_var_key_cache_long::update(THD
*/
key_cache->in_init= 1;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
error= (bool) (ha_resize_key_cache(key_cache));
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
key_cache->in_init= 0;
end:
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return error;
}
@@ -2434,7 +2434,7 @@ end:
bool sys_var_log_state::update(THD *thd, set_var *var)
{
bool res;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (!var->save_result.ulong_value)
{
logger.deactivate_log_handler(thd, log_type);
@@ -2442,15 +2442,15 @@ bool sys_var_log_state::update(THD *thd,
}
else
res= logger.activate_log_handler(thd, log_type);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return res;
}
void sys_var_log_state::set_default(THD *thd, enum_var_type type)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.deactivate_log_handler(thd, log_type);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
@@ -2585,7 +2585,7 @@ bool update_sys_var_str_path(THD *thd, s
goto err;
}
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.lock_exclusive();
/*
@@ -2639,7 +2639,7 @@ bool update_sys_var_str_path(THD *thd, s
}
logger.unlock();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
err:
return result;
@@ -2735,26 +2735,26 @@ static void sys_default_slow_log_path(TH
bool sys_var_log_output::update(THD *thd, set_var *var)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.lock_exclusive();
logger.init_slow_log(var->save_result.ulong_value);
logger.init_general_log(var->save_result.ulong_value);
*value= var->save_result.ulong_value;
logger.unlock();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return 0;
}
void sys_var_log_output::set_default(THD *thd, enum_var_type type)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.lock_exclusive();
logger.init_slow_log(LOG_FILE);
logger.init_general_log(LOG_FILE);
*value= LOG_FILE;
logger.unlock();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
@@ -2787,13 +2787,13 @@ uchar *sys_var_log_output::value_ptr(THD
*/
bool sys_var_log_backup_output::update(THD *thd, set_var *var)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.lock_exclusive();
logger.init_backup_history_log(var->save_result.ulong_value);
logger.init_backup_progress_log(var->save_result.ulong_value);
*value= var->save_result.ulong_value;
logger.unlock();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return 0;
}
@@ -2802,13 +2802,13 @@ bool sys_var_log_backup_output::update(T
*/
void sys_var_log_backup_output::set_default(THD *thd, enum_var_type type)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.lock_exclusive();
logger.init_backup_history_log(LOG_TABLE);
logger.init_backup_progress_log(LOG_TABLE);
*value= LOG_TABLE;
logger.unlock();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
/*
@@ -2935,13 +2935,13 @@ static bool sys_update_backupdir(THD *th
goto err;
}
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
logger.lock_exclusive();
old_value= sys_var_backupdir.value;
sys_var_backupdir.value= res;
sys_var_backupdir.value_length= str_length;
logger.unlock();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
if (my_access(sys_var_backupdir.value, (F_OK|W_OK)))
goto err;
@@ -3148,9 +3148,9 @@ bool sys_var_thd_time_zone::update(THD *
/* We are using Time_zone object found during check() phase. */
if (var->type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.time_zone= var->save_result.time_zone;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.time_zone= var->save_result.time_zone;
@@ -3185,7 +3185,7 @@ uchar *sys_var_thd_time_zone::value_ptr(
void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (type == OPT_GLOBAL)
{
if (default_tz_name)
@@ -3202,7 +3202,7 @@ void sys_var_thd_time_zone::set_default(
}
else
thd->variables.time_zone= global_system_variables.time_zone;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
@@ -3224,9 +3224,9 @@ bool sys_var_max_user_conn::check(THD *t
bool sys_var_max_user_conn::update(THD *thd, set_var *var)
{
DBUG_ASSERT(var->type == OPT_GLOBAL);
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
max_user_connections= (uint)var->save_result.ulonglong_value;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return 0;
}
@@ -3234,9 +3234,9 @@ bool sys_var_max_user_conn::update(THD *
void sys_var_max_user_conn::set_default(THD *thd, enum_var_type type)
{
DBUG_ASSERT(type == OPT_GLOBAL);
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
max_user_connections= (ulong) option_limits->def_value;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
@@ -3334,9 +3334,9 @@ bool sys_var_microseconds::update(THD *t
microseconds= (longlong) (num * 1000000.0 + 0.5);
if (var->type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
(global_system_variables.*offset)= microseconds;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.*offset= microseconds;
@@ -3349,9 +3349,9 @@ void sys_var_microseconds::set_default(T
longlong microseconds= (longlong) (option_limits->def_value * 1000000.0);
if (type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.*offset= microseconds;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.*offset= microseconds;
@@ -4395,10 +4395,10 @@ KEY_CACHE *get_or_create_key_cache(const
key_cache_name.str= (char *) name;
key_cache_name.length= length;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (!(key_cache= get_key_cache(&key_cache_name)))
key_cache= create_key_cache(name, length);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
return key_cache;
}
=== modified file 'sql/set_var.h'
--- a/sql/set_var.h 2008-08-27 17:30:49 +0000
+++ b/sql/set_var.h 2008-10-10 20:34:55 +0000
@@ -131,10 +131,10 @@ private:
class sys_var_global: public sys_var
{
protected:
- pthread_mutex_t *guard;
+ mysql_mutex_t *guard;
public:
sys_var_global(const char *name_arg, sys_after_update_func after_update_arg,
- pthread_mutex_t *guard_arg)
+ mysql_mutex_t *guard_arg)
:sys_var(name_arg, after_update_arg), guard(guard_arg) {}
};
@@ -150,7 +150,7 @@ public:
ulong *value;
sys_var_long_ptr_global(sys_var_chain *chain, const char *name_arg,
ulong *value_ptr_arg,
- pthread_mutex_t *guard_arg,
+ mysql_mutex_t *guard_arg,
sys_after_update_func after_update_arg= NULL)
:sys_var_global(name_arg, after_update_arg, guard_arg),
value(value_ptr_arg)
=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc 2008-09-11 16:28:29 +0000
+++ b/sql/si_objects.cc 2008-10-10 20:34:55 +0000
@@ -57,9 +57,9 @@ int silent_exec(THD *thd, String *query)
thd->query_length= query->length();
thd->set_time();
- 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);
/*
@todo The following is a work around for online backup and the DDL blocker.
@@ -91,13 +91,13 @@ int silent_exec(THD *thd, String *query)
next_packet++;
length--;
}
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query_length= length;
thd->query= next_packet;
thd->query_id= next_query_id();
thd->set_time(); /* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
mysql_parse(thd, next_packet, length, & found_semicolon);
}
@@ -3852,7 +3852,7 @@ int Name_locker::get_name_locks(List<Obj
{
if (lock_table_names(m_thd, m_table_list))
ret= 1;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (ltable= m_table_list; ltable; ltable= ltable->next_local)
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, ltable->db,
ltable->table_name);
@@ -3873,7 +3873,7 @@ int Name_locker::release_name_locks()
DBUG_ENTER("Name_locker::release_name_locks()");
if (m_table_list)
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
unlock_table_names(m_thd);
}
DBUG_RETURN(0);
=== modified file 'sql/slave.cc'
--- a/sql/slave.cc 2008-08-08 01:39:23 +0000
+++ b/sql/slave.cc 2008-10-10 20:34:55 +0000
@@ -139,8 +139,8 @@ static int get_master_version_and_clock(
static Log_event* next_event(Relay_log_info* rli);
static int queue_event(Master_info* mi,const char* buf,ulong event_len);
static int terminate_slave_thread(THD *thd,
- pthread_mutex_t* term_lock,
- pthread_cond_t* term_cond,
+ mysql_mutex_t* term_lock,
+ mysql_cond_t* term_cond,
volatile uint *slave_running,
bool skip_lock);
static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info);
@@ -189,8 +189,8 @@ void lock_slave_threads(Master_info* mi)
DBUG_ENTER("lock_slave_threads");
//TODO: see if we can do this without dual mutex
- pthread_mutex_lock(&mi->run_lock);
- pthread_mutex_lock(&mi->rli.run_lock);
+ MYSQL_MUTEX_LOCK(&mi->run_lock);
+ MYSQL_MUTEX_LOCK(&mi->rli.run_lock);
DBUG_VOID_RETURN;
}
@@ -204,8 +204,8 @@ void unlock_slave_threads(Master_info* m
DBUG_ENTER("unlock_slave_threads");
//TODO: see if we can do this without dual mutex
- pthread_mutex_unlock(&mi->rli.run_lock);
- pthread_mutex_unlock(&mi->run_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->rli.run_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->run_lock);
DBUG_VOID_RETURN;
}
@@ -221,7 +221,7 @@ int init_slave()
accepted. However bootstrap may conflict with us if it does START SLAVE.
So it's safer to take the lock.
*/
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
/*
TODO: re-write this to interate through the list of files
for multi-master
@@ -261,11 +261,11 @@ int init_slave()
goto err;
}
}
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
DBUG_RETURN(0);
err:
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
DBUG_RETURN(1);
}
@@ -320,7 +320,7 @@ int terminate_slave_threads(Master_info*
if (!mi->inited)
DBUG_RETURN(0); /* successfully do nothing */
int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
- pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
+ mysql_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
if ((thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)))
{
@@ -379,8 +379,8 @@ int terminate_slave_threads(Master_info*
*/
static int
terminate_slave_thread(THD *thd,
- pthread_mutex_t* term_lock,
- pthread_cond_t* term_cond,
+ mysql_mutex_t* term_lock,
+ mysql_cond_t* term_cond,
volatile uint *slave_running,
bool skip_lock)
{
@@ -389,14 +389,14 @@ terminate_slave_thread(THD *thd,
DBUG_ENTER("terminate_slave_thread");
if (!skip_lock)
- pthread_mutex_lock(term_lock);
+ MYSQL_MUTEX_LOCK(term_lock);
- safe_mutex_assert_owner(term_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(term_lock);
if (!*slave_running)
{
if (!skip_lock)
- pthread_mutex_unlock(term_lock);
+ MYSQL_MUTEX_UNLOCK(term_lock);
DBUG_RETURN(ER_SLAVE_NOT_RUNNING);
}
DBUG_ASSERT(thd != 0);
@@ -411,7 +411,7 @@ terminate_slave_thread(THD *thd,
{
DBUG_PRINT("loop", ("killing slave thread"));
- pthread_mutex_lock(&thd->LOCK_delete);
+ MYSQL_MUTEX_LOCK(&thd->LOCK_delete);
#ifndef DONT_USE_THR_ALARM
/*
Error codes from pthread_kill are:
@@ -422,7 +422,7 @@ terminate_slave_thread(THD *thd,
DBUG_ASSERT(err != EINVAL);
#endif
thd->awake(THD::NOT_KILLED);
- pthread_mutex_unlock(&thd->LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&thd->LOCK_delete);
/*
There is a small chance that slave thread might miss the first
@@ -430,21 +430,21 @@ terminate_slave_thread(THD *thd,
*/
struct timespec abstime;
set_timespec(abstime,2);
- error= pthread_cond_timedwait(term_cond, term_lock, &abstime);
+ error= MYSQL_COND_TIMEDWAIT(term_cond, term_lock, &abstime);
DBUG_ASSERT(error == ETIMEDOUT || error == 0);
}
DBUG_ASSERT(*slave_running == 0);
if (!skip_lock)
- pthread_mutex_unlock(term_lock);
+ MYSQL_MUTEX_UNLOCK(term_lock);
DBUG_RETURN(0);
}
-int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
- pthread_mutex_t *cond_lock,
- pthread_cond_t *start_cond,
+int start_slave_thread(pthread_handler h_func, mysql_mutex_t *start_lock,
+ mysql_mutex_t *cond_lock,
+ mysql_cond_t *start_cond,
volatile uint *slave_running,
volatile ulong *slave_run_id,
Master_info* mi,
@@ -457,13 +457,13 @@ int start_slave_thread(pthread_handler h
DBUG_ASSERT(mi->inited);
if (start_lock)
- pthread_mutex_lock(start_lock);
+ MYSQL_MUTEX_LOCK(start_lock);
if (!server_id)
{
if (start_cond)
- pthread_cond_broadcast(start_cond);
+ MYSQL_COND_BROADCAST(start_cond);
if (start_lock)
- pthread_mutex_unlock(start_lock);
+ MYSQL_MUTEX_UNLOCK(start_lock);
sql_print_error("Server id not set, will not start slave");
DBUG_RETURN(ER_BAD_SLAVE);
}
@@ -471,9 +471,9 @@ int start_slave_thread(pthread_handler h
if (*slave_running)
{
if (start_cond)
- pthread_cond_broadcast(start_cond);
+ MYSQL_COND_BROADCAST(start_cond);
if (start_lock)
- pthread_mutex_unlock(start_lock);
+ MYSQL_MUTEX_UNLOCK(start_lock);
DBUG_RETURN(ER_SLAVE_MUST_STOP);
}
start_id= *slave_run_id;
@@ -483,7 +483,7 @@ int start_slave_thread(pthread_handler h
if (pthread_create(&th, &connection_attrib, h_func, (void*)mi))
{
if (start_lock)
- pthread_mutex_unlock(start_lock);
+ MYSQL_MUTEX_UNLOCK(start_lock);
DBUG_RETURN(ER_SLAVE_THREAD);
}
if (start_cond && cond_lock) // caller has cond_lock
@@ -494,15 +494,15 @@ int start_slave_thread(pthread_handler h
DBUG_PRINT("sleep",("Waiting for slave thread to start"));
const char* old_msg = thd->enter_cond(start_cond,cond_lock,
"Waiting for slave thread to start");
- pthread_cond_wait(start_cond,cond_lock);
+ MYSQL_COND_WAIT(start_cond,cond_lock);
thd->exit_cond(old_msg);
- pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
+ MYSQL_MUTEX_LOCK(cond_lock); // re-acquire it as exit_cond() released
if (thd->killed)
DBUG_RETURN(thd->killed_errno());
}
}
if (start_lock)
- pthread_mutex_unlock(start_lock);
+ MYSQL_MUTEX_UNLOCK(start_lock);
DBUG_RETURN(0);
}
@@ -520,8 +520,8 @@ int start_slave_threads(bool need_slave_
Master_info* mi, const char* master_info_fname,
const char* slave_info_fname, int thread_mask)
{
- pthread_mutex_t *lock_io=0,*lock_sql=0,*lock_cond_io=0,*lock_cond_sql=0;
- pthread_cond_t* cond_io=0,*cond_sql=0;
+ mysql_mutex_t *lock_io=0,*lock_sql=0,*lock_cond_io=0,*lock_cond_sql=0;
+ mysql_cond_t* cond_io=0,*cond_sql=0;
int error=0;
DBUG_ENTER("start_slave_threads");
@@ -585,7 +585,7 @@ void end_slave()
will make us wait until slave threads have started, and START SLAVE
returns, then we terminate them here.
*/
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
if (active_mi)
{
/*
@@ -598,7 +598,7 @@ void end_slave()
delete active_mi;
active_mi= 0;
}
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
DBUG_VOID_RETURN;
}
@@ -1054,7 +1054,7 @@ static bool wait_for_relay_log_space(Rel
THD* thd = mi->io_thd;
DBUG_ENTER("wait_for_relay_log_space");
- pthread_mutex_lock(&rli->log_space_lock);
+ MYSQL_MUTEX_LOCK(&rli->log_space_lock);
save_proc_info= thd->enter_cond(&rli->log_space_cond,
&rli->log_space_lock,
"\
@@ -1062,7 +1062,7 @@ Waiting for the slave SQL thread to free
while (rli->log_space_limit < rli->log_space_total &&
!(slave_killed=io_slave_killed(thd,mi)) &&
!rli->ignore_log_space_limit)
- pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock);
+ MYSQL_COND_WAIT(&rli->log_space_cond, &rli->log_space_lock);
thd->exit_cond(save_proc_info);
DBUG_RETURN(slave_killed);
}
@@ -1084,11 +1084,11 @@ Waiting for the slave SQL thread to free
static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi)
{
Relay_log_info *rli= &mi->rli;
- pthread_mutex_t *log_lock= rli->relay_log.get_log_lock();
+ mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();
DBUG_ENTER("write_ignored_events_info_to_relay_log");
DBUG_ASSERT(thd == mi->io_thd);
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
if (rli->ign_master_log_name_end[0])
{
DBUG_PRINT("info",("writing a Rotate event to track down ignored events"));
@@ -1097,7 +1097,7 @@ static void write_ignored_events_info_to
Rotate_log_event::DUP_NAME);
rli->ign_master_log_name_end[0]= 0;
/* can unlock before writing as slave SQL thd will soon see our Rotate */
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
if (likely((bool)ev))
{
ev->server_id= 0; // don't be ignored by slave SQL thread
@@ -1119,7 +1119,7 @@ static void write_ignored_events_info_to
" SHOW SLAVE STATUS may be inaccurate");
}
else
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
DBUG_VOID_RETURN;
}
@@ -1255,12 +1255,12 @@ bool show_master_info(THD* thd, Master_i
slave_running can be accessed without run_lock but not other
non-volotile members like mi->io_thd, which is guarded by the mutex.
*/
- pthread_mutex_lock(&mi->run_lock);
+ MYSQL_MUTEX_LOCK(&mi->run_lock);
protocol->store(mi->io_thd ? mi->io_thd->proc_info : "", &my_charset_bin);
- pthread_mutex_unlock(&mi->run_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->run_lock);
- pthread_mutex_lock(&mi->data_lock);
- pthread_mutex_lock(&mi->rli.data_lock);
+ MYSQL_MUTEX_LOCK(&mi->data_lock);
+ MYSQL_MUTEX_LOCK(&mi->rli.data_lock);
protocol->store(mi->host, &my_charset_bin);
protocol->store(mi->user, &my_charset_bin);
protocol->store((uint32) mi->port);
@@ -1360,8 +1360,8 @@ bool show_master_info(THD* thd, Master_i
// Last_SQL_Error
protocol->store(mi->rli.last_error().message, &my_charset_bin);
- pthread_mutex_unlock(&mi->rli.data_lock);
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->rli.data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
if (my_net_write(&thd->net, (uchar*) thd->packet.ptr(), packet->length()))
DBUG_RETURN(TRUE);
@@ -1440,9 +1440,9 @@ static int init_slave_thread(THD* thd, S
thd->enable_slow_log= opt_log_slow_slave_statements;
set_slave_thread_options(thd);
thd->client_capabilities = CLIENT_LOCAL_FILES;
- 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);
DBUG_EXECUTE_IF("simulate_io_slave_error_on_init",
simulate_error|= (1 << SLAVE_THD_IO););
@@ -1756,7 +1756,7 @@ int apply_event_and_update_pos(Log_event
int reason= ev->shall_skip(rli);
if (reason == Log_event::EVENT_SKIP_COUNT)
--rli->slave_skip_counter;
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
if (reason == Log_event::EVENT_SKIP_NOT)
exec_res= ev->apply_event(rli);
#ifndef DBUG_OFF
@@ -1864,7 +1864,7 @@ static int exec_relay_log_event(THD* thd
event execution. But we will release it in places where we will
wait for something for example inside of next_event().
*/
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
Log_event * ev = next_event(rli);
@@ -1872,7 +1872,7 @@ static int exec_relay_log_event(THD* thd
if (sql_slave_killed(thd,rli))
{
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
delete ev;
DBUG_RETURN(1);
}
@@ -1897,7 +1897,7 @@ static int exec_relay_log_event(THD* thd
error in query execution to be printed.
*/
rli->abort_slave= 1;
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
delete ev;
DBUG_RETURN(1);
}
@@ -1958,10 +1958,10 @@ static int exec_relay_log_event(THD* thd
/* chance for concurrent connection to get more locks */
safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
(CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
+ MYSQL_MUTEX_LOCK(&rli->data_lock); // because of SHOW STATUS
rli->trans_retries++;
rli->retried_trans++;
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
DBUG_PRINT("info", ("Slave retries transaction "
"rli->trans_retries: %lu", rli->trans_retries));
}
@@ -1989,7 +1989,7 @@ static int exec_relay_log_event(THD* thd
}
DBUG_RETURN(exec_res);
}
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
rli->report(ERROR_LEVEL, ER_SLAVE_RELAY_LOG_READ_FAILURE,
ER(ER_SLAVE_RELAY_LOG_READ_FAILURE), "\
Could not parse relay log event entry. The possible reasons are: the master's \
@@ -2102,7 +2102,7 @@ pthread_handler_t handle_slave_io(void *
mysql= NULL ;
retry_count= 0;
- pthread_mutex_lock(&mi->run_lock);
+ MYSQL_MUTEX_LOCK(&mi->run_lock);
/* Inform waiting threads that slave has started */
mi->slave_run_id++;
@@ -2118,18 +2118,18 @@ pthread_handler_t handle_slave_io(void *
thd->thread_stack= (char*) &thd; // remember where our stack is
if (init_slave_thread(thd, SLAVE_THD_IO))
{
- pthread_cond_broadcast(&mi->start_cond);
- pthread_mutex_unlock(&mi->run_lock);
+ MYSQL_COND_BROADCAST(&mi->start_cond);
+ MYSQL_MUTEX_UNLOCK(&mi->run_lock);
sql_print_error("Failed during slave I/O thread initialization");
goto err;
}
- 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);
mi->slave_running = 1;
mi->abort_slave = 0;
- pthread_mutex_unlock(&mi->run_lock);
- pthread_cond_broadcast(&mi->start_cond);
+ MYSQL_MUTEX_UNLOCK(&mi->run_lock);
+ MYSQL_COND_BROADCAST(&mi->start_cond);
DBUG_PRINT("master_info",("log_file_name: '%s' position: %s",
mi->master_log_name,
@@ -2333,10 +2333,10 @@ err:
// print the current replication position
sql_print_information("Slave I/O thread exiting, read up to log '%s', position %s",
IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff));
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query = thd->db = 0; // extra safety
thd->query_length= thd->db_length= 0;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (mysql)
{
/*
@@ -2355,7 +2355,7 @@ err:
}
write_ignored_events_info_to_relay_log(thd, mi);
thd_proc_info(thd, "Waiting for slave mutex on exit");
- pthread_mutex_lock(&mi->run_lock);
+ MYSQL_MUTEX_LOCK(&mi->run_lock);
/* Forget the relay log's format */
delete mi->rli.relay_log.description_event_for_queue;
@@ -2365,10 +2365,10 @@ err:
DBUG_ASSERT(thd->net.buff != 0);
net_end(&thd->net); // destructor will not free it, because net.vio is 0
close_thread_tables(thd);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
THD_CHECK_SENTRY(thd);
delete thd;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
mi->abort_slave= 0;
mi->slave_running= 0;
mi->io_thd= 0;
@@ -2377,8 +2377,8 @@ err:
is important. Otherwise a killer_thread can execute between the calls and
delete the mi structure leading to a crash! (see BUG#25306 for details)
*/
- pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done
- pthread_mutex_unlock(&mi->run_lock);
+ MYSQL_COND_BROADCAST(&mi->stop_cond); // tell the world we are done
+ MYSQL_MUTEX_UNLOCK(&mi->run_lock);
my_thread_end();
pthread_exit(0);
DBUG_RETURN(0); // Can't return anything here
@@ -2400,7 +2400,7 @@ pthread_handler_t handle_slave_sql(void
DBUG_ENTER("handle_slave_sql");
DBUG_ASSERT(rli->inited);
- pthread_mutex_lock(&rli->run_lock);
+ MYSQL_MUTEX_LOCK(&rli->run_lock);
DBUG_ASSERT(!rli->slave_running);
errmsg= 0;
#ifndef DBUG_OFF
@@ -2422,16 +2422,16 @@ pthread_handler_t handle_slave_sql(void
TODO: this is currently broken - slave start and change master
will be stuck if we fail here
*/
- pthread_cond_broadcast(&rli->start_cond);
- pthread_mutex_unlock(&rli->run_lock);
+ MYSQL_COND_BROADCAST(&rli->start_cond);
+ MYSQL_MUTEX_UNLOCK(&rli->run_lock);
sql_print_error("Failed during slave thread initialization");
goto err;
}
thd->init_for_queries();
thd->temporary_tables = rli->save_temporary_tables; // restore temp tables
- 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);
/*
We are going to set slave_running to 1. Assuming slave I/O thread is
alive and connected, this is going to make Seconds_Behind_Master be 0
@@ -2441,8 +2441,8 @@ pthread_handler_t handle_slave_sql(void
Seconds_Behind_Master grows. No big deal.
*/
rli->abort_slave = 0;
- pthread_mutex_unlock(&rli->run_lock);
- pthread_cond_broadcast(&rli->start_cond);
+ MYSQL_MUTEX_UNLOCK(&rli->run_lock);
+ MYSQL_COND_BROADCAST(&rli->start_cond);
/*
Reset errors for a clean start (otherwise, if the master is idle, the SQL
@@ -2457,9 +2457,9 @@ pthread_handler_t handle_slave_sql(void
rli->clear_error();
//tell the I/O thread to take relay_log_space_limit into account from now on
- pthread_mutex_lock(&rli->log_space_lock);
+ MYSQL_MUTEX_LOCK(&rli->log_space_lock);
rli->ignore_log_space_limit= 0;
- pthread_mutex_unlock(&rli->log_space_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->log_space_lock);
rli->trans_retries= 0; // start from "no error"
DBUG_PRINT("info", ("rli->trans_retries: %lu", rli->trans_retries));
@@ -2525,17 +2525,17 @@ Slave SQL thread aborted. Can't execute
First check until condition - probably there is nothing to execute. We
do not want to wait for next event in this case.
*/
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
if (rli->until_condition != Relay_log_info::UNTIL_NONE &&
rli->is_until_satisfied(rli->group_master_log_pos))
{
char buf[22];
sql_print_information("Slave SQL thread stopped because it reached its"
" UNTIL position %s", llstr(rli->until_pos(), buf));
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
goto err;
}
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
/* Read queries from the IO/THREAD until this thread is killed */
@@ -2619,7 +2619,7 @@ the slave SQL thread with \"SLAVE START\
must "proactively" clear playgrounds:
*/
rli->cleanup_context(thd, 1);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
/*
Some extra safety, which should not been needed (normally, event deletion
should already have done these assignments (each event which sets these
@@ -2627,11 +2627,11 @@ the slave SQL thread with \"SLAVE START\
*/
thd->query= thd->db= thd->catalog= 0;
thd->query_length= thd->db_length= 0;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thd_proc_info(thd, "Waiting for slave mutex on exit");
- pthread_mutex_lock(&rli->run_lock);
+ MYSQL_MUTEX_LOCK(&rli->run_lock);
/* We need data_lock, at least to wake up any waiting master_pos_wait() */
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun
/* When master_pos_wait() wakes up it will check this and terminate */
rli->slave_running= 0;
@@ -2639,9 +2639,9 @@ the slave SQL thread with \"SLAVE START\
delete rli->relay_log.description_event_for_exec;
rli->relay_log.description_event_for_exec= 0;
/* Wake up master_pos_wait() */
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions"));
- pthread_cond_broadcast(&rli->data_cond);
+ MYSQL_COND_BROADCAST(&rli->data_cond);
rli->ignore_log_space_limit= 0; /* don't need any lock */
/* we die so won't remember charset - re-update them on next thread start */
rli->cached_charset_invalidate();
@@ -2657,17 +2657,17 @@ the slave SQL thread with \"SLAVE START\
DBUG_ASSERT(rli->sql_thd == thd);
THD_CHECK_SENTRY(thd);
rli->sql_thd= 0;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
THD_CHECK_SENTRY(thd);
delete thd;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
/*
Note: the order of the broadcast and unlock calls below (first broadcast, then unlock)
is important. Otherwise a killer_thread can execute between the calls and
delete the mi structure leading to a crash! (see BUG#25306 for details)
*/
- pthread_cond_broadcast(&rli->stop_cond);
- pthread_mutex_unlock(&rli->run_lock); // tell the world we are done
+ MYSQL_COND_BROADCAST(&rli->stop_cond);
+ MYSQL_MUTEX_UNLOCK(&rli->run_lock); // tell the world we are done
my_thread_end();
pthread_exit(0);
@@ -2809,7 +2809,7 @@ err:
static int process_io_rotate(Master_info *mi, Rotate_log_event *rev)
{
DBUG_ENTER("process_io_rotate");
- safe_mutex_assert_owner(&mi->data_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&mi->data_lock);
if (unlikely(!rev->is_valid()))
DBUG_RETURN(1);
@@ -2905,7 +2905,7 @@ static int queue_binlog_ver_1_event(Mast
DBUG_RETURN(1);
}
- pthread_mutex_lock(&mi->data_lock);
+ MYSQL_MUTEX_LOCK(&mi->data_lock);
ev->log_pos= mi->master_log_pos; /* 3.23 events don't contain log_pos */
switch (ev->get_type_code()) {
case STOP_EVENT:
@@ -2916,7 +2916,7 @@ static int queue_binlog_ver_1_event(Mast
if (unlikely(process_io_rotate(mi,(Rotate_log_event*)ev)))
{
delete ev;
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(1);
}
inc_pos= 0;
@@ -2937,7 +2937,7 @@ static int queue_binlog_ver_1_event(Mast
delete ev;
mi->master_log_pos += inc_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
my_free((char*)tmp_buf, MYF(0));
DBUG_RETURN(error);
}
@@ -2956,7 +2956,7 @@ static int queue_binlog_ver_1_event(Mast
if (unlikely(rli->relay_log.append(ev)))
{
delete ev;
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(1);
}
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
@@ -2964,7 +2964,7 @@ static int queue_binlog_ver_1_event(Mast
delete ev;
mi->master_log_pos+= inc_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(0);
}
@@ -2992,7 +2992,7 @@ static int queue_binlog_ver_3_event(Mast
my_free((char*) tmp_buf, MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(1);
}
- pthread_mutex_lock(&mi->data_lock);
+ MYSQL_MUTEX_LOCK(&mi->data_lock);
switch (ev->get_type_code()) {
case STOP_EVENT:
goto err;
@@ -3000,7 +3000,7 @@ static int queue_binlog_ver_3_event(Mast
if (unlikely(process_io_rotate(mi,(Rotate_log_event*)ev)))
{
delete ev;
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(1);
}
inc_pos= 0;
@@ -3012,7 +3012,7 @@ static int queue_binlog_ver_3_event(Mast
if (unlikely(rli->relay_log.append(ev)))
{
delete ev;
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(1);
}
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
@@ -3020,7 +3020,7 @@ static int queue_binlog_ver_3_event(Mast
mi->master_log_pos+= inc_pos;
err:
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_RETURN(0);
}
@@ -3070,7 +3070,7 @@ static int queue_event(Master_info* mi,c
String error_msg;
ulong inc_pos;
Relay_log_info *rli= &mi->rli;
- pthread_mutex_t *log_lock= rli->relay_log.get_log_lock();
+ mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();
DBUG_ENTER("queue_event");
LINT_INIT(inc_pos);
@@ -3080,7 +3080,7 @@ static int queue_event(Master_info* mi,c
DBUG_RETURN(queue_old_event(mi,buf,event_len));
LINT_INIT(inc_pos);
- pthread_mutex_lock(&mi->data_lock);
+ MYSQL_MUTEX_LOCK(&mi->data_lock);
switch (buf[EVENT_TYPE_OFFSET]) {
case STOP_EVENT:
@@ -3216,7 +3216,7 @@ static int queue_event(Master_info* mi,c
direct master (an unsupported, useless setup!).
*/
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
if ((uint4korr(buf + SERVER_ID_OFFSET) == ::server_id) &&
!mi->rli.replicate_same_server_id)
@@ -3263,12 +3263,12 @@ static int queue_event(Master_info* mi,c
}
rli->ign_master_log_name_end[0]= 0; // last event is not ignored
}
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
skip_relay_logging:
err:
- pthread_mutex_unlock(&mi->data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->data_lock);
DBUG_PRINT("info", ("error: %d", error));
if (error)
mi->report(ERROR_LEVEL, error, ER(error),
@@ -3542,7 +3542,7 @@ static Log_event* next_event(Relay_log_i
{
Log_event* ev;
IO_CACHE* cur_log = rli->cur_log;
- pthread_mutex_t *log_lock = rli->relay_log.get_log_lock();
+ mysql_mutex_t *log_lock = rli->relay_log.get_log_lock();
const char* errmsg=0;
THD* thd = rli->sql_thd;
DBUG_ENTER("next_event");
@@ -3559,9 +3559,9 @@ static Log_event* next_event(Relay_log_i
so we assume calling function acquired this mutex for us and we will
hold it for the most of the loop below However, we will release it
whenever it is worth the hassle, and in the cases when we go into a
- pthread_cond_wait() with the non-data_lock mutex
+ MYSQL_COND_WAIT() with the non-data_lock mutex
*/
- safe_mutex_assert_owner(&rli->data_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&rli->data_lock);
while (!sql_slave_killed(thd,rli))
{
@@ -3580,7 +3580,7 @@ static Log_event* next_event(Relay_log_i
if ((hot_log = (cur_log != &rli->cache_buf)))
{
DBUG_ASSERT(rli->cur_log_fd == -1); // foreign descriptor
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
/*
Reading xxx_file_id is safe because the log will only
@@ -3590,7 +3590,7 @@ static Log_event* next_event(Relay_log_i
{
// The master has switched to a new log file; Reopen the old log file
cur_log=reopen_relay_log(rli, &errmsg);
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
if (!cur_log) // No more log files
goto err;
hot_log=0; // Using old binary log
@@ -3637,7 +3637,7 @@ static Log_event* next_event(Relay_log_i
*/
rli->future_event_relay_log_pos= my_b_tell(cur_log);
if (hot_log)
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
DBUG_RETURN(ev);
}
DBUG_ASSERT(thd==rli->sql_thd);
@@ -3647,7 +3647,7 @@ static Log_event* next_event(Relay_log_i
{
errmsg = "slave SQL thread aborted because of I/O error";
if (hot_log)
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
goto err;
}
if (!cur_log->error) /* EOF */
@@ -3694,7 +3694,7 @@ static Log_event* next_event(Relay_log_i
0, rli->ign_master_log_pos_end,
Rotate_log_event::DUP_NAME);
rli->ign_master_log_name_end[0]= 0;
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
if (unlikely(!ev))
{
errmsg= "Slave SQL thread failed to create a Rotate event "
@@ -3709,7 +3709,7 @@ static Log_event* next_event(Relay_log_i
We can, and should release data_lock while we are waiting for
update. If we do not, show slave status will block
*/
- pthread_mutex_unlock(&rli->data_lock);
+ MYSQL_MUTEX_UNLOCK(&rli->data_lock);
/*
Possible deadlock :
@@ -3735,7 +3735,7 @@ static Log_event* next_event(Relay_log_i
be stopped, and the SQL thread sets ignore_log_space_limit to 0 when
it stops.
*/
- pthread_mutex_lock(&rli->log_space_lock);
+ MYSQL_MUTEX_LOCK(&rli->log_space_lock);
// prevent the I/O thread from blocking next times
rli->ignore_log_space_limit= 1;
/*
@@ -3744,12 +3744,12 @@ static Log_event* next_event(Relay_log_i
~Relay_log_info(), i.e. when rli is destroyed, and rli will
not be destroyed before we exit the present function.
*/
- pthread_mutex_unlock(&rli->log_space_lock);
- pthread_cond_broadcast(&rli->log_space_cond);
+ MYSQL_MUTEX_UNLOCK(&rli->log_space_lock);
+ MYSQL_COND_BROADCAST(&rli->log_space_cond);
// Note that wait_for_update_relay_log unlocks lock_log !
rli->relay_log.wait_for_update_relay_log(rli->sql_thd);
// re-acquire data lock since we released it earlier
- pthread_mutex_lock(&rli->data_lock);
+ MYSQL_MUTEX_LOCK(&rli->data_lock);
rli->last_master_timestamp= save_timestamp;
continue;
}
@@ -3817,7 +3817,7 @@ static Log_event* next_event(Relay_log_i
DBUG_PRINT("info",("hot_log: %d",hot_log));
if (!hot_log) /* if hot_log, we already have this mutex */
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
if (rli->relay_log.is_active(rli->linfo.log_file_name))
{
#ifdef EXTRA_DEBUG
@@ -3838,13 +3838,13 @@ static Log_event* next_event(Relay_log_i
*/
if (check_binlog_magic(cur_log,&errmsg))
{
- if (!hot_log) pthread_mutex_unlock(log_lock);
+ if (!hot_log) MYSQL_MUTEX_UNLOCK(log_lock);
goto err;
}
- if (!hot_log) pthread_mutex_unlock(log_lock);
+ if (!hot_log) MYSQL_MUTEX_UNLOCK(log_lock);
continue;
}
- if (!hot_log) pthread_mutex_unlock(log_lock);
+ if (!hot_log) MYSQL_MUTEX_UNLOCK(log_lock);
/*
if we get here, the log was not hot, so we will have to open it
ourselves. We are sure that the log is still not hot now (a log can get
@@ -3867,7 +3867,7 @@ static Log_event* next_event(Relay_log_i
TODO: come up with something better to handle this error
*/
if (hot_log)
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
sql_print_error("Slave SQL thread: I/O error reading \
event(errno: %d cur_log->error: %d)",
my_errno,cur_log->error);
@@ -3905,7 +3905,7 @@ void rotate_relay_log(Master_info* mi)
Relay_log_info* rli= &mi->rli;
/* We don't lock rli->run_lock. This would lead to deadlocks. */
- pthread_mutex_lock(&mi->run_lock);
+ MYSQL_MUTEX_LOCK(&mi->run_lock);
/*
We need to test inited because otherwise, new_file() will attempt to lock
@@ -3935,7 +3935,7 @@ void rotate_relay_log(Master_info* mi)
*/
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
end:
- pthread_mutex_unlock(&mi->run_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->run_lock);
DBUG_VOID_RETURN;
}
=== modified file 'sql/slave.h'
--- a/sql/slave.h 2008-07-21 03:55:09 +0000
+++ b/sql/slave.h 2008-10-10 20:34:55 +0000
@@ -155,11 +155,11 @@ int start_slave_threads(bool need_slave_
cond_lock is usually same as start_lock. It is needed for the case when
start_lock is 0 which happens if start_slave_thread() is called already
inside the start_lock section, but at the same time we want a
- pthread_cond_wait() on start_cond,start_lock
+ MYSQL_COND_WAIT() on start_cond,start_lock
*/
-int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
- pthread_mutex_t *cond_lock,
- pthread_cond_t* start_cond,
+int start_slave_thread(pthread_handler h_func, mysql_mutex_t* start_lock,
+ mysql_mutex_t *cond_lock,
+ mysql_cond_t* start_cond,
volatile uint *slave_running,
volatile ulong *slave_run_id,
Master_info* mi,
=== modified file 'sql/sp_cache.cc'
--- a/sql/sp_cache.cc 2008-07-03 19:41:22 +0000
+++ b/sql/sp_cache.cc 2008-10-10 20:34:55 +0000
@@ -20,7 +20,10 @@
#include "sp_cache.h"
#include "sp_head.h"
-static pthread_mutex_t Cversion_lock;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_Cversion_lock;
+#endif
+static mysql_mutex_t Cversion_lock;
static ulong volatile Cversion= 0;
@@ -79,7 +82,7 @@ private:
void sp_cache_init()
{
- pthread_mutex_init(&Cversion_lock, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&Cversion_lock, key_Cversion_lock, MY_MUTEX_INIT_FAST);
}
=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc 2008-09-04 18:30:34 +0000
+++ b/sql/sp_head.cc 2008-10-10 20:34:55 +0000
@@ -1734,9 +1734,9 @@ sp_head::execute_function(THD *thd, Item
as one select and not resetting THD::user_var_events before
each invocation.
*/
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
q= global_query_id;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
mysql_bin_log.start_union_events(thd, q + 1);
binlog_save_options= thd->options;
thd->options&= ~OPTION_BIN_LOG;
@@ -2698,9 +2698,9 @@ sp_lex_keeper::reset_lex_and_exec_core(T
*/
thd->lex= m_lex;
- 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 (thd->locked_tables_mode <= LTM_LOCK_TABLES)
{
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2008-08-12 16:46:23 +0000
+++ b/sql/sql_acl.cc 2008-10-10 20:34:55 +0000
@@ -227,9 +227,9 @@ static void restrict_update_of_old_passw
{
if (var_type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
global_system_variables.old_passwords= 1;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
thd->variables.old_passwords= 1;
@@ -389,23 +389,23 @@ static my_bool acl_load(THD *thd, TABLE_
DBUG_PRINT("info",("user table fields: %d, password length: %d",
table->s->fields, password_length));
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH)
{
if (opt_secure_auth)
{
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
sql_print_error("Fatal error: mysql.user table is in old format, "
"but server started with --secure-auth option.");
goto end;
}
sys_old_passwords.after_update= restrict_update_of_old_passwords_var;
if (global_system_variables.old_passwords)
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
else
{
global_system_variables.old_passwords= 1;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
sql_print_warning("mysql.user table is not updated to new password format; "
"Disabling new password usage until "
"mysql_fix_privilege_tables is run");
@@ -415,7 +415,7 @@ static my_bool acl_load(THD *thd, TABLE_
else
{
sys_old_passwords.after_update= 0;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
allow_all_hosts=0;
@@ -704,7 +704,7 @@ my_bool acl_reload(THD *thd)
}
if ((old_initialized=initialized))
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
old_acl_hosts=acl_hosts;
old_acl_users=acl_users;
@@ -731,7 +731,7 @@ my_bool acl_reload(THD *thd)
delete_dynamic(&old_acl_dbs);
}
if (old_initialized)
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
end:
close_thread_tables(thd);
DBUG_RETURN(return_val);
@@ -883,7 +883,7 @@ int acl_getroot(THD *thd, USER_RESOURCES
DBUG_RETURN(0);
}
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
/*
Find acl entry in user database. Note, that find_acl_user is not the same,
@@ -1055,7 +1055,7 @@ int acl_getroot(THD *thd, USER_RESOURCES
else
*sctx->priv_host= 0;
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_RETURN(res);
}
@@ -1102,7 +1102,7 @@ bool acl_getroot_no_password(Security_co
DBUG_RETURN(FALSE);
}
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
sctx->master_access= 0;
sctx->db_access= 0;
@@ -1156,7 +1156,7 @@ bool acl_getroot_no_password(Security_co
else
*sctx->priv_host= 0;
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_RETURN(res);
}
@@ -1177,7 +1177,7 @@ static void acl_update_user(const char *
USER_RESOURCES *mqh,
ulong privileges)
{
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
for (uint i=0 ; i < acl_users.elements ; i++)
{
@@ -1229,7 +1229,7 @@ static void acl_insert_user(const char *
{
ACL_USER acl_user;
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
acl_user.user=*user ? strdup_root(&mem,user) : 0;
update_hostname(&acl_user.host, *host ? strdup_root(&mem, host): 0);
@@ -1260,7 +1260,7 @@ static void acl_insert_user(const char *
static void acl_update_db(const char *user, const char *host, const char *db,
ulong privileges)
{
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
for (uint i=0 ; i < acl_dbs.elements ; i++)
{
@@ -1305,7 +1305,7 @@ static void acl_insert_db(const char *us
ulong privileges)
{
ACL_DB acl_db;
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
acl_db.user=strdup_root(&mem,user);
update_hostname(&acl_db.host, *host ? strdup_root(&mem,host) : 0);
acl_db.db=strdup_root(&mem,db);
@@ -1335,7 +1335,7 @@ ulong acl_get(const char *host, const ch
acl_entry *entry;
DBUG_ENTER("acl_get");
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
end=strmov((tmp_db=strmov(strmov(key, ip ? ip : "")+1,user)+1),db);
if (lower_case_table_names)
{
@@ -1347,7 +1347,7 @@ ulong acl_get(const char *host, const ch
key_length)))
{
db_access=entry->access;
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_PRINT("exit", ("access: 0x%lx", db_access));
DBUG_RETURN(db_access);
}
@@ -1401,7 +1401,7 @@ exit:
memcpy((uchar*) entry->key,key,key_length);
acl_cache->add(entry);
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_PRINT("exit", ("access: 0x%lx", db_access & host_access));
DBUG_RETURN(db_access & host_access);
}
@@ -1481,12 +1481,12 @@ bool acl_check_host(const char *host, co
{
if (allow_all_hosts)
return 0;
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
if (host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host)) ||
ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip)))
{
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
return 0; // Found host
}
for (uint i=0 ; i < acl_wild_hosts.elements ; i++)
@@ -1494,11 +1494,11 @@ bool acl_check_host(const char *host, co
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,i,acl_host_and_ip*);
if (compare_hostname(acl, host, ip))
{
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
return 0; // Host ok
}
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
return 1; // Host is not allowed
}
@@ -1613,11 +1613,11 @@ bool change_password(THD *thd, const cha
if (!(table= open_ltable(thd, &tables, TL_WRITE, 0)))
DBUG_RETURN(1);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
ACL_USER *acl_user;
if (!(acl_user= find_acl_user(host, user, TRUE)))
{
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0));
goto end;
}
@@ -1629,12 +1629,12 @@ bool change_password(THD *thd, const cha
acl_user->user ? acl_user->user : "",
new_password, new_password_len))
{
- pthread_mutex_unlock(&acl_cache->lock); /* purecov: deadcode */
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock); /* purecov: deadcode */
goto end;
}
acl_cache->clear(1); // Clear locked hostname cache
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
result= 0;
if (mysql_bin_log.is_open())
{
@@ -1674,9 +1674,9 @@ bool is_acl_user(const char *host, const
if (!initialized)
return TRUE;
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
res= find_acl_user(host, user, TRUE) != NULL;
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
return res;
}
@@ -1691,7 +1691,7 @@ find_acl_user(const char *host, const ch
DBUG_ENTER("find_acl_user");
DBUG_PRINT("enter",("host: '%s' user: '%s'",host,user));
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
for (uint i=0 ; i < acl_users.elements ; i++)
{
@@ -1894,7 +1894,7 @@ static int replace_user_table(THD *thd,
LEX *lex= thd->lex;
DBUG_ENTER("replace_user_table");
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
if (combo.password.str && combo.password.str[0])
{
@@ -3065,8 +3065,8 @@ int mysql_table_grant(THD *thd, TABLE_LI
if (!revoke_grant)
create_new_users= test_if_create_new_users(thd);
bool result= FALSE;
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
MEM_ROOT *old_root= thd->mem_root;
thd->mem_root= &memex;
grant_version++;
@@ -3175,14 +3175,14 @@ int mysql_table_grant(THD *thd, TABLE_LI
}
}
thd->mem_root= old_root;
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
if (!result) /* success */
{
write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
if (!result) /* success */
my_ok(thd);
@@ -3284,8 +3284,8 @@ bool mysql_routine_grant(THD *thd, TABLE
if (!revoke_grant)
create_new_users= test_if_create_new_users(thd);
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
MEM_ROOT *old_root= thd->mem_root;
thd->mem_root= &memex;
@@ -3346,13 +3346,13 @@ bool mysql_routine_grant(THD *thd, TABLE
}
}
thd->mem_root= old_root;
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
if (!result && !no_error)
{
write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
if (!result && !no_error)
my_ok(thd);
@@ -3428,8 +3428,8 @@ bool mysql_grant(THD *thd, const char *d
create_new_users= test_if_create_new_users(thd);
/* go through users in user_list */
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
grant_version++;
int result=0;
@@ -3461,14 +3461,14 @@ bool mysql_grant(THD *thd, const char *d
}
}
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
if (!result)
{
write_bin_log(thd, TRUE, thd->query, thd->query_length);
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
if (!result)
@@ -3738,7 +3738,7 @@ static my_bool grant_reload_procs_priv(T
old_proc_priv_hash= proc_priv_hash;
old_func_priv_hash= func_priv_hash;
- rw_wrlock(&LOCK_grant);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
if ((return_val= grant_load_procs_priv(table.table)))
{
/* Error; Reverting to old hash */
@@ -3752,7 +3752,7 @@ static my_bool grant_reload_procs_priv(T
hash_free(&old_proc_priv_hash);
hash_free(&old_func_priv_hash);
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
DBUG_RETURN(return_val);
@@ -3802,7 +3802,7 @@ my_bool grant_reload(THD *thd)
if (simple_open_n_lock_tables(thd, tables))
goto end;
- rw_wrlock(&LOCK_grant);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
old_column_priv_hash= column_priv_hash;
/*
@@ -3824,7 +3824,7 @@ my_bool grant_reload(THD *thd)
hash_free(&old_column_priv_hash);
free_root(&old_mem,MYF(0));
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
/*
@@ -3834,9 +3834,9 @@ my_bool grant_reload(THD *thd)
if (grant_reload_procs_priv(thd))
return_val= 1;
- rw_wrlock(&LOCK_grant);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
grant_version++;
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
end:
DBUG_RETURN(return_val);
@@ -3911,7 +3911,7 @@ bool check_grant(THD *thd, ulong want_ac
table->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
}
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
for (table= tables;
table && number-- && table != first_not_own_table;
table= table->next_global)
@@ -3972,11 +3972,11 @@ bool check_grant(THD *thd, ulong want_ac
goto err; // impossible
}
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_RETURN(FALSE);
err:
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
if (!no_errors) // Not a silent skip of table
{
char command[128];
@@ -4030,11 +4030,11 @@ bool has_any_table_level_privileges(THD
Get privileges from table_priv and column_priv tables by searching
the cache.
*/
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
grant_table= table_hash_search(sctx->host, sctx->ip,
table->db, sctx->priv_user,
table->table_name,0);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
/* Stop if there are no grants for the current user */
if (!grant_table)
@@ -4111,7 +4111,7 @@ bool check_grant_column(THD *thd, GRANT_
if (!want_access)
DBUG_RETURN(0); // Already checked
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
/* reload table if someone has modified any grants */
@@ -4129,12 +4129,12 @@ bool check_grant_column(THD *thd, GRANT_
grant_column=column_hash_search(grant_table, name, length);
if (grant_column && !(~grant_column->rights & want_access))
{
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_RETURN(0);
}
err:
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
char command[128];
get_privilege_desc(command, sizeof(command), want_access);
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
@@ -4245,7 +4245,7 @@ bool check_grant_all_columns(THD *thd, u
/* Initialized only to make gcc happy */
GRANT_TABLE *grant_table= NULL;
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
for (; !fields->end_of_fields(); fields->next())
{
@@ -4284,11 +4284,11 @@ bool check_grant_all_columns(THD *thd, u
goto err;
}
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
return 0;
err:
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
char command[128];
get_privilege_desc(command, sizeof(command), want_access);
@@ -4337,7 +4337,7 @@ bool check_grant_db(THD *thd,const char
len= (uint) (strmov(strmov(helping, sctx->priv_user) + 1, db) - helping) + 1;
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
for (uint idx=0 ; idx < column_priv_hash.records ; idx++)
{
@@ -4356,7 +4356,7 @@ bool check_grant_db(THD *thd,const char
error= check_grant_db_routine(thd, db, &proc_priv_hash) &&
check_grant_db_routine(thd, db, &func_priv_hash);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
return error;
}
@@ -4392,7 +4392,7 @@ bool check_grant_routine(THD *thd, ulong
if (!want_access)
DBUG_RETURN(0); // ok
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
for (table= procs; table; table= table->next_global)
{
GRANT_NAME *grant_proc;
@@ -4406,10 +4406,10 @@ bool check_grant_routine(THD *thd, ulong
goto err;
}
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_RETURN(0);
err:
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
if (!no_errors)
{
char buff[1024];
@@ -4450,13 +4450,13 @@ bool check_routine_level_acl(THD *thd, c
bool no_routine_acl= 1;
GRANT_NAME *grant_proc;
Security_context *sctx= thd->security_ctx;
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
if ((grant_proc= routine_hash_search(sctx->priv_host,
sctx->ip, db,
sctx->priv_user,
name, is_proc, 0)))
no_routine_acl= !(grant_proc->privs & SHOW_PROC_ACLS);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
return no_routine_acl;
}
@@ -4472,7 +4472,7 @@ ulong get_table_grant(THD *thd, TABLE_LI
const char *db = table->db ? table->db : thd->db;
GRANT_TABLE *grant_table;
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
#ifdef EMBEDDED_LIBRARY
grant_table= NULL;
#else
@@ -4484,7 +4484,7 @@ ulong get_table_grant(THD *thd, TABLE_LI
if (grant_table)
table->grant.privilege|= grant_table->privs;
privilege= table->grant.privilege;
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
return privilege;
}
@@ -4515,7 +4515,7 @@ ulong get_column_grant(THD *thd, GRANT_I
GRANT_COLUMN *grant_column;
ulong priv;
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
/* reload table if someone has modified any grants */
if (grant->version != grant_version)
{
@@ -4538,7 +4538,7 @@ ulong get_column_grant(THD *thd, GRANT_I
else
priv= (grant->privilege | grant_table->privs | grant_column->rights);
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
return priv;
}
@@ -4605,14 +4605,14 @@ bool mysql_show_grants(THD *thd,LEX_USER
DBUG_RETURN(TRUE);
}
- rw_rdlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
acl_user= find_acl_user(lex_user->host.str, lex_user->user.str, TRUE);
if (!acl_user)
{
- pthread_mutex_unlock(&acl_cache->lock);
- rw_unlock(&LOCK_grant);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
my_error(ER_NONEXISTING_GRANT, MYF(0),
lex_user->user.str, lex_user->host.str);
@@ -4629,8 +4629,8 @@ bool mysql_show_grants(THD *thd,LEX_USER
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
{
- pthread_mutex_unlock(&acl_cache->lock);
- rw_unlock(&LOCK_grant);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_RETURN(TRUE);
}
@@ -4940,8 +4940,8 @@ bool mysql_show_grants(THD *thd,LEX_USER
}
end:
- pthread_mutex_unlock(&acl_cache->lock);
- rw_unlock(&LOCK_grant);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
my_eof(thd);
DBUG_RETURN(error);
@@ -5065,14 +5065,14 @@ void get_mqh(const char *user, const cha
{
ACL_USER *acl_user;
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
if (initialized && (acl_user= find_acl_user(host,user, FALSE)))
uc->user_resources= acl_user->user_resource;
else
bzero((char*) &uc->user_resources, sizeof(uc->user_resources));
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
}
/*
@@ -5159,7 +5159,7 @@ ACL_USER *check_acl_user(LEX_USER *user_
ACL_USER *acl_user= 0;
uint counter;
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
for (counter= 0 ; counter < acl_users.elements ; counter++)
{
@@ -5431,7 +5431,7 @@ static int handle_grant_struct(uint stru
LINT_INIT(user);
LINT_INIT(host);
- safe_mutex_assert_owner(&acl_cache->lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&acl_cache->lock);
/* Get the number of elements in the in-memory structure. */
switch (struct_no) {
@@ -5728,8 +5728,8 @@ bool mysql_create_user(THD *thd, List <L
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
while ((tmp_user_name= user_list++))
{
@@ -5758,7 +5758,7 @@ bool mysql_create_user(THD *thd, List <L
}
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
@@ -5766,7 +5766,7 @@ bool mysql_create_user(THD *thd, List <L
if (some_users_created)
write_bin_log(thd, FALSE, thd->query, thd->query_length);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
DBUG_RETURN(result);
}
@@ -5806,8 +5806,8 @@ bool mysql_drop_user(THD *thd, List <LEX
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
while ((tmp_user_name= user_list++))
{
@@ -5828,7 +5828,7 @@ bool mysql_drop_user(THD *thd, List <LEX
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host();
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "DROP USER", wrong_users.c_ptr_safe());
@@ -5836,7 +5836,7 @@ bool mysql_drop_user(THD *thd, List <LEX
if (some_users_deleted)
write_bin_log(thd, FALSE, thd->query, thd->query_length);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
DBUG_RETURN(result);
}
@@ -5877,8 +5877,8 @@ bool mysql_rename_user(THD *thd, List <L
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
while ((tmp_user_from= user_list++))
{
@@ -5912,7 +5912,7 @@ bool mysql_rename_user(THD *thd, List <L
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host();
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
@@ -5920,7 +5920,7 @@ bool mysql_rename_user(THD *thd, List <L
if (some_users_renamed && mysql_bin_log.is_open())
write_bin_log(thd, FALSE, thd->query, thd->query_length);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
DBUG_RETURN(result);
}
@@ -5958,8 +5958,8 @@ bool mysql_revoke_all(THD *thd, List <L
if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1);
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
LEX_USER *lex_user, *tmp_lex_user;
List_iterator <LEX_USER> user_list(list);
@@ -6098,11 +6098,11 @@ bool mysql_revoke_all(THD *thd, List <L
} while (revoked);
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
write_bin_log(thd, FALSE, thd->query, thd->query_length);
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
if (result)
@@ -6198,8 +6198,8 @@ bool sp_revoke_privileges(THD *thd, cons
/* Be sure to pop this before exiting this scope! */
thd->push_internal_handler(&error_handler);
- rw_wrlock(&LOCK_grant);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_grant);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
/*
This statement will be replicated as a statement, even when using
@@ -6237,8 +6237,8 @@ bool sp_revoke_privileges(THD *thd, cons
}
} while (revoked);
- pthread_mutex_unlock(&acl_cache->lock);
- rw_unlock(&LOCK_grant);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
close_thread_tables(thd);
thd->pop_internal_handler();
@@ -6278,7 +6278,7 @@ int sp_grant_privileges(THD *thd, const
combo->user.str= sctx->user;
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
if ((au= find_acl_user(combo->host.str=(char*)sctx->host_or_ip,combo->user.str,FALSE)))
goto found_acl;
@@ -6289,11 +6289,11 @@ int sp_grant_privileges(THD *thd, const
if((au= find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE)))
goto found_acl;
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_RETURN(TRUE);
found_acl:
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
bzero((char*)tables, sizeof(TABLE_LIST));
user_list.empty();
@@ -6437,7 +6437,7 @@ int fill_schema_user_privileges(THD *thd
if (!initialized)
DBUG_RETURN(0);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
for (counter=0 ; counter < acl_users.elements ; counter++)
{
@@ -6475,7 +6475,7 @@ int fill_schema_user_privileges(THD *thd
}
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_RETURN(0);
#else
@@ -6498,7 +6498,7 @@ int fill_schema_schema_privileges(THD *t
if (!initialized)
DBUG_RETURN(0);
- pthread_mutex_lock(&acl_cache->lock);
+ MYSQL_MUTEX_LOCK(&acl_cache->lock);
for (counter=0 ; counter < acl_dbs.elements ; counter++)
{
@@ -6539,7 +6539,7 @@ int fill_schema_schema_privileges(THD *t
}
}
- pthread_mutex_unlock(&acl_cache->lock);
+ MYSQL_MUTEX_UNLOCK(&acl_cache->lock);
DBUG_RETURN(0);
#else
@@ -6558,7 +6558,7 @@ int fill_schema_table_privileges(THD *th
char *curr_host= thd->security_ctx->priv_host_name();
DBUG_ENTER("fill_schema_table_privileges");
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
for (index=0 ; index < column_priv_hash.records ; index++)
{
@@ -6607,7 +6607,7 @@ int fill_schema_table_privileges(THD *th
}
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_RETURN(0);
#else
@@ -6626,7 +6626,7 @@ int fill_schema_column_privileges(THD *t
char *curr_host= thd->security_ctx->priv_host_name();
DBUG_ENTER("fill_schema_table_privileges");
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
for (index=0 ; index < column_priv_hash.records ; index++)
{
@@ -6681,7 +6681,7 @@ int fill_schema_column_privileges(THD *t
}
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_RETURN(0);
#else
@@ -6733,7 +6733,7 @@ void fill_effective_table_privileges(THD
grant->privilege|= acl_get(sctx->host, sctx->ip, sctx->priv_user, db, 0);
/* table privileges */
- rw_rdlock(&LOCK_grant);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_grant);
if (grant->version != grant_version)
{
grant->grant_table=
@@ -6746,7 +6746,7 @@ void fill_effective_table_privileges(THD
{
grant->privilege|= grant->grant_table->privs;
}
- rw_unlock(&LOCK_grant);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_grant);
DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege));
DBUG_VOID_RETURN;
=== modified file 'sql/sql_audit.cc'
--- a/sql/sql_audit.cc 2008-03-26 14:30:28 +0000
+++ b/sql/sql_audit.cc 2008-10-10 20:34:55 +0000
@@ -23,7 +23,10 @@ extern int finalize_audit_plugin(st_plug
unsigned long mysql_global_audit_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
-static pthread_mutex_t LOCK_audit_mask;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_audit_mask;
+#endif
+static mysql_mutex_t LOCK_audit_mask;
static void event_class_dispatch(THD *thd, const struct mysql_event *event);
@@ -247,7 +250,7 @@ void mysql_audit_free_thd(THD *thd)
void mysql_audit_initialize()
{
- pthread_mutex_init(&LOCK_audit_mask, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_audit_mask, key_LOCK_audit_mask, MY_MUTEX_INIT_FAST);
bzero(mysql_global_audit_mask, sizeof(mysql_global_audit_mask));
}
@@ -258,7 +261,7 @@ void mysql_audit_initialize()
void mysql_audit_finalize()
{
- pthread_mutex_destroy(&LOCK_audit_mask);
+ MYSQL_MUTEX_DESTROY(&LOCK_audit_mask);
}
@@ -294,9 +297,9 @@ int initialize_audit_plugin(st_plugin_in
plugin->data= plugin->plugin->info;
/* Add the bits the plugin is interested in to the global mask */
- pthread_mutex_lock(&LOCK_audit_mask);
+ MYSQL_MUTEX_LOCK(&LOCK_audit_mask);
add_audit_mask(mysql_global_audit_mask, data->class_mask);
- pthread_mutex_unlock(&LOCK_audit_mask);
+ MYSQL_MUTEX_UNLOCK(&LOCK_audit_mask);
return 0;
}
@@ -343,13 +346,13 @@ int finalize_audit_plugin(st_plugin_int
bzero(&event_class_mask, sizeof(event_class_mask));
/* Iterate through all the installed plugins to create new mask */
- pthread_mutex_lock(&LOCK_audit_mask);
+ MYSQL_MUTEX_LOCK(&LOCK_audit_mask);
plugin_foreach(current_thd, calc_class_mask, MYSQL_AUDIT_PLUGIN,
&event_class_mask);
/* Set the global audit mask */
bmove(mysql_global_audit_mask, event_class_mask, sizeof(event_class_mask));
- pthread_mutex_unlock(&LOCK_audit_mask);
+ MYSQL_MUTEX_UNLOCK(&LOCK_audit_mask);
return 0;
}
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2008-09-04 18:30:34 +0000
+++ b/sql/sql_base.cc 2008-10-10 20:34:55 +0000
@@ -242,7 +242,7 @@ extern "C" uchar *table_def_key(const uc
static void table_def_free_entry(TABLE_SHARE *share)
{
DBUG_ENTER("table_def_free_entry");
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
if (share->prev)
{
/* remove from old_unused_share list */
@@ -619,7 +619,7 @@ void release_table_share(TABLE_SHARE *sh
share, share->db.str, share->table_name.str,
share->ref_count, share->version));
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
if (!--share->ref_count)
{
@@ -667,7 +667,7 @@ TABLE_SHARE *get_cached_table_share(cons
char key[NAME_LEN*2+2];
TABLE_LIST table_list;
uint key_length;
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
table_list.db= (char*) db;
table_list.table_name= (char*) table_name;
@@ -687,7 +687,7 @@ static void reference_table_share(TABLE_
{
DBUG_ENTER("reference_table_share");
DBUG_ASSERT(share->ref_count);
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
share->ref_count++;
DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
(ulong) share, share->ref_count));
@@ -720,7 +720,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *t
TABLE_LIST table_list;
DBUG_ENTER("list_open_tables");
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
bzero((char*) &table_list,sizeof(table_list));
start_list= &open_list;
open_list=0;
@@ -760,7 +760,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *t
start_list= &(*start_list)->next;
*start_list=0;
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(open_list);
}
@@ -837,7 +837,7 @@ static void kill_delayed_threads_for_tab
I_P_List_iterator<TABLE, TABLE_share> it(share->used_tables);
TABLE *tab;
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
while ((tab= it++))
{
@@ -847,14 +847,14 @@ static void kill_delayed_threads_for_tab
! in_use->killed)
{
in_use->killed= THD::KILL_CONNECTION;
- pthread_mutex_lock(&in_use->mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
{
- pthread_mutex_lock(in_use->mysys_var->current_mutex);
- pthread_cond_broadcast(in_use->mysys_var->current_cond);
- pthread_mutex_unlock(in_use->mysys_var->current_mutex);
+ MYSQL_MUTEX_LOCK(in_use->mysys_var->current_mutex);
+ MYSQL_COND_BROADCAST(in_use->mysys_var->current_cond);
+ MYSQL_MUTEX_UNLOCK(in_use->mysys_var->current_mutex);
}
- pthread_mutex_unlock(&in_use->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&in_use->mysys_var->mutex);
}
}
}
@@ -888,7 +888,7 @@ bool close_cached_tables(THD *thd, TABLE
DBUG_ASSERT(thd || (!wait_for_refresh && !tables));
if (!have_lock)
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (!tables)
{
refresh_version++; // Force close of open tables
@@ -926,7 +926,7 @@ bool close_cached_tables(THD *thd, TABLE
}
if (!have_lock)
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (!wait_for_refresh)
DBUG_RETURN(result);
@@ -977,7 +977,7 @@ bool close_cached_tables(THD *thd, TABLE
mysql_ha_flush(thd);
DEBUG_SYNC(thd, "after_flush_unlock");
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
thd->enter_cond(&COND_refresh, &LOCK_open, "Flushing tables");
@@ -1009,7 +1009,7 @@ bool close_cached_tables(THD *thd, TABLE
if (found)
{
DBUG_PRINT("signal", ("Waiting for COND_refresh"));
- pthread_cond_wait(&COND_refresh,&LOCK_open);
+ MYSQL_COND_WAIT(&COND_refresh,&LOCK_open);
}
thd->exit_cond(NULL);
@@ -1053,7 +1053,7 @@ bool close_cached_connection_tables(THD
bzero(&tmp, sizeof(TABLE_LIST));
if (!have_lock)
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (idx= 0; idx < table_def_cache.records; idx++)
{
@@ -1086,15 +1086,15 @@ bool close_cached_connection_tables(THD
result= close_cached_tables(thd, tables, TRUE, FALSE);
if (!have_lock)
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (if_wait_for_refresh)
{
- pthread_mutex_lock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
thd->proc_info=0;
- pthread_mutex_unlock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&thd->mysys_var->mutex);
}
DBUG_RETURN(result);
@@ -1178,9 +1178,9 @@ static void close_open_tables(THD *thd)
{
bool found_old_table= 0;
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
DBUG_PRINT("info", ("thd->open_tables: %p", thd->open_tables));
@@ -1197,7 +1197,7 @@ static void close_open_tables(THD *thd)
broadcast_refresh();
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
@@ -1228,13 +1228,13 @@ close_all_tables_for_name(THD *thd, TABL
memcpy(key, share->table_cache_key.str, key_length);
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
/*
We need to hold LOCK_open while changing the open_tables
list, since another thread may work on it.
@sa mysql_notify_thread_having_shared_lock()
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (TABLE **prev= &thd->open_tables; *prev; )
{
@@ -1270,7 +1270,7 @@ close_all_tables_for_name(THD *thd, TABL
}
/* We have been removing tables from the table cache. */
broadcast_refresh();
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
@@ -1453,7 +1453,7 @@ bool close_thread_table(THD *thd, TABLE
DBUG_ENTER("close_thread_table");
DBUG_ASSERT(table->key_read == 0);
DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
*table_ptr=table->next;
@@ -2047,10 +2047,10 @@ bool wait_while_table_is_used(THD *thd,
DBUG_RETURN(TRUE);
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN,
table->s->db.str, table->s->table_name.str);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/* extra() call must come only after all instances above are closed */
(void) table->file->extra(function);
DBUG_RETURN(FALSE);
@@ -2090,11 +2090,11 @@ void drop_open_table(THD *thd, TABLE *ta
/* Ensure the table is removed from the cache. */
table->s->version= 0;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
table->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
close_thread_table(thd, &thd->open_tables);
quick_rm_table(table_type, db_name, table_name, 0);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
DBUG_VOID_RETURN;
}
@@ -2111,7 +2111,7 @@ void drop_open_table(THD *thd, TABLE *ta
cond Condition to wait for
*/
-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)
{
/* Wait until the current table is up to date */
const char *proc_info;
@@ -2121,7 +2121,7 @@ void wait_for_condition(THD *thd, pthrea
thd_proc_info(thd, "Waiting for table");
DBUG_ENTER("wait_for_condition");
if (!thd->killed)
- (void) pthread_cond_wait(cond, mutex);
+ (void) MYSQL_COND_WAIT(cond, mutex);
/*
We must unlock mutex first to avoid deadlock becasue conditions are
@@ -2134,12 +2134,12 @@ void wait_for_condition(THD *thd, pthrea
mutex is unlocked
*/
- pthread_mutex_unlock(mutex);
- pthread_mutex_lock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(mutex);
+ MYSQL_MUTEX_LOCK(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
thd_proc_info(thd, proc_info);
- pthread_mutex_unlock(&thd->mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&thd->mysys_var->mutex);
DBUG_VOID_RETURN;
}
@@ -2171,7 +2171,7 @@ bool check_if_table_exists(THD *thd, TAB
int rc;
DBUG_ENTER("check_if_table_exists");
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
*exists= TRUE;
@@ -2215,10 +2215,10 @@ bool check_if_table_exists(THD *thd, TAB
void table_share_release_hook(void *share)
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
release_table_share((TABLE_SHARE*) share);
broadcast_refresh();
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
@@ -2536,7 +2536,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
}
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
/*
If it's the first table from a list of tables used in a query,
@@ -2553,7 +2553,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
{
/* Someone did a refresh while thread was opening tables */
*action= OT_BACK_OFF_AND_RETRY;
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(TRUE);
}
@@ -2566,14 +2566,14 @@ bool open_table(THD *thd, TABLE_LIST *ta
if (!exists)
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(FALSE);
}
/* Table exists. Let us try to open it. */
}
else if (table_list->open_type == TABLE_LIST::TAKE_EXCLUSIVE_MDL)
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(FALSE);
}
@@ -2620,7 +2620,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
DBUG_ASSERT(table_list->view);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(FALSE);
}
/*
@@ -2677,7 +2677,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
*/
*action= OT_BACK_OFF_AND_RETRY;
release_table_share(share);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(TRUE);
}
/* Force close at once after usage */
@@ -2739,7 +2739,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
table_def_add_used_table(thd, table);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/*
In CREATE TABLE .. If NOT EXISTS .. SELECT we have found that
@@ -2796,7 +2796,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
err_unlock:
release_table_share(share);
err_unlock2:
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (! (flags & MYSQL_OPEN_HAS_MDL_LOCK))
{
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
@@ -3114,9 +3114,9 @@ Locked_tables_list::reopen_tables(THD *t
No one's seen this branch work. Recover and report an
error just in case.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
close_thread_table(thd, &thd->open_tables);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
table_list->table= 0;
unlink_all_closed_tables();
my_error(ER_LOCK_DEADLOCK, MYF(0));
@@ -3166,7 +3166,7 @@ void assign_new_table_id(TABLE_SHARE *sh
/* Preconditions */
DBUG_ASSERT(share != NULL);
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
ulong tid= ++last_table_id; /* get next id */
/*
@@ -3276,7 +3276,7 @@ bool tdc_open_view(THD *thd, TABLE_LIST
int error;
TABLE_SHARE *share;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
cache_key_length,
@@ -3292,14 +3292,14 @@ bool tdc_open_view(THD *thd, TABLE_LIST
mem_root))
{
release_table_share(share);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
return FALSE;
}
my_error(ER_WRONG_OBJECT, MYF(0), share->db.str, share->table_name.str, "VIEW");
release_table_share(share);
err:
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
return TRUE;
}
@@ -3372,13 +3372,13 @@ static bool auto_repair_table(THD *thd,
thd->clear_error();
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
cache_key_length,
OPEN_VIEW, ¬_used)))
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
return TRUE;
}
@@ -3391,7 +3391,7 @@ static bool auto_repair_table(THD *thd,
goto end_with_lock_open;
}
share->version= 0;
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (open_table_from_share(thd, share, table_list->alias,
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
@@ -3418,11 +3418,11 @@ static bool auto_repair_table(THD *thd,
}
my_free(entry, MYF(0));
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
end_with_lock_open:
release_table_share(share);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
return result;
}
@@ -3461,10 +3461,10 @@ recover_from_failed_open_table_attempt(T
mdl_remove_lock(&thd->mdl_context, table->mdl_lock_data);
return TRUE;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name);
ha_create_table_from_engine(thd, table->db, table->table_name);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
mysql_reset_errors(thd, 1); // Clear warnings
thd->clear_error(); // Clear error message
@@ -3479,9 +3479,9 @@ recover_from_failed_open_table_attempt(T
mdl_remove_lock(&thd->mdl_context, table->mdl_lock_data);
return TRUE;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
result= auto_repair_table(thd, table);
mdl_release_lock(&thd->mdl_context, table->mdl_lock_data);
@@ -7376,10 +7376,10 @@ my_bool mysql_rm_tmp_tables(void)
void flush_tables()
{
- (void) pthread_mutex_lock(&LOCK_open);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_open);
while (unused_tables)
free_cache_entry(unused_tables);
- (void) pthread_mutex_unlock(&LOCK_open);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
@@ -7415,13 +7415,13 @@ bool mysql_notify_thread_having_shared_l
!in_use->killed)
{
in_use->killed= THD::KILL_CONNECTION;
- pthread_mutex_lock(&in_use->mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
- pthread_cond_broadcast(in_use->mysys_var->current_cond);
- pthread_mutex_unlock(&in_use->mysys_var->mutex);
+ MYSQL_COND_BROADCAST(in_use->mysys_var->current_cond);
+ MYSQL_MUTEX_UNLOCK(&in_use->mysys_var->mutex);
signalled= TRUE;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (TABLE *thd_table= in_use->open_tables;
thd_table ;
thd_table= thd_table->next)
@@ -7436,7 +7436,7 @@ bool mysql_notify_thread_having_shared_l
if (thd_table->db_stat)
signalled|= mysql_lock_abort_for_thread(thd, thd_table);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
return signalled;
}
@@ -7479,7 +7479,7 @@ void tdc_remove_table(THD *thd, enum_tdc
TABLE *table;
TABLE_SHARE *share;
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
DBUG_ASSERT(remove_type == TDC_RT_REMOVE_UNUSED ||
mdl_is_exclusive_lock_owner(&thd->mdl_context, 0,
@@ -7546,7 +7546,7 @@ static bool tdc_wait_for_old_versions(TH
to broadcast on COND_refresh because of this.
*/
mysql_ha_flush(thd);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
I_P_List_iterator<MDL_LOCK_DATA,
MDL_LOCK_DATA_context> it= mdl_get_locks(context);
@@ -7561,11 +7561,11 @@ static bool tdc_wait_for_old_versions(TH
}
if (!lock_data)
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
break;
}
old_msg= thd->enter_cond(&COND_refresh, &LOCK_open, "Waiting for table");
- pthread_cond_wait(&COND_refresh, &LOCK_open);
+ MYSQL_COND_WAIT(&COND_refresh, &LOCK_open);
/* LOCK_open mutex is unlocked by THD::exit_cond() as side-effect. */
thd->exit_cond(old_msg);
}
@@ -7963,7 +7963,7 @@ void close_performance_schema_table(THD
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
found_old_table= false;
/*
@@ -7977,7 +7977,7 @@ void close_performance_schema_table(THD
if (found_old_table)
broadcast_refresh();
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
mdl_release_locks(&thd->mdl_context);
mdl_remove_all_locks(&thd->mdl_context);
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc 2008-08-07 03:05:33 +0000
+++ b/sql/sql_cache.cc 2008-10-10 20:34:55 +0000
@@ -340,23 +340,23 @@ TODO list:
#if !defined(EXTRA_DBUG) && !defined(DBUG_OFF)
#define MUTEX_LOCK(M) { DBUG_PRINT("lock", ("mutex lock %p", (M))); \
- pthread_mutex_lock(M);}
+ MYSQL_MUTEX_LOCK(M);}
#define MUTEX_UNLOCK(M) {DBUG_PRINT("lock", ("mutex unlock %p",\
- (M))); pthread_mutex_unlock(M);}
+ (M))); MYSQL_MUTEX_UNLOCK(M);}
#define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock %p",(M))); \
- if (!rw_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \
+ if (!MYSQL_RWLOCK_WRLOCK(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
#define RW_RLOCK(M) {DBUG_PRINT("lock", ("rwlock rlock %p", (M))); \
- if (!rw_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \
+ if (!MYSQL_RWLOCK_RDLOCK(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
#define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock %p",(M))); \
- if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \
+ if (!MYSQL_RWLOCK_UNLOCK(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \
else DBUG_PRINT("lock", ("rwlock unlock FAILED %d", errno)); }
#define STRUCT_LOCK(M) {DBUG_PRINT("lock", ("%d struct lock...",__LINE__)); \
- pthread_mutex_lock(M);DBUG_PRINT("lock", ("struct lock OK"));}
+ MYSQL_MUTEX_LOCK(M);DBUG_PRINT("lock", ("struct lock OK"));}
#define STRUCT_UNLOCK(M) { \
DBUG_PRINT("lock", ("%d struct unlock...",__LINE__)); \
- pthread_mutex_unlock(M);DBUG_PRINT("lock", ("struct unlock OK"));}
+ MYSQL_MUTEX_UNLOCK(M);DBUG_PRINT("lock", ("struct unlock OK"));}
#define BLOCK_LOCK_WR(B) {DBUG_PRINT("lock", ("%d LOCK_WR %p",\
__LINE__,(B))); \
B->query()->lock_writing();}
@@ -398,13 +398,13 @@ static void debug_wait_for_kill(const ch
}
#else
-#define MUTEX_LOCK(M) pthread_mutex_lock(M)
-#define MUTEX_UNLOCK(M) pthread_mutex_unlock(M)
-#define RW_WLOCK(M) rw_wrlock(M)
-#define RW_RLOCK(M) rw_rdlock(M)
-#define RW_UNLOCK(M) rw_unlock(M)
-#define STRUCT_LOCK(M) pthread_mutex_lock(M)
-#define STRUCT_UNLOCK(M) pthread_mutex_unlock(M)
+#define MUTEX_LOCK(M) MYSQL_MUTEX_LOCK(M)
+#define MUTEX_UNLOCK(M) MYSQL_MUTEX_UNLOCK(M)
+#define RW_WLOCK(M) MYSQL_RWLOCK_WRLOCK(M)
+#define RW_RLOCK(M) MYSQL_RWLOCK_RDLOCK(M)
+#define RW_UNLOCK(M) MYSQL_RWLOCK_UNLOCK(M)
+#define STRUCT_LOCK(M) MYSQL_MUTEX_LOCK(M)
+#define STRUCT_UNLOCK(M) MYSQL_MUTEX_UNLOCK(M)
#define BLOCK_LOCK_WR(B) B->query()->lock_writing()
#define BLOCK_LOCK_RD(B) B->query()->lock_reading()
#define BLOCK_UNLOCK_WR(B) B->query()->unlock_writing()
@@ -546,7 +546,7 @@ inline void Query_cache_query::lock_writ
my_bool Query_cache_query::try_lock_writing()
{
DBUG_ENTER("Query_cache_block::try_lock_writing");
- if (rw_trywrlock(&lock)!=0)
+ if (MYSQL_RWLOCK_TRYWRLOCK(&lock)!=0)
{
DBUG_PRINT("info", ("can't lock rwlock"));
DBUG_RETURN(0);
@@ -578,7 +578,7 @@ void Query_cache_query::init_n_lock()
{
DBUG_ENTER("Query_cache_query::init_n_lock");
res=0; wri = 0; len = 0;
- my_rwlock_init(&lock, NULL);
+ MYSQL_RWLOCK_INIT(&lock, key_QCQ_lock, NULL);
lock_writing();
DBUG_PRINT("qcache", ("inited & locked query for block %p",
(((uchar*) this) -
@@ -598,7 +598,7 @@ void Query_cache_query::unlock_n_destroy
active semaphore
*/
this->unlock_writing();
- rwlock_destroy(&lock);
+ MYSQL_RWLOCK_DESTROY(&lock);
DBUG_VOID_RETURN;
}
@@ -927,7 +927,7 @@ ulong Query_cache::resize(ulong query_ca
STRUCT_LOCK(&structure_guard_mutex);
while (is_flushing())
- pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
+ MYSQL_COND_WAIT(&COND_cache_status_changed, &structure_guard_mutex);
m_cache_status= Query_cache::FLUSH_IN_PROGRESS;
STRUCT_UNLOCK(&structure_guard_mutex);
@@ -963,7 +963,7 @@ ulong Query_cache::resize(ulong query_ca
STRUCT_LOCK(&structure_guard_mutex);
m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS;
- pthread_cond_signal(&COND_cache_status_changed);
+ MYSQL_COND_SIGNAL(&COND_cache_status_changed);
if (new_query_cache_size)
DBUG_EXECUTE("check_querycache",check_integrity(1););
STRUCT_UNLOCK(&structure_guard_mutex);
@@ -1639,7 +1639,7 @@ void Query_cache::wait_while_table_flush
If a table flush is in progress; wait on cache status to change.
*/
if (m_cache_status == Query_cache::TABLE_FLUSH_IN_PROGRESS)
- pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
+ MYSQL_COND_WAIT(&COND_cache_status_changed, &structure_guard_mutex);
}
*interrupt= FALSE;
}
@@ -1809,8 +1809,8 @@ void Query_cache::destroy()
free_cache();
STRUCT_UNLOCK(&structure_guard_mutex);
- pthread_cond_destroy(&COND_cache_status_changed);
- pthread_mutex_destroy(&structure_guard_mutex);
+ MYSQL_COND_DESTROY(&COND_cache_status_changed);
+ MYSQL_MUTEX_DESTROY(&structure_guard_mutex);
initialized = 0;
}
DBUG_VOID_RETURN;
@@ -1824,8 +1824,8 @@ void Query_cache::destroy()
void Query_cache::init()
{
DBUG_ENTER("Query_cache::init");
- pthread_mutex_init(&structure_guard_mutex,MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_cache_status_changed, NULL);
+ MYSQL_MUTEX_INIT(&structure_guard_mutex, key_structure_guard_mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&COND_cache_status_changed, key_COND_cache_status_changed, NULL);
m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS;
initialized = 1;
DBUG_VOID_RETURN;
@@ -2074,7 +2074,7 @@ void Query_cache::flush_cache()
flush the cache is empty.
*/
while (is_flushing())
- pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
+ MYSQL_COND_WAIT(&COND_cache_status_changed, &structure_guard_mutex);
/*
Setting 'FLUSH_IN_PROGRESS' will prevent other threads from using
@@ -2093,7 +2093,7 @@ void Query_cache::flush_cache()
STRUCT_LOCK(&structure_guard_mutex);
m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS;
- pthread_cond_signal(&COND_cache_status_changed);
+ MYSQL_COND_SIGNAL(&COND_cache_status_changed);
}
/*
@@ -2572,7 +2572,7 @@ void Query_cache::invalidate_table(THD *
net_real_write might be waiting on a change on the m_cache_status
variable.
*/
- pthread_cond_signal(&COND_cache_status_changed);
+ MYSQL_COND_SIGNAL(&COND_cache_status_changed);
STRUCT_UNLOCK(&structure_guard_mutex);
}
@@ -3705,7 +3705,7 @@ my_bool Query_cache::move_by_type(uchar
} while ( result_block != first_result_block );
}
Query_cache_query *new_query= ((Query_cache_query *) new_block->data());
- my_rwlock_init(&new_query->lock, NULL);
+ MYSQL_RWLOCK_INIT(&new_query->lock, key_QCQ_lock, NULL);
/*
If someone is writing to this block, inform the writer that the block
@@ -4129,7 +4129,7 @@ my_bool Query_cache::check_integrity(boo
STRUCT_LOCK(&structure_guard_mutex);
while (is_flushing())
- pthread_cond_wait(&COND_cache_status_changed,&structure_guard_mutex);
+ MYSQL_COND_WAIT(&COND_cache_status_changed,&structure_guard_mutex);
if (hash_check(&queries))
{
=== modified file 'sql/sql_cache.h'
--- a/sql/sql_cache.h 2008-08-10 14:49:52 +0000
+++ b/sql/sql_cache.h 2008-10-10 20:34:55 +0000
@@ -134,10 +134,14 @@ struct Query_cache_block
inline Query_cache_block_table *table(TABLE_COUNTER_TYPE n);
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_rwlock_key key_QCQ_lock;
+#endif
+
struct Query_cache_query
{
ulonglong limit_found_rows;
- rw_lock_t lock;
+ mysql_rwlock_t lock;
Query_cache_block *res;
Query_cache_tls *wri;
ulong len;
@@ -263,6 +267,11 @@ struct Query_cache_memory_bin_step
}
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_structure_guard_mutex;
+extern PSI_cond_key key_COND_cache_status_changed;
+#endif
+
class Query_cache
{
public:
@@ -274,7 +283,7 @@ public:
private:
- pthread_cond_t COND_cache_status_changed;
+ mysql_cond_t COND_cache_status_changed;
enum Cache_status { NO_FLUSH_IN_PROGRESS, FLUSH_IN_PROGRESS,
TABLE_FLUSH_IN_PROGRESS };
@@ -299,7 +308,7 @@ protected:
is other threads that were going to do cache flush---they'll wait
till the end of a flush operation.
*/
- pthread_mutex_t structure_guard_mutex;
+ mysql_mutex_t structure_guard_mutex;
uchar *cache; // cache memory
Query_cache_block *first_block; // physical location block list
Query_cache_block *queries_blocks; // query list (LIFO)
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2008-09-16 08:34:30 +0000
+++ b/sql/sql_class.cc 2008-10-10 20:34:55 +0000
@@ -608,7 +608,7 @@ THD::THD()
#ifdef SIGNAL_WITH_VIO_CLOSE
active_vio = 0;
#endif
- pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_delete, key_LOCK_delete, MY_MUTEX_INIT_FAST);
/* Variables with default values */
proc_info="login";
@@ -738,7 +738,7 @@ void thd_get_xid(const MYSQL_THD thd, MY
void THD::init(void)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
plugin_thdvar_init(this);
variables.time_format= date_time_format_copy((THD*) 0,
variables.time_format);
@@ -752,7 +752,7 @@ void THD::init(void)
avoid temporary tables replication failure.
*/
variables.pseudo_thread_id= thread_id;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
server_status= SERVER_STATUS_AUTOCOMMIT;
if (variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)
server_status|= SERVER_STATUS_NO_BACKSLASH_ESCAPES;
@@ -817,9 +817,9 @@ void THD::init_for_queries()
void THD::change_user(void)
{
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
add_to_status(&global_status_var, &status_var);
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
cleanup();
killed= NOT_KILLED;
@@ -875,9 +875,9 @@ void THD::cleanup(void)
unlock_global_read_lock(this);
if (ull)
{
- pthread_mutex_lock(&LOCK_user_locks);
+ MYSQL_MUTEX_LOCK(&LOCK_user_locks);
item_user_lock_release(ull);
- pthread_mutex_unlock(&LOCK_user_locks);
+ MYSQL_MUTEX_UNLOCK(&LOCK_user_locks);
ull= NULL;
}
@@ -913,8 +913,8 @@ THD::~THD()
THD_CHECK_SENTRY(this);
DBUG_ENTER("~THD()");
/* Ensure that no one is using THD */
- pthread_mutex_lock(&LOCK_delete);
- pthread_mutex_unlock(&LOCK_delete);
+ MYSQL_MUTEX_LOCK(&LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delete);
add_to_status(&global_status_var, &status_var);
/* Close connection */
@@ -943,7 +943,7 @@ THD::~THD()
free_root(&warn_root,MYF(0));
free_root(&transaction.mem_root,MYF(0));
mysys_var=0; // Safety (shouldn't be needed)
- pthread_mutex_destroy(&LOCK_delete);
+ MYSQL_MUTEX_DESTROY(&LOCK_delete);
#ifndef DBUG_OFF
dbug_sentry= THD_SENTRY_GONE;
#endif
@@ -1018,7 +1018,7 @@ void THD::awake(THD::killed_state state_
DBUG_ENTER("THD::awake");
DBUG_PRINT("enter", ("this: %p", this));
THD_CHECK_SENTRY(this);
- safe_mutex_assert_owner(&LOCK_delete);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_delete);
killed= state_to_set;
if (state_to_set != THD::KILL_QUERY)
@@ -1045,7 +1045,7 @@ void THD::awake(THD::killed_state state_
}
if (mysys_var)
{
- pthread_mutex_lock(&mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&mysys_var->mutex);
if (system_thread == NON_SYSTEM_THREAD ||
system_thread == SYSTEM_THREAD_BACKUP)
mysys_var->abort= 1; // abort locks
@@ -1070,11 +1070,11 @@ void THD::awake(THD::killed_state state_
*/
if (mysys_var->current_cond && mysys_var->current_mutex)
{
- pthread_mutex_lock(mysys_var->current_mutex);
- pthread_cond_broadcast(mysys_var->current_cond);
- pthread_mutex_unlock(mysys_var->current_mutex);
+ MYSQL_MUTEX_LOCK(mysys_var->current_mutex);
+ MYSQL_COND_BROADCAST(mysys_var->current_cond);
+ MYSQL_MUTEX_UNLOCK(mysys_var->current_mutex);
}
- pthread_mutex_unlock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&mysys_var->mutex);
}
DBUG_VOID_RETURN;
}
@@ -1419,7 +1419,7 @@ int THD::send_explain_fields(select_resu
void THD::close_active_vio()
{
DBUG_ENTER("close_active_vio");
- safe_mutex_assert_owner(&LOCK_delete);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_delete);
#ifndef EMBEDDED_LIBRARY
if (active_vio)
{
@@ -2512,7 +2512,7 @@ int Statement_map::insert(THD *thd, Stat
my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto err_names_hash;
}
- pthread_mutex_lock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_LOCK(&LOCK_prepared_stmt_count);
/*
We don't check that prepared_stmt_count is <= max_prepared_stmt_count
because we would like to allow to lower the total limit
@@ -2522,13 +2522,13 @@ int Statement_map::insert(THD *thd, Stat
*/
if (prepared_stmt_count >= max_prepared_stmt_count)
{
- pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prepared_stmt_count);
my_error(ER_MAX_PREPARED_STMT_COUNT_REACHED, MYF(0),
max_prepared_stmt_count);
goto err_max;
}
prepared_stmt_count++;
- pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prepared_stmt_count);
last_found_statement= statement;
return 0;
@@ -2561,20 +2561,20 @@ void Statement_map::erase(Statement *sta
hash_delete(&names_hash, (uchar *) statement);
hash_delete(&st_hash, (uchar *) statement);
- pthread_mutex_lock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_LOCK(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count > 0);
prepared_stmt_count--;
- pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prepared_stmt_count);
}
void Statement_map::reset()
{
/* Must be first, hash_free will reset st_hash.records */
- pthread_mutex_lock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_LOCK(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
prepared_stmt_count-= st_hash.records;
- pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prepared_stmt_count);
my_hash_reset(&names_hash);
my_hash_reset(&st_hash);
@@ -2585,10 +2585,10 @@ void Statement_map::reset()
Statement_map::~Statement_map()
{
/* Must go first, hash_free will reset st_hash.records */
- pthread_mutex_lock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_LOCK(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
prepared_stmt_count-= st_hash.records;
- pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_prepared_stmt_count);
hash_free(&names_hash);
hash_free(&st_hash);
@@ -3080,7 +3080,10 @@ void mark_transaction_to_rollback(THD *t
Handling of XA id cacheing
***************************************************************************/
-pthread_mutex_t LOCK_xid_cache;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_xid_cache;
+#endif
+mysql_mutex_t LOCK_xid_cache;
HASH xid_cache;
extern "C" uchar *xid_get_hash_key(const uchar *, size_t *, my_bool);
@@ -3101,7 +3104,7 @@ void xid_free_hash(void *ptr)
bool xid_cache_init()
{
- pthread_mutex_init(&LOCK_xid_cache, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_xid_cache, key_LOCK_xid_cache, MY_MUTEX_INIT_FAST);
return hash_init(&xid_cache, &my_charset_bin, 100, 0, 0,
xid_get_hash_key, xid_free_hash, 0) != 0;
}
@@ -3111,15 +3114,15 @@ void xid_cache_free()
if (hash_inited(&xid_cache))
{
hash_free(&xid_cache);
- pthread_mutex_destroy(&LOCK_xid_cache);
+ MYSQL_MUTEX_DESTROY(&LOCK_xid_cache);
}
}
XID_STATE *xid_cache_search(XID *xid)
{
- pthread_mutex_lock(&LOCK_xid_cache);
+ MYSQL_MUTEX_LOCK(&LOCK_xid_cache);
XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, xid->key(), xid->key_length());
- pthread_mutex_unlock(&LOCK_xid_cache);
+ MYSQL_MUTEX_UNLOCK(&LOCK_xid_cache);
return res;
}
@@ -3128,7 +3131,7 @@ bool xid_cache_insert(XID *xid, enum xa_
{
XID_STATE *xs;
my_bool res;
- pthread_mutex_lock(&LOCK_xid_cache);
+ MYSQL_MUTEX_LOCK(&LOCK_xid_cache);
if (hash_search(&xid_cache, xid->key(), xid->key_length()))
res=0;
else if (!(xs=(XID_STATE *)my_malloc(sizeof(*xs), MYF(MY_WME))))
@@ -3140,27 +3143,27 @@ bool xid_cache_insert(XID *xid, enum xa_
xs->in_thd=0;
res=my_hash_insert(&xid_cache, (uchar*)xs);
}
- pthread_mutex_unlock(&LOCK_xid_cache);
+ MYSQL_MUTEX_UNLOCK(&LOCK_xid_cache);
return res;
}
bool xid_cache_insert(XID_STATE *xid_state)
{
- pthread_mutex_lock(&LOCK_xid_cache);
+ MYSQL_MUTEX_LOCK(&LOCK_xid_cache);
DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(),
xid_state->xid.key_length())==0);
my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
- pthread_mutex_unlock(&LOCK_xid_cache);
+ MYSQL_MUTEX_UNLOCK(&LOCK_xid_cache);
return res;
}
void xid_cache_delete(XID_STATE *xid_state)
{
- pthread_mutex_lock(&LOCK_xid_cache);
+ MYSQL_MUTEX_LOCK(&LOCK_xid_cache);
hash_delete(&xid_cache, (uchar *)xid_state);
- pthread_mutex_unlock(&LOCK_xid_cache);
+ MYSQL_MUTEX_UNLOCK(&LOCK_xid_cache);
}
/*
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2008-09-05 14:16:07 +0000
+++ b/sql/sql_class.h 2008-10-10 20:34:55 +0000
@@ -804,7 +804,7 @@ typedef struct st_xid_state {
bool in_thd;
} XID_STATE;
-extern pthread_mutex_t LOCK_xid_cache;
+extern mysql_mutex_t LOCK_xid_cache;
extern HASH xid_cache;
bool xid_cache_init(void);
void xid_cache_free(void);
@@ -1310,6 +1310,9 @@ struct Ha_data
Ha_data() :ha_ptr(NULL) {}
};
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_delete;
+#endif
/**
@class THD
@@ -1370,7 +1373,7 @@ public:
THR_LOCK_OWNER main_lock_id; // To use for conventional queries
THR_LOCK_OWNER *lock_id; // If not main_lock_id, points to
// the lock_id of a cursor.
- pthread_mutex_t LOCK_delete; // Locked before thd is deleted
+ mysql_mutex_t LOCK_delete; // Locked before thd is deleted
/* all prepared statements and cursors of this connection */
Statement_map stmt_map;
/*
@@ -1986,15 +1989,15 @@ public:
#ifdef SIGNAL_WITH_VIO_CLOSE
inline void set_active_vio(Vio* vio)
{
- pthread_mutex_lock(&LOCK_delete);
+ MYSQL_MUTEX_LOCK(&LOCK_delete);
active_vio = vio;
- pthread_mutex_unlock(&LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delete);
}
inline void clear_active_vio()
{
- pthread_mutex_lock(&LOCK_delete);
+ MYSQL_MUTEX_LOCK(&LOCK_delete);
active_vio = 0;
- pthread_mutex_unlock(&LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delete);
}
void close_active_vio();
#endif
@@ -2031,11 +2034,11 @@ public:
enter_cond(); this mutex is then released by exit_cond().
Usage must be: lock mutex; enter_cond(); your code; exit_cond().
*/
- inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
+ inline const char* enter_cond(mysql_cond_t *cond, mysql_mutex_t* mutex,
const char* msg)
{
const char* old_msg = get_proc_info();
- safe_mutex_assert_owner(mutex);
+ MYSQL_MUTEX_ASSERT_OWNER(mutex);
mysys_var->current_mutex = mutex;
mysys_var->current_cond = cond;
thd_proc_info(this, msg);
@@ -2049,12 +2052,12 @@ public:
locked (if that would not be the case, you'll get a deadlock if someone
does a THD::awake() on you).
*/
- pthread_mutex_unlock(mysys_var->current_mutex);
- pthread_mutex_lock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(mysys_var->current_mutex);
+ MYSQL_MUTEX_LOCK(&mysys_var->mutex);
mysys_var->current_mutex = 0;
mysys_var->current_cond = 0;
thd_proc_info(this, old_msg);
- pthread_mutex_unlock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&mysys_var->mutex);
}
inline time_t query_start() { query_start_used=1; return start_time; }
inline void set_time()
=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc 2008-06-27 09:26:03 +0000
+++ b/sql/sql_connect.cc 2008-10-10 20:34:55 +0000
@@ -64,7 +64,7 @@ static int get_or_create_user_conn(THD *
user_len= strlen(user);
temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
- (void) pthread_mutex_lock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_user_conn);
if (!(uc = (struct user_conn *) hash_search(&hash_user_connections,
(uchar*) temp_user, temp_len)))
{
@@ -95,7 +95,7 @@ static int get_or_create_user_conn(THD *
thd->user_connect=uc;
uc->connections++;
end:
- (void) pthread_mutex_unlock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_user_conn);
return return_val;
}
@@ -124,7 +124,7 @@ int check_for_max_user_connections(THD *
int error=0;
DBUG_ENTER("check_for_max_user_connections");
- (void) pthread_mutex_lock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_user_conn);
if (max_user_connections && !uc->user_resources.user_conn &&
max_user_connections < (uint) uc->connections)
{
@@ -164,7 +164,7 @@ end:
*/
thd->user_connect= NULL;
}
- (void) pthread_mutex_unlock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_user_conn);
DBUG_RETURN(error);
}
@@ -190,14 +190,14 @@ end:
void decrease_user_connections(USER_CONN *uc)
{
DBUG_ENTER("decrease_user_connections");
- (void) pthread_mutex_lock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_user_conn);
DBUG_ASSERT(uc->connections);
if (!--uc->connections && !mqh_used)
{
/* Last connection for user; Delete it */
(void) hash_delete(&hash_user_connections,(uchar*) uc);
}
- (void) pthread_mutex_unlock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_user_conn);
DBUG_VOID_RETURN;
}
@@ -245,7 +245,7 @@ bool check_mqh(THD *thd, uint check_comm
DBUG_ENTER("check_mqh");
DBUG_ASSERT(uc != 0);
- (void) pthread_mutex_lock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_user_conn);
time_out_user_resource_limits(thd, uc);
@@ -272,7 +272,7 @@ bool check_mqh(THD *thd, uint check_comm
}
}
end:
- (void) pthread_mutex_unlock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_user_conn);
DBUG_RETURN(error);
}
@@ -333,9 +333,9 @@ check_user(THD *thd, enum enum_server_co
#else
my_bool opt_secure_auth_local;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
opt_secure_auth_local= opt_secure_auth;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
/*
If the server is running in secure auth mode, short scrambles are
@@ -412,10 +412,10 @@ check_user(THD *thd, enum enum_server_co
if (check_count)
{
- pthread_mutex_lock(&LOCK_connection_count);
+ MYSQL_MUTEX_LOCK(&LOCK_connection_count);
bool count_ok= connection_count <= max_connections ||
(thd->main_security_ctx.master_access & SUPER_ACL);
- pthread_mutex_unlock(&LOCK_connection_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_connection_count);
if (!count_ok)
{ // too many connections
@@ -560,7 +560,7 @@ void free_max_user_conn(void)
void reset_mqh(LEX_USER *lu, bool get_them= 0)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
- (void) pthread_mutex_lock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_user_conn);
if (lu) // for GRANT
{
USER_CONN *uc;
@@ -593,7 +593,7 @@ void reset_mqh(LEX_USER *lu, bool get_th
uc->conn_per_hour=0;
}
}
- (void) pthread_mutex_unlock(&LOCK_user_conn);
+ (void) MYSQL_MUTEX_UNLOCK(&LOCK_user_conn);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}
=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc 2008-08-27 08:47:03 +0000
+++ b/sql/sql_db.cc 2008-10-10 20:34:55 +0000
@@ -47,7 +47,7 @@ static void mysql_change_db_impl(THD *th
/* Database lock hash */
HASH lock_db_cache;
-pthread_mutex_t LOCK_lock_db;
+mysql_mutex_t LOCK_lock_db;
int creating_database= 0; // how many database locks are made
@@ -103,7 +103,7 @@ static my_bool lock_db_insert(const char
my_bool error= 0;
DBUG_ENTER("lock_db_insert");
- safe_mutex_assert_owner(&LOCK_lock_db);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_lock_db);
if (!(opt= (my_dblock_t*) hash_search(&lock_db_cache,
(uchar*) dbname, length)))
@@ -138,7 +138,7 @@ end:
void lock_db_delete(const char *name, uint length)
{
my_dblock_t *opt;
- safe_mutex_assert_owner(&LOCK_lock_db);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_lock_db);
if ((opt= (my_dblock_t *)hash_search(&lock_db_cache,
(const uchar*) name, length)))
hash_delete(&lock_db_cache, (uchar*) opt);
@@ -148,7 +148,12 @@ void lock_db_delete(const char *name, ui
/* Database options hash */
static HASH dboptions;
static my_bool dboptions_init= 0;
-static rw_lock_t LOCK_dboptions;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_rwlock_key key_LOCK_dboptions;
+#endif
+
+static mysql_rwlock_t LOCK_dboptions;
/* Structure for database options */
typedef struct my_dbopt_st
@@ -218,7 +223,7 @@ void free_dbopt(void *dbopt)
bool my_database_names_init(void)
{
bool error= 0;
- (void) my_rwlock_init(&LOCK_dboptions, NULL);
+ (void) MYSQL_RWLOCK_INIT(&LOCK_dboptions, key_LOCK_dboptions, NULL);
if (!dboptions_init)
{
dboptions_init= 1;
@@ -247,7 +252,7 @@ void my_database_names_free(void)
{
dboptions_init= 0;
hash_free(&dboptions);
- (void) rwlock_destroy(&LOCK_dboptions);
+ (void) MYSQL_RWLOCK_DESTROY(&LOCK_dboptions);
hash_free(&lock_db_cache);
}
}
@@ -259,13 +264,13 @@ void my_database_names_free(void)
void my_dbopt_cleanup(void)
{
- rw_wrlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_dboptions);
hash_free(&dboptions);
hash_init(&dboptions, lower_case_table_names ?
&my_charset_bin : system_charset_info,
32, 0, 0, (hash_get_key) dboptions_get_key,
free_dbopt,0);
- rw_unlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_dboptions);
}
@@ -289,13 +294,13 @@ static my_bool get_dbopt(const char *dbn
length= (uint) strlen(dbname);
- rw_rdlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_dboptions);
if ((opt= (my_dbopt_t*) hash_search(&dboptions, (uchar*) dbname, length)))
{
create->default_table_charset= opt->charset;
error= 0;
}
- rw_unlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_dboptions);
return error;
}
@@ -321,7 +326,7 @@ static my_bool put_dbopt(const char *dbn
length= (uint) strlen(dbname);
- rw_wrlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_dboptions);
if (!(opt= (my_dbopt_t*) hash_search(&dboptions, (uchar*) dbname, length)))
{
/* Options are not in the hash, insert them */
@@ -349,7 +354,7 @@ static my_bool put_dbopt(const char *dbn
opt->charset= create->default_table_charset;
end:
- rw_unlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_dboptions);
DBUG_RETURN(error);
}
@@ -361,11 +366,11 @@ end:
void del_dbopt(const char *path)
{
my_dbopt_t *opt;
- rw_wrlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_dboptions);
if ((opt= (my_dbopt_t *)hash_search(&dboptions, (const uchar*) path,
strlen(path))))
hash_delete(&dboptions, (uchar*) opt);
- rw_unlock(&LOCK_dboptions);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_dboptions);
}
@@ -643,7 +648,7 @@ int mysql_create_db(THD *thd, char *db,
goto exit2;
}
- pthread_mutex_lock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_LOCK(&LOCK_mysql_create_db);
/* Check directory */
path_len= build_table_filename(path, sizeof(path), db, "", "", 0);
@@ -753,7 +758,7 @@ int mysql_create_db(THD *thd, char *db,
}
exit:
- pthread_mutex_unlock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mysql_create_db);
start_waiting_global_read_lock(thd);
exit2:
DBUG_RETURN(error);
@@ -784,7 +789,7 @@ bool mysql_alter_db(THD *thd, const char
if ((error=wait_if_global_read_lock(thd,0,1)))
goto exit2;
- pthread_mutex_lock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_LOCK(&LOCK_mysql_create_db);
/*
Recreate db options file: /dbpath/.db.opt
@@ -829,7 +834,7 @@ bool mysql_alter_db(THD *thd, const char
my_ok(thd, result);
exit:
- pthread_mutex_unlock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mysql_create_db);
start_waiting_global_read_lock(thd);
exit2:
DBUG_RETURN(error);
@@ -881,7 +886,7 @@ bool mysql_rm_db(THD *thd,char *db,bool
goto exit2;
}
- pthread_mutex_lock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_LOCK(&LOCK_mysql_create_db);
length= build_table_filename(path, sizeof(path), db, "", "", 0);
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
@@ -1020,7 +1025,7 @@ exit:
*/
if (thd->db && !strcmp(thd->db, db) && error == 0)
mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
- pthread_mutex_unlock(&LOCK_mysql_create_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mysql_create_db);
start_waiting_global_read_lock(thd);
exit2:
DBUG_RETURN(error);
@@ -1706,18 +1711,18 @@ static int
lock_databases(THD *thd, const char *db1, uint length1,
const char *db2, uint length2)
{
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
while (!thd->killed &&
(hash_search(&lock_db_cache,(uchar*) db1, length1) ||
hash_search(&lock_db_cache,(uchar*) db2, length2)))
{
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
}
if (thd->killed)
{
- pthread_mutex_unlock(&LOCK_lock_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
return 1;
}
@@ -1734,7 +1739,7 @@ lock_databases(THD *thd, const char *db1
while (!thd->killed && creating_table)
{
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
}
if (thd->killed)
@@ -1742,8 +1747,8 @@ lock_databases(THD *thd, const char *db1
lock_db_delete(db1, length1);
lock_db_delete(db2, length2);
creating_database--;
- pthread_mutex_unlock(&LOCK_lock_db);
- pthread_cond_signal(&COND_refresh);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
+ MYSQL_COND_SIGNAL(&COND_refresh);
return(1);
}
@@ -1751,7 +1756,7 @@ lock_databases(THD *thd, const char *db1
We can unlock now as the hash will protect against anyone creating a table
in the databases we are using
*/
- pthread_mutex_unlock(&LOCK_lock_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
return 0;
}
@@ -1962,14 +1967,14 @@ bool mysql_upgrade_db(THD *thd, LEX_STRI
error|= mysql_change_db(thd, & new_db, FALSE);
exit:
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
/* Remove the databases from db lock cache */
lock_db_delete(old_db->str, old_db->length);
lock_db_delete(new_db.str, new_db.length);
creating_database--;
/* Signal waiting CREATE TABLE's to continue */
- pthread_cond_signal(&COND_refresh);
- pthread_mutex_unlock(&LOCK_lock_db);
+ MYSQL_COND_SIGNAL(&COND_refresh);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
DBUG_RETURN(error);
}
=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc 2008-07-26 16:38:20 +0000
+++ b/sql/sql_delete.cc 2008-10-10 20:34:55 +0000
@@ -1044,10 +1044,10 @@ bool mysql_truncate(THD *thd, TABLE_LIST
mdl_remove_lock(&thd->mdl_context, mdl_lock_data);
DBUG_RETURN(TRUE);
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_list->db,
table_list->table_name);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
/*
@@ -1056,10 +1056,10 @@ bool mysql_truncate(THD *thd, TABLE_LIST
'\0';
*/
path[path_length - reg_ext_length] = 0;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
error= ha_create_table(thd, path, table_list->db, table_list->table_name,
&create_info, 1);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
query_cache_invalidate3(thd, table_list, 0);
end:
=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc 2008-08-07 17:52:43 +0000
+++ b/sql/sql_handler.cc 2008-10-10 20:34:55 +0000
@@ -142,13 +142,13 @@ static void mysql_ha_close_table(THD *th
{
(*table_ptr)->file->ha_index_or_rnd_end();
mdl_lock_data= (*table_ptr)->mdl_lock_data;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (close_thread_table(thd, table_ptr))
{
/* Tell threads waiting for refresh that something has happened */
broadcast_refresh();
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
mdl_release_lock(&thd->handler_mdl_context, mdl_lock_data);
mdl_remove_lock(&thd->handler_mdl_context, mdl_lock_data);
}
@@ -768,7 +768,7 @@ void mysql_ha_flush(THD *thd)
TABLE_LIST *hash_tables;
DBUG_ENTER("mysql_ha_flush");
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
for (uint i= 0; i < thd->handler_tables_hash.records; i++)
{
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2008-09-16 17:58:49 +0000
+++ b/sql/sql_insert.cc 2008-10-10 20:34:55 +0000
@@ -1707,6 +1707,12 @@ public:
}
};
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_Delayed_insert_mutex;
+PSI_cond_key key_Delayed_insert_cond;
+PSI_cond_key key_Delayed_insert_cond_client;
+#endif
+
/**
Delayed_insert - context of a thread responsible for delayed insert
into one table. When processing delayed inserts, we create an own
@@ -1719,8 +1725,8 @@ class Delayed_insert :public ilink {
public:
THD thd;
TABLE *table;
- pthread_mutex_t mutex;
- pthread_cond_t cond,cond_client;
+ mysql_mutex_t mutex;
+ mysql_cond_t cond,cond_client;
volatile uint tables_in_use,stacked_inserts;
volatile bool status,dead;
COPY_INFO info;
@@ -1752,12 +1758,12 @@ public:
thd.system_thread= SYSTEM_THREAD_DELAYED_INSERT;
thd.security_ctx->host_or_ip= "";
bzero((char*) &info,sizeof(info));
- pthread_mutex_init(&mutex,MY_MUTEX_INIT_FAST);
- pthread_cond_init(&cond,NULL);
- pthread_cond_init(&cond_client,NULL);
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_INIT(&mutex, key_Delayed_insert_mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_COND_INIT(&cond, key_Delayed_insert_cond, NULL);
+ MYSQL_COND_INIT(&cond_client, key_Delayed_insert_cond_client, NULL);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
delayed_insert_threads++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
~Delayed_insert()
{
@@ -1767,17 +1773,17 @@ public:
delete row;
if (table)
close_thread_tables(&thd);
- pthread_mutex_lock(&LOCK_thread_count);
- pthread_mutex_destroy(&mutex);
- pthread_cond_destroy(&cond);
- pthread_cond_destroy(&cond_client);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
+ MYSQL_MUTEX_DESTROY(&mutex);
+ MYSQL_COND_DESTROY(&cond);
+ MYSQL_COND_DESTROY(&cond_client);
thd.unlink(); // Must be unlinked under lock
x_free(thd.query);
thd.security_ctx->user= thd.security_ctx->host=0;
thread_count--;
delayed_insert_threads--;
- pthread_mutex_unlock(&LOCK_thread_count);
- pthread_cond_broadcast(&COND_thread_count); /* Tell main we are ready */
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
+ MYSQL_COND_BROADCAST(&COND_thread_count); /* Tell main we are ready */
}
/* The following is for checking when we can delete ourselves */
@@ -1787,18 +1793,18 @@ public:
}
void unlock()
{
- pthread_mutex_lock(&LOCK_delayed_insert);
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_insert);
if (!--locks_in_memory)
{
- pthread_mutex_lock(&mutex);
+ MYSQL_MUTEX_LOCK(&mutex);
if (thd.killed && ! stacked_inserts && ! tables_in_use)
{
- pthread_cond_signal(&cond);
+ MYSQL_COND_SIGNAL(&cond);
status=1;
}
- pthread_mutex_unlock(&mutex);
+ MYSQL_MUTEX_UNLOCK(&mutex);
}
- pthread_mutex_unlock(&LOCK_delayed_insert);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_insert);
}
inline uint lock_count() { return locks_in_memory; }
@@ -1820,7 +1826,7 @@ static
Delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
{
thd_proc_info(thd, "waiting for delay_list");
- pthread_mutex_lock(&LOCK_delayed_insert); // Protect master list
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_insert); // Protect master list
I_List_iterator<Delayed_insert> it(delayed_threads);
Delayed_insert *di;
while ((di= it++))
@@ -1832,7 +1838,7 @@ Delayed_insert *find_handler(THD *thd, T
break;
}
}
- pthread_mutex_unlock(&LOCK_delayed_insert); // For unlink from list
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_insert); // For unlink from list
return di;
}
@@ -1902,7 +1908,7 @@ bool delayed_get_table(THD *thd, TABLE_L
if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
DBUG_RETURN(0);
thd_proc_info(thd, "Creating delayed handler");
- pthread_mutex_lock(&LOCK_delayed_create);
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_create);
/*
The first search above was done without LOCK_delayed_create.
Another thread might have created the handler in between. Search again.
@@ -1911,9 +1917,9 @@ bool delayed_get_table(THD *thd, TABLE_L
{
if (!(di= new Delayed_insert()))
goto end_create;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
di->thd.set_db(table_list->db, strlen(table_list->db));
di->thd.query= my_strdup(table_list->table_name, MYF(MY_WME | ME_FATALERROR));
if (di->thd.db == NULL || di->thd.query == NULL)
@@ -1927,14 +1933,14 @@ bool delayed_get_table(THD *thd, TABLE_L
di->table_list.alias= di->table_list.table_name= di->thd.query;
di->table_list.db= di->thd.db;
di->lock();
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
if ((error= pthread_create(&di->thd.real_id, &connection_attrib,
handle_delayed_insert, (void*) di)))
{
DBUG_PRINT("error",
("Can't create thread to handle delayed insert (error %d)",
error));
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
di->unlock();
delete di;
my_error(ER_CANT_CREATE_THREAD, MYF(ME_FATALERROR), error);
@@ -1945,9 +1951,9 @@ bool delayed_get_table(THD *thd, TABLE_L
thd_proc_info(thd, "waiting for handler open");
while (!di->thd.killed && !di->table && !thd->killed)
{
- pthread_cond_wait(&di->cond_client, &di->mutex);
+ MYSQL_COND_WAIT(&di->cond_client, &di->mutex);
}
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
thd_proc_info(thd, "got old table");
if (di->thd.killed)
{
@@ -1970,16 +1976,16 @@ bool delayed_get_table(THD *thd, TABLE_L
di->unlock();
goto end_create;
}
- pthread_mutex_lock(&LOCK_delayed_insert);
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_insert);
delayed_threads.append(di);
- pthread_mutex_unlock(&LOCK_delayed_insert);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_insert);
}
- pthread_mutex_unlock(&LOCK_delayed_create);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_create);
}
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
table_list->table= di->get_local_table(thd);
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
if (table_list->table)
{
DBUG_ASSERT(! thd->is_error());
@@ -1990,7 +1996,7 @@ bool delayed_get_table(THD *thd, TABLE_L
DBUG_RETURN((table_list->table == NULL));
end_create:
- pthread_mutex_unlock(&LOCK_delayed_create);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_create);
DBUG_RETURN(thd->is_error());
}
@@ -2026,10 +2032,10 @@ TABLE *Delayed_insert::get_local_table(T
if (!thd.lock) // Table is not locked
{
thd_proc_info(client_thd, "waiting for handler lock");
- pthread_cond_signal(&cond); // Tell handler to lock table
+ MYSQL_COND_SIGNAL(&cond); // Tell handler to lock table
while (!dead && !thd.lock && ! client_thd->killed)
{
- pthread_cond_wait(&cond_client,&mutex);
+ MYSQL_COND_WAIT(&cond_client,&mutex);
}
thd_proc_info(client_thd, "got handler lock");
if (client_thd->killed)
@@ -2116,7 +2122,7 @@ TABLE *Delayed_insert::get_local_table(T
error:
tables_in_use--;
status=1;
- pthread_cond_signal(&cond); // Inform thread about abort
+ MYSQL_COND_SIGNAL(&cond); // Inform thread about abort
DBUG_RETURN(0);
}
@@ -2135,9 +2141,9 @@ int write_delayed(THD *thd, TABLE *table
(ulong) query.length));
thd_proc_info(thd, "waiting for handler insert");
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
while (di->stacked_inserts >= delayed_queue_size && !thd->killed)
- pthread_cond_wait(&di->cond_client,&di->mutex);
+ MYSQL_COND_WAIT(&di->cond_client,&di->mutex);
thd_proc_info(thd, "storing row into queue");
if (thd->killed)
@@ -2199,15 +2205,15 @@ int write_delayed(THD *thd, TABLE *table
di->status=1;
if (table->s->blob_fields)
unlink_blobs(table);
- pthread_cond_signal(&di->cond);
+ MYSQL_COND_SIGNAL(&di->cond);
thread_safe_increment(delayed_rows_in_use,&LOCK_delayed_status);
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
DBUG_RETURN(0);
err:
delete row;
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
DBUG_RETURN(1);
}
@@ -2220,14 +2226,14 @@ static void end_delayed_insert(THD *thd)
{
DBUG_ENTER("end_delayed_insert");
Delayed_insert *di=thd->di;
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
DBUG_PRINT("info",("tables in use: %d",di->tables_in_use));
if (!--di->tables_in_use || di->thd.killed)
{ // Unlock table
di->status=1;
- pthread_cond_signal(&di->cond);
+ MYSQL_COND_SIGNAL(&di->cond);
}
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
DBUG_VOID_RETURN;
}
@@ -2236,7 +2242,7 @@ static void end_delayed_insert(THD *thd)
void kill_delayed_threads(void)
{
- pthread_mutex_lock(&LOCK_delayed_insert); // For unlink from list
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_insert); // For unlink from list
I_List_iterator<Delayed_insert> it(delayed_threads);
Delayed_insert *di;
@@ -2245,7 +2251,7 @@ void kill_delayed_threads(void)
di->thd.killed= THD::KILL_CONNECTION;
if (di->thd.mysys_var)
{
- pthread_mutex_lock(&di->thd.mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&di->thd.mysys_var->mutex);
if (di->thd.mysys_var->current_cond)
{
/*
@@ -2253,15 +2259,15 @@ void kill_delayed_threads(void)
in handle_delayed_insert()
*/
if (&di->mutex != di->thd.mysys_var->current_mutex)
- pthread_mutex_lock(di->thd.mysys_var->current_mutex);
- pthread_cond_broadcast(di->thd.mysys_var->current_cond);
+ MYSQL_MUTEX_LOCK(di->thd.mysys_var->current_mutex);
+ MYSQL_COND_BROADCAST(di->thd.mysys_var->current_cond);
if (&di->mutex != di->thd.mysys_var->current_mutex)
- pthread_mutex_unlock(di->thd.mysys_var->current_mutex);
+ MYSQL_MUTEX_UNLOCK(di->thd.mysys_var->current_mutex);
}
- pthread_mutex_unlock(&di->thd.mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->thd.mysys_var->mutex);
}
}
- pthread_mutex_unlock(&LOCK_delayed_insert); // For unlink from list
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_insert); // For unlink from list
}
@@ -2312,22 +2318,22 @@ pthread_handler_t handle_delayed_insert(
pthread_detach_this_thread();
/* Add thread to THD list so that's it's visible in 'show processlist' */
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
thd->set_current_time();
threads.append(thd);
thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
/*
- Wait until the client runs into pthread_cond_wait(),
+ Wait until the client runs into MYSQL_COND_WAIT(),
where we free it after the table is opened and di linked in the list.
If we did not wait here, the client might detect the opened table
before it is linked to the list. It would release LOCK_delayed_create
and allow another thread to create another handler for the same table,
since it does not find one in the list.
*/
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
#if !defined( __WIN__) /* Win32 calls this in pthread_create */
if (my_thread_init())
{
@@ -2369,7 +2375,7 @@ pthread_handler_t handle_delayed_insert(
goto err;
/* Tell client that the thread is initialized */
- pthread_cond_signal(&di->cond_client);
+ MYSQL_COND_SIGNAL(&di->cond_client);
/* Now wait until we get an insert or lock to handle */
/* We will not abort as long as a client thread uses this thread */
@@ -2383,12 +2389,12 @@ pthread_handler_t handle_delayed_insert(
Remove this from delay insert list so that no one can request a
table from this
*/
- pthread_mutex_unlock(&di->mutex);
- pthread_mutex_lock(&LOCK_delayed_insert);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_insert);
di->unlink();
lock_count=di->lock_count();
- pthread_mutex_unlock(&LOCK_delayed_insert);
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_insert);
+ MYSQL_MUTEX_LOCK(&di->mutex);
if (!lock_count && !di->tables_in_use && !di->stacked_inserts)
break; // Time to die
}
@@ -2409,14 +2415,14 @@ pthread_handler_t handle_delayed_insert(
int error;
mysql_audit_release(thd);
#if defined(HAVE_BROKEN_COND_TIMEDWAIT)
- error=pthread_cond_wait(&di->cond,&di->mutex);
+ error=MYSQL_COND_WAIT(&di->cond,&di->mutex);
#else
- error=pthread_cond_timedwait(&di->cond,&di->mutex,&abstime);
+ error=MYSQL_COND_TIMEDWAIT(&di->cond,&di->mutex,&abstime);
#ifdef EXTRA_DEBUG
if (error && error != EINTR && error != ETIMEDOUT)
{
- fprintf(stderr, "Got error %d from pthread_cond_timedwait\n",error);
- DBUG_PRINT("error",("Got error %d from pthread_cond_timedwait",
+ fprintf(stderr, "Got error %d from MYSQL_COND_TIMEDWAIT\n",error);
+ DBUG_PRINT("error",("Got error %d from MYSQL_COND_TIMEDWAIT",
error));
}
#endif
@@ -2430,12 +2436,12 @@ pthread_handler_t handle_delayed_insert(
}
}
/* We can't lock di->mutex and mysys_var->mutex at the same time */
- pthread_mutex_unlock(&di->mutex);
- pthread_mutex_lock(&di->thd.mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->thd.mysys_var->mutex);
di->thd.mysys_var->current_mutex= 0;
di->thd.mysys_var->current_cond= 0;
- pthread_mutex_unlock(&di->thd.mysys_var->mutex);
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->thd.mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
}
thd_proc_info(&(di->thd), 0);
@@ -2478,7 +2484,7 @@ pthread_handler_t handle_delayed_insert(
thd->killed= THD::KILL_CONNECTION;
}
}
- pthread_cond_broadcast(&di->cond_client);
+ MYSQL_COND_BROADCAST(&di->cond_client);
}
if (di->stacked_inserts)
{
@@ -2498,7 +2504,7 @@ pthread_handler_t handle_delayed_insert(
*/
MYSQL_LOCK *lock=thd->lock;
thd->lock=0;
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
/*
We need to release next_insert_id before unlocking. This is
enforced by handler::ha_external_lock().
@@ -2508,10 +2514,10 @@ pthread_handler_t handle_delayed_insert(
trans_commit_stmt(thd);
di->group_count=0;
mysql_audit_release(thd);
- pthread_mutex_lock(&di->mutex);
+ MYSQL_MUTEX_LOCK(&di->mutex);
}
if (di->tables_in_use)
- pthread_cond_broadcast(&di->cond_client); // If waiting clients
+ MYSQL_COND_BROADCAST(&di->cond_client); // If waiting clients
}
err:
@@ -2540,14 +2546,14 @@ end:
di->table=0;
di->dead= 1; // If error
thd->killed= THD::KILL_CONNECTION; // If error
- pthread_cond_broadcast(&di->cond_client); // Safety
- pthread_mutex_unlock(&di->mutex);
+ MYSQL_COND_BROADCAST(&di->cond_client); // Safety
+ MYSQL_MUTEX_UNLOCK(&di->mutex);
- pthread_mutex_lock(&LOCK_delayed_create); // Because of delayed_get_table
- pthread_mutex_lock(&LOCK_delayed_insert);
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_create); // Because of delayed_get_table
+ MYSQL_MUTEX_LOCK(&LOCK_delayed_insert);
delete di;
- pthread_mutex_unlock(&LOCK_delayed_insert);
- pthread_mutex_unlock(&LOCK_delayed_create);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_insert);
+ MYSQL_MUTEX_UNLOCK(&LOCK_delayed_create);
my_thread_end();
pthread_exit(0);
@@ -2593,7 +2599,7 @@ bool Delayed_insert::handle_inserts(void
DBUG_ENTER("handle_inserts");
/* Allow client to insert new rows */
- pthread_mutex_unlock(&mutex);
+ MYSQL_MUTEX_UNLOCK(&mutex);
table->next_number_field=table->found_next_number_field;
table->use_all_columns();
@@ -2621,12 +2627,12 @@ bool Delayed_insert::handle_inserts(void
*/
if (!using_bin_log)
table->file->extra(HA_EXTRA_WRITE_CACHE);
- pthread_mutex_lock(&mutex);
+ MYSQL_MUTEX_LOCK(&mutex);
while ((row=rows.get()))
{
stacked_inserts--;
- pthread_mutex_unlock(&mutex);
+ MYSQL_MUTEX_UNLOCK(&mutex);
memcpy(table->record[0],row->record,table->s->reclength);
thd.start_time=row->start_time;
@@ -2727,7 +2733,7 @@ bool Delayed_insert::handle_inserts(void
free_delayed_insert_blobs(table);
thread_safe_decrement(delayed_rows_in_use,&LOCK_delayed_status);
thread_safe_increment(delayed_insert_writes,&LOCK_delayed_status);
- pthread_mutex_lock(&mutex);
+ MYSQL_MUTEX_LOCK(&mutex);
delete row;
/*
@@ -2743,9 +2749,9 @@ bool Delayed_insert::handle_inserts(void
if (stacked_inserts || tables_in_use) // Let these wait a while
{
if (tables_in_use)
- pthread_cond_broadcast(&cond_client); // If waiting clients
+ MYSQL_COND_BROADCAST(&cond_client); // If waiting clients
thd_proc_info(&thd, "reschedule");
- pthread_mutex_unlock(&mutex);
+ MYSQL_MUTEX_UNLOCK(&mutex);
if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
{
/* This should never happen */
@@ -2763,15 +2769,15 @@ bool Delayed_insert::handle_inserts(void
}
if (!using_bin_log)
table->file->extra(HA_EXTRA_WRITE_CACHE);
- pthread_mutex_lock(&mutex);
+ MYSQL_MUTEX_LOCK(&mutex);
thd_proc_info(&thd, "insert");
}
if (tables_in_use)
- pthread_cond_broadcast(&cond_client); // If waiting clients
+ MYSQL_COND_BROADCAST(&cond_client); // If waiting clients
}
}
thd_proc_info(&thd, 0);
- pthread_mutex_unlock(&mutex);
+ MYSQL_MUTEX_UNLOCK(&mutex);
/*
We need to flush the pending event when using row-based
@@ -2796,7 +2802,7 @@ bool Delayed_insert::handle_inserts(void
goto err;
}
query_cache_invalidate3(&thd, table, 1);
- pthread_mutex_lock(&mutex);
+ MYSQL_MUTEX_LOCK(&mutex);
DBUG_RETURN(0);
err:
@@ -2815,7 +2821,7 @@ bool Delayed_insert::handle_inserts(void
}
DBUG_PRINT("error", ("dropped %lu rows after an error", max_rows));
thread_safe_increment(delayed_insert_errors, &LOCK_delayed_status);
- pthread_mutex_lock(&mutex);
+ MYSQL_MUTEX_LOCK(&mutex);
DBUG_RETURN(1);
}
#endif /* EMBEDDED_LIBRARY */
@@ -3482,11 +3488,11 @@ static TABLE *create_table_from_items(TH
if (open_table(thd, create_table, thd->mem_root, &ot_action_unused,
MYSQL_OPEN_REOPEN))
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
quick_rm_table(create_info->db_type, create_table->db,
table_case_name(create_info, create_table->table_name),
0);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
else
table= create_table->table;
=== modified file 'sql/sql_manager.cc'
--- a/sql/sql_manager.cc 2007-05-10 09:59:39 +0000
+++ b/sql/sql_manager.cc 2008-10-10 20:34:55 +0000
@@ -27,8 +27,8 @@ ulong volatile manager_status;
bool volatile manager_thread_in_use;
pthread_t manager_thread;
-pthread_mutex_t LOCK_manager;
-pthread_cond_t COND_manager;
+mysql_mutex_t LOCK_manager;
+mysql_cond_t COND_manager;
struct handler_cb {
struct handler_cb *next;
@@ -41,7 +41,7 @@ bool mysql_manager_submit(void (*action)
{
bool result= FALSE;
struct handler_cb * volatile *cb;
- pthread_mutex_lock(&LOCK_manager);
+ MYSQL_MUTEX_LOCK(&LOCK_manager);
cb= &cb_list;
while (*cb && (*cb)->action != action)
cb= &(*cb)->next;
@@ -56,7 +56,7 @@ bool mysql_manager_submit(void (*action)
(*cb)->action= action;
}
}
- pthread_mutex_unlock(&LOCK_manager);
+ MYSQL_MUTEX_UNLOCK(&LOCK_manager);
return result;
}
@@ -77,7 +77,7 @@ pthread_handler_t handle_manager(void *a
for (;;)
{
- pthread_mutex_lock(&LOCK_manager);
+ MYSQL_MUTEX_LOCK(&LOCK_manager);
/* XXX: This will need to be made more general to handle different
* polling needs. */
if (flush_time)
@@ -88,12 +88,12 @@ pthread_handler_t handle_manager(void *a
reset_flush_time = FALSE;
}
while (!manager_status && (!error || error == EINTR) && !abort_loop)
- error= pthread_cond_timedwait(&COND_manager, &LOCK_manager, &abstime);
+ error= MYSQL_COND_TIMEDWAIT(&COND_manager, &LOCK_manager, &abstime);
}
else
{
while (!manager_status && (!error || error == EINTR) && !abort_loop)
- error= pthread_cond_wait(&COND_manager, &LOCK_manager);
+ error= MYSQL_COND_WAIT(&COND_manager, &LOCK_manager);
}
status = manager_status;
manager_status = 0;
@@ -102,7 +102,7 @@ pthread_handler_t handle_manager(void *a
cb= cb_list;
cb_list= NULL;
}
- pthread_mutex_unlock(&LOCK_manager);
+ MYSQL_MUTEX_UNLOCK(&LOCK_manager);
if (abort_loop)
break;
=== modified file 'sql/sql_map.cc'
--- a/sql/sql_map.cc 2008-04-09 00:56:49 +0000
+++ b/sql/sql_map.cc 2008-10-10 20:34:55 +0000
@@ -85,7 +85,7 @@ static I_List<mapped_files> maps_in_use;
mapped_files *map_file(const char * name,uchar *magic,uint magic_length)
{
#ifdef HAVE_MMAP
- pthread_mutex_lock(&LOCK_mapped_file);
+ MYSQL_MUTEX_LOCK(&LOCK_mapped_file);
I_List_iterator<mapped_files> list(maps_in_use);
mapped_files *map;
char path[FN_REFLEN];
@@ -108,7 +108,7 @@ mapped_files *map_file(const char * name
if (!map->map)
my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error);
}
- pthread_mutex_unlock(&LOCK_mapped_file);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mapped_file);
return map;
#else
return NULL;
@@ -122,10 +122,10 @@ mapped_files *map_file(const char * name
void unmap_file(mapped_files *map)
{
#ifdef HAVE_MMAP
- pthread_mutex_lock(&LOCK_mapped_file);
+ MYSQL_MUTEX_LOCK(&LOCK_mapped_file);
if (!map->use_count--)
delete map;
- pthread_mutex_unlock(&LOCK_mapped_file);
+ MYSQL_MUTEX_UNLOCK(&LOCK_mapped_file);
#endif
}
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2008-09-16 08:34:30 +0000
+++ b/sql/sql_parse.cc 2008-10-10 20:34:55 +0000
@@ -350,7 +350,7 @@ bool is_log_table_write_query(enum enum_
}
void execute_init_command(THD *thd, sys_var_str *init_command_var,
- rw_lock_t *var_mutex)
+ mysql_rwlock_t *var_mutex)
{
Vio* save_vio;
ulong save_client_capabilities;
@@ -367,7 +367,7 @@ void execute_init_command(THD *thd, sys_
during execution of init_command_var query
values of init_command_var can't be changed
*/
- rw_rdlock(var_mutex);
+ MYSQL_RWLOCK_RDLOCK(var_mutex);
save_client_capabilities= thd->client_capabilities;
thd->client_capabilities|= CLIENT_MULTI_QUERIES;
/*
@@ -379,7 +379,7 @@ void execute_init_command(THD *thd, sys_
dispatch_command(COM_QUERY, thd,
init_command_var->value,
init_command_var->value_length);
- rw_unlock(var_mutex);
+ MYSQL_RWLOCK_UNLOCK(var_mutex);
thd->client_capabilities= save_client_capabilities;
thd->net.vio= save_vio;
@@ -510,10 +510,10 @@ end:
delete thd;
#ifndef EMBEDDED_LIBRARY
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ (void) MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thread_count--;
- (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);
my_thread_end();
pthread_exit(0);
#endif
@@ -802,12 +802,12 @@ bool dispatch_command(enum enum_server_c
thd->enable_slow_log= TRUE;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
thd->set_time();
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query_id= global_query_id;
if (!(server_command_flags[command] & CF_SKIP_QUERY_ID))
next_query_id();
thread_running++;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (!(server_command_flags[command] & CF_SKIP_QUESTIONS))
statistic_increment(thd->status_var.questions, &LOCK_status);
@@ -1031,7 +1031,7 @@ bool dispatch_command(enum enum_server_c
thd->profiling.set_query_source(beginning_of_next_stmt, length);
#endif
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query_length= length;
thd->query= beginning_of_next_stmt;
/*
@@ -1041,7 +1041,7 @@ bool dispatch_command(enum enum_server_c
thd->query_id= next_query_id();
thd->set_time(); /* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
mysql_parse(thd, beginning_of_next_stmt, length, &end_of_stmt);
}
@@ -1405,13 +1405,13 @@ bool dispatch_command(enum enum_server_c
log_slow_statement(thd);
thd_proc_info(thd, "cleaning up");
- pthread_mutex_lock(&LOCK_thread_count); // For process list
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count); // For process list
thd_proc_info(thd, 0);
thd->command=COM_SLEEP;
thd->query=0;
thd->query_length=0;
thread_running--;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
@@ -1992,11 +1992,11 @@ mysql_execute_command(THD *thd)
restore status variables, as we don't want 'show status' to cause
changes
*/
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
add_diff_to_status(&global_status_var, &thd->status_var,
&old_status_var);
thd->status_var= old_status_var;
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
break;
}
case SQLCOM_SHOW_DATABASES:
@@ -2232,9 +2232,9 @@ mysql_execute_command(THD *thd)
{
if (check_global_access(thd, SUPER_ACL))
goto error;
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
res = change_master(thd,active_mi);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
break;
}
case SQLCOM_SHOW_SLAVE_STAT:
@@ -2242,7 +2242,7 @@ mysql_execute_command(THD *thd)
/* Accept one of two privileges */
if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL))
goto error;
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
if (active_mi != NULL)
{
res = show_master_info(thd, active_mi);
@@ -2253,7 +2253,7 @@ mysql_execute_command(THD *thd)
"the master info structure does not exist");
my_ok(thd);
}
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
break;
}
case SQLCOM_SHOW_MASTER_STAT:
@@ -2528,9 +2528,9 @@ ddl_blocker_err:
#ifdef HAVE_REPLICATION
case SQLCOM_SLAVE_START:
{
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
start_slave(thd,active_mi,1 /* net report*/);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
break;
}
case SQLCOM_SLAVE_STOP:
@@ -2555,9 +2555,9 @@ ddl_blocker_err:
goto error;
}
{
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
stop_slave(thd,active_mi,1/* net report*/);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
break;
}
#endif /* HAVE_REPLICATION */
@@ -6452,9 +6452,9 @@ bool reload_acl_and_cache(THD *thd, ulon
mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
}
#ifdef HAVE_REPLICATION
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
rotate_relay_log(active_mi);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
#endif
/* flush slow and general logs */
@@ -6582,10 +6582,10 @@ bool reload_acl_and_cache(THD *thd, ulon
if (options & REFRESH_SLAVE)
{
tmp_write_to_binlog= 0;
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
if (reset_slave(thd, active_mi))
result=1;
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
}
#endif
if (options & REFRESH_USER_RESOURCES)
@@ -6612,7 +6612,7 @@ uint kill_one_thread(THD *thd, ulong id,
uint error=ER_NO_SUCH_THREAD;
DBUG_ENTER("kill_one_thread");
DBUG_PRINT("enter", ("id=%lu only_kill=%d", id, only_kill_query));
- 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++))
{
@@ -6620,11 +6620,11 @@ uint kill_one_thread(THD *thd, ulong id,
continue;
if (tmp->thread_id == id)
{
- pthread_mutex_lock(&tmp->LOCK_delete); // Lock from delete
+ MYSQL_MUTEX_LOCK(&tmp->LOCK_delete); // Lock from delete
break;
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (tmp)
{
if ((thd->security_ctx->master_access & SUPER_ACL) ||
@@ -6635,7 +6635,7 @@ uint kill_one_thread(THD *thd, ulong id,
}
else
error=ER_KILL_DENIED_ERROR;
- pthread_mutex_unlock(&tmp->LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&tmp->LOCK_delete);
}
DBUG_PRINT("exit", ("%d", error));
DBUG_RETURN(error);
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2008-09-04 18:30:34 +0000
+++ b/sql/sql_partition.cc 2008-10-10 20:34:55 +0000
@@ -5481,7 +5481,7 @@ static bool write_log_drop_shadow_frm(AL
DBUG_ENTER("write_log_drop_shadow_frm");
build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, NULL,
(const char*)shadow_path, FALSE))
goto error;
@@ -5489,13 +5489,13 @@ static bool write_log_drop_shadow_frm(AL
if (write_execute_ddl_log_entry(log_entry->entry_pos,
FALSE, &exec_log_entry))
goto error;
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
set_part_info_exec_log_entry(part_info, exec_log_entry);
DBUG_RETURN(FALSE);
error:
release_part_info_log_entries(part_info->first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->first_log_entry= NULL;
my_error(ER_DDL_LOG_ERROR, MYF(0));
DBUG_RETURN(TRUE);
@@ -5529,7 +5529,7 @@ static bool write_log_rename_frm(ALTER_P
build_table_filename(path, sizeof(path), lpt->db,
lpt->table_name, "", 0);
build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE))
goto error;
log_entry= part_info->first_log_entry;
@@ -5538,12 +5538,12 @@ static bool write_log_rename_frm(ALTER_P
FALSE, &exec_log_entry))
goto error;
release_part_info_log_entries(old_first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
DBUG_RETURN(FALSE);
error:
release_part_info_log_entries(part_info->first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->first_log_entry= old_first_log_entry;
part_info->frm_log_entry= NULL;
my_error(ER_DDL_LOG_ERROR, MYF(0));
@@ -5582,7 +5582,7 @@ static bool write_log_drop_partition(ALT
lpt->table_name, "", 0);
build_table_filename(tmp_path, sizeof(tmp_path), lpt->db,
lpt->table_name, "#", 0);
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
FALSE))
goto error;
@@ -5595,12 +5595,12 @@ static bool write_log_drop_partition(ALT
FALSE, &exec_log_entry))
goto error;
release_part_info_log_entries(old_first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
DBUG_RETURN(FALSE);
error:
release_part_info_log_entries(part_info->first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->first_log_entry= old_first_log_entry;
part_info->frm_log_entry= NULL;
my_error(ER_DDL_LOG_ERROR, MYF(0));
@@ -5639,7 +5639,7 @@ static bool write_log_add_change_partiti
lpt->table_name, "", 0);
build_table_filename(tmp_path, sizeof(tmp_path), lpt->db,
lpt->table_name, "#", 0);
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
FALSE))
goto error;
@@ -5650,13 +5650,13 @@ static bool write_log_add_change_partiti
if (write_execute_ddl_log_entry(log_entry->entry_pos,
FALSE, &exec_log_entry))
goto error;
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
set_part_info_exec_log_entry(part_info, exec_log_entry);
DBUG_RETURN(FALSE);
error:
release_part_info_log_entries(part_info->first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->first_log_entry= NULL;
my_error(ER_DDL_LOG_ERROR, MYF(0));
DBUG_RETURN(TRUE);
@@ -5694,7 +5694,7 @@ static bool write_log_final_change_parti
build_table_filename(path, sizeof(path), lpt->db,
lpt->table_name, "", 0);
build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION))
goto error;
@@ -5708,12 +5708,12 @@ static bool write_log_final_change_parti
FALSE, &exec_log_entry))
goto error;
release_part_info_log_entries(old_first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
DBUG_RETURN(FALSE);
error:
release_part_info_log_entries(part_info->first_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->first_log_entry= old_first_log_entry;
part_info->frm_log_entry= NULL;
my_error(ER_DDL_LOG_ERROR, MYF(0));
@@ -5740,7 +5740,7 @@ static void write_log_completed(ALTER_PA
DBUG_ENTER("write_log_completed");
DBUG_ASSERT(log_entry);
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
if (write_execute_ddl_log_entry(0UL, TRUE, &log_entry))
{
/*
@@ -5754,7 +5754,7 @@ static void write_log_completed(ALTER_PA
}
release_part_info_log_entries(part_info->first_log_entry);
release_part_info_log_entries(part_info->exec_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->exec_log_entry= NULL;
part_info->first_log_entry= NULL;
DBUG_VOID_RETURN;
@@ -5772,10 +5772,10 @@ static void write_log_completed(ALTER_PA
static void release_log_entries(partition_info *part_info)
{
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
release_part_info_log_entries(part_info->first_log_entry);
release_part_info_log_entries(part_info->exec_log_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
part_info->first_log_entry= NULL;
part_info->exec_log_entry= NULL;
}
@@ -5820,7 +5820,7 @@ static int alter_close_tables(ALTER_PART
We must keep LOCK_open while manipulating with thd->open_tables.
Another thread may be working on it.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
/*
We can safely remove locks for all tables with the same name:
later they will all be closed anyway in
@@ -5843,7 +5843,7 @@ static int alter_close_tables(ALTER_PART
table->s->version= 0;
}
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(0);
}
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc 2008-08-19 15:58:48 +0000
+++ b/sql/sql_plugin.cc 2008-10-10 20:34:55 +0000
@@ -108,7 +108,11 @@ static bool initialized= 0;
following variables/structures.
We are always manipulating ref count, so a rwlock here is unneccessary.
*/
-pthread_mutex_t LOCK_plugin;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_plugin;
+#endif
+
+mysql_mutex_t LOCK_plugin;
static DYNAMIC_ARRAY plugin_dl_array;
static DYNAMIC_ARRAY plugin_array;
static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
@@ -532,7 +536,7 @@ static void plugin_dl_del(const LEX_STRI
uint i;
DBUG_ENTER("plugin_dl_del");
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
for (i= 0; i < plugin_dl_array.elements; i++)
{
@@ -564,7 +568,7 @@ static struct st_plugin_int *plugin_find
if (! initialized)
DBUG_RETURN(0);
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
if (type == MYSQL_ANY_PLUGIN)
{
@@ -588,14 +592,14 @@ static SHOW_COMP_OPTION plugin_status(co
SHOW_COMP_OPTION rc= SHOW_OPTION_NO;
struct st_plugin_int *plugin;
DBUG_ENTER("plugin_is_ready");
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
if ((plugin= plugin_find_internal(name, type)))
{
rc= SHOW_OPTION_DISABLED;
if (plugin->state == PLUGIN_IS_READY)
rc= SHOW_OPTION_YES;
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(rc);
}
@@ -621,7 +625,7 @@ static plugin_ref intern_plugin_lock(LEX
st_plugin_int *pi= plugin_ref_to_int(rc);
DBUG_ENTER("intern_plugin_lock");
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
if (pi->state & (PLUGIN_IS_READY | PLUGIN_IS_UNINITIALIZED))
{
@@ -660,9 +664,9 @@ plugin_ref plugin_lock(THD *thd, plugin_
LEX *lex= thd ? thd->lex : 0;
plugin_ref rc;
DBUG_ENTER("plugin_lock");
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
rc= my_intern_plugin_lock_ci(lex, *ptr);
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(rc);
}
@@ -674,10 +678,10 @@ plugin_ref plugin_lock_by_name(THD *thd,
plugin_ref rc= NULL;
st_plugin_int *plugin;
DBUG_ENTER("plugin_lock_by_name");
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
if ((plugin= plugin_find_internal(name, type)))
rc= my_intern_plugin_lock_ci(lex, plugin_int_to_ref(plugin));
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(rc);
}
@@ -797,7 +801,7 @@ static void plugin_deinitialize(struct s
deinitialization to deadlock if plugins have worker threads
with plugin locks
*/
- safe_mutex_assert_not_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_plugin);
if (plugin->plugin->status_vars)
{
@@ -851,7 +855,7 @@ static void plugin_deinitialize(struct s
static void plugin_del(struct st_plugin_int *plugin)
{
DBUG_ENTER("plugin_del(plugin)");
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
/* Free allocated strings before deleting the plugin. */
plugin_vars_free_values(plugin->system_vars);
hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin);
@@ -859,9 +863,9 @@ static void plugin_del(struct st_plugin_
plugin_dl_del(&plugin->plugin_dl->dl);
plugin->state= PLUGIN_IS_FREED;
plugin_array_version++;
- rw_wrlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_system_variables_hash);
mysql_del_sys_var_chain(plugin->system_vars);
- rw_unlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
free_root(&plugin->mem_root, MYF(0));
DBUG_VOID_RETURN;
}
@@ -884,7 +888,7 @@ static void reap_plugins(void)
uint count, idx;
struct st_plugin_int *plugin, **reap, **list;
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
if (!reap_needed)
return;
@@ -905,13 +909,13 @@ static void reap_plugins(void)
}
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
list= reap;
while ((plugin= *(--list)))
plugin_deinitialize(plugin, true);
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
while ((plugin= *(--reap)))
plugin_del(plugin);
@@ -925,7 +929,7 @@ static void intern_plugin_unlock(LEX *le
st_plugin_int *pi;
DBUG_ENTER("intern_plugin_unlock");
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
if (!plugin)
DBUG_VOID_RETURN;
@@ -978,10 +982,10 @@ void plugin_unlock(THD *thd, plugin_ref
if (!plugin_dlib(plugin))
DBUG_VOID_RETURN;
#endif
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
intern_plugin_unlock(lex, plugin);
reap_plugins();
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_VOID_RETURN;
}
@@ -991,11 +995,11 @@ void plugin_unlock_list(THD *thd, plugin
LEX *lex= thd ? thd->lex : 0;
DBUG_ENTER("plugin_unlock_list");
DBUG_ASSERT(list);
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
while (count--)
intern_plugin_unlock(lex, *list++);
reap_plugins();
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_VOID_RETURN;
}
@@ -1004,7 +1008,7 @@ static int plugin_initialize(struct st_p
{
DBUG_ENTER("plugin_initialize");
- safe_mutex_assert_owner(&LOCK_plugin);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_plugin);
if (plugin_type_initialize[plugin->plugin->type])
{
@@ -1120,7 +1124,7 @@ int plugin_init(int *argc, char **argv,
goto err;
- pthread_mutex_init(&LOCK_plugin, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_plugin, key_LOCK_plugin, MY_MUTEX_INIT_FAST);
if (my_init_dynamic_array(&plugin_dl_array,
sizeof(struct st_plugin_dl *),16,16) ||
@@ -1135,7 +1139,7 @@ int plugin_init(int *argc, char **argv,
goto err;
}
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
initialized= 1;
@@ -1188,7 +1192,7 @@ int plugin_init(int *argc, char **argv,
/* should now be set to MyISAM storage engine */
DBUG_ASSERT(global_system_variables.table_plugin);
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
/* Register all dynamic plugins */
if (!(flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING))
@@ -1206,7 +1210,7 @@ int plugin_init(int *argc, char **argv,
Now we initialize all remaining plugins
*/
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
reap= (st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*));
*(reap++)= NULL;
@@ -1228,13 +1232,13 @@ int plugin_init(int *argc, char **argv,
*/
while ((plugin_ptr= *(--reap)))
{
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
plugin_deinitialize(plugin_ptr, true);
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
plugin_del(plugin_ptr);
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
my_afree(reap);
end:
@@ -1243,7 +1247,7 @@ end:
DBUG_RETURN(0);
err_unlock:
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
err:
free_root(&tmp_root, MYF(0));
DBUG_RETURN(1);
@@ -1300,8 +1304,8 @@ bool plugin_register_builtin(THD *thd, s
tmp.name.str= (char *)plugin->name;
tmp.name.length= strlen(plugin->name);
- pthread_mutex_lock(&LOCK_plugin);
- rw_wrlock(&LOCK_system_variables_hash);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_system_variables_hash);
if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL, true))
goto end;
@@ -1310,8 +1314,8 @@ bool plugin_register_builtin(THD *thd, s
mysql_del_sys_var_chain(tmp.system_vars);
end:
- rw_unlock(&LOCK_system_variables_hash);
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(result);;
}
@@ -1351,10 +1355,10 @@ static void plugin_load(MEM_ROOT *tmp_ro
When building an embedded library, if the mysql.plugin table
does not exist, we silently ignore the missing table
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (check_if_table_exists(new_thd, &tables, &table_exists))
table_exists= FALSE;
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (!table_exists)
goto end;
#endif /* EMBEDDED_LIBRARY */
@@ -1372,10 +1376,10 @@ static void plugin_load(MEM_ROOT *tmp_ro
/*
there're no other threads running yet, so we don't need a mutex.
but plugin_add() before is designed to work in multi-threaded
- environment, and it uses safe_mutex_assert_owner(), so we lock
+ environment, and it uses MYSQL_MUTEX_ASSERT_OWNER(), so we lock
the mutex here to satisfy the assert
*/
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
while (!(error= read_record_info.read_record(&read_record_info)))
{
DBUG_PRINT("info", ("init plugin record"));
@@ -1391,7 +1395,7 @@ static void plugin_load(MEM_ROOT *tmp_ro
str_name.c_ptr(), str_dl.c_ptr());
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
if (error > 0)
sql_print_error(ER(ER_GET_ERRNO), my_errno);
end_read_record(&read_record_info);
@@ -1442,7 +1446,7 @@ static bool plugin_load_list(MEM_ROOT *t
}
dl= name;
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
if ((plugin_dl= plugin_dl_add(&dl, REPORT_TO_LOG)))
{
for (plugin= plugin_dl->plugins; plugin->info; plugin++)
@@ -1460,11 +1464,11 @@ static bool plugin_load_list(MEM_ROOT *t
else
{
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
if (plugin_add(tmp_root, &name, &dl, argc, argv, REPORT_TO_LOG))
goto error;
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
name.length= dl.length= 0;
dl.str= NULL; name.str= p= buffer;
str= &name;
@@ -1485,7 +1489,7 @@ static bool plugin_load_list(MEM_ROOT *t
}
DBUG_RETURN(FALSE);
error:
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
sql_print_error("Couldn't load plugin named '%s' with soname '%s'.",
name.str, dl.str);
DBUG_RETURN(TRUE);
@@ -1501,7 +1505,7 @@ void plugin_shutdown(void)
if (initialized)
{
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
reap_needed= true;
@@ -1554,7 +1558,7 @@ void plugin_shutdown(void)
if (plugins[i]->state == PLUGIN_IS_DELETED)
plugins[i]->state= PLUGIN_IS_DYING;
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
/*
We loop through all plugins and call deinit() if they have one.
@@ -1574,9 +1578,9 @@ void plugin_shutdown(void)
/*
It's perfectly safe not to lock LOCK_plugin, as there're no
concurrent threads anymore. But some functions called from here
- use safe_mutex_assert_owner(), so we lock the mutex to satisfy it
+ use MYSQL_MUTEX_ASSERT_OWNER(), so we lock the mutex to satisfy it
*/
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
/*
We defer checking ref_counts until after all plugins are deinitialized
@@ -1597,10 +1601,10 @@ void plugin_shutdown(void)
cleanup_variables(NULL, &global_system_variables);
cleanup_variables(NULL, &max_system_variables);
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
initialized= 0;
- pthread_mutex_destroy(&LOCK_plugin);
+ MYSQL_MUTEX_DESTROY(&LOCK_plugin);
my_afree(plugins);
}
@@ -1650,14 +1654,14 @@ bool mysql_install_plugin(THD *thd, cons
if (! (table = open_ltable(thd, &tables, TL_WRITE, 0)))
DBUG_RETURN(TRUE);
- pthread_mutex_lock(&LOCK_plugin);
- rw_wrlock(&LOCK_system_variables_hash);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
+ MYSQL_RWLOCK_WRLOCK(&LOCK_system_variables_hash);
/* handle_options() assumes arg0 (program name) always exists */
argv[0]= const_cast<char*>(""); // without a cast gcc emits a warning
argv[1]= 0;
argc= 1;
error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER);
- rw_unlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
if (error || !(tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
goto err;
@@ -1687,14 +1691,14 @@ bool mysql_install_plugin(THD *thd, cons
goto deinit;
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(FALSE);
deinit:
tmp->state= PLUGIN_IS_DELETED;
reap_needed= true;
reap_plugins();
err:
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(TRUE);
}
@@ -1715,7 +1719,7 @@ bool mysql_uninstall_plugin(THD *thd, co
if (! (table= open_ltable(thd, &tables, TL_WRITE, 0)))
DBUG_RETURN(TRUE);
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
if (!(plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
{
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
@@ -1736,7 +1740,7 @@ bool mysql_uninstall_plugin(THD *thd, co
else
reap_needed= true;
reap_plugins();
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
table->use_all_columns();
table->field[0]->store(name->str, name->length, system_charset_info);
@@ -1762,7 +1766,7 @@ bool mysql_uninstall_plugin(THD *thd, co
}
DBUG_RETURN(FALSE);
err:
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_RETURN(TRUE);
}
@@ -1780,7 +1784,7 @@ bool plugin_foreach_with_mask(THD *thd,
state_mask= ~state_mask; // do it only once
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
total= type == MYSQL_ANY_PLUGIN ? plugin_array.elements
: plugin_hash[type].records;
/*
@@ -1805,17 +1809,17 @@ bool plugin_foreach_with_mask(THD *thd,
plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
}
}
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
for (idx= 0; idx < total; idx++)
{
if (unlikely(version != plugin_array_version))
{
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
for (uint i=idx; i < total; i++)
if (plugins[i] && plugins[i]->state & state_mask)
plugins[i]=0;
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
}
plugin= plugins[idx];
/* It will stop iterating on first engine error when "func" returns TRUE */
@@ -2136,12 +2140,12 @@ sys_var *find_sys_var(THD *thd, const ch
plugin_ref plugin;
DBUG_ENTER("find_sys_var");
- pthread_mutex_lock(&LOCK_plugin);
- rw_rdlock(&LOCK_system_variables_hash);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_system_variables_hash);
if ((var= intern_find_sys_var(str, length, false)) &&
(pi= var->cast_pluginvar()))
{
- rw_unlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
LEX *lex= thd ? thd->lex : 0;
if (!(plugin= my_intern_plugin_lock(lex, plugin_int_to_ref(pi->plugin))))
var= NULL; /* failed to lock it, it must be uninstalling */
@@ -2154,8 +2158,8 @@ sys_var *find_sys_var(THD *thd, const ch
}
}
else
- rw_unlock(&LOCK_system_variables_hash);
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
/*
If the variable exists but the plugin it is associated with is not ready
@@ -2334,7 +2338,7 @@ static uchar *intern_sys_var_ptr(THD* th
{
uint idx;
- rw_rdlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_system_variables_hash);
thd->variables.dynamic_variables_ptr= (char*)
my_realloc(thd->variables.dynamic_variables_ptr,
@@ -2342,9 +2346,9 @@ static uchar *intern_sys_var_ptr(THD* th
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
if (global_lock)
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
- safe_mutex_assert_owner(&LOCK_global_system_variables);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_global_system_variables);
memcpy(thd->variables.dynamic_variables_ptr +
thd->variables.dynamic_variables_size,
@@ -2383,7 +2387,7 @@ static uchar *intern_sys_var_ptr(THD* th
}
if (global_lock)
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
thd->variables.dynamic_variables_version=
global_system_variables.dynamic_variables_version;
@@ -2392,7 +2396,7 @@ static uchar *intern_sys_var_ptr(THD* th
thd->variables.dynamic_variables_size=
global_system_variables.dynamic_variables_size;
- rw_unlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
}
return (uchar*)thd->variables.dynamic_variables_ptr + offset;
}
@@ -2419,11 +2423,11 @@ void plugin_thdvar_init(THD *thd)
thd->variables.dynamic_variables_size= 0;
thd->variables.dynamic_variables_ptr= 0;
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
thd->variables.table_plugin=
my_intern_plugin_lock(NULL, global_system_variables.table_plugin);
intern_plugin_unlock(NULL, old_table_plugin);
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
DBUG_VOID_RETURN;
}
@@ -2452,7 +2456,7 @@ static void cleanup_variables(THD *thd,
int flags;
uint idx;
- rw_rdlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_system_variables_hash);
for (idx= 0; idx < bookmark_hash.records; idx++)
{
v= (st_bookmark*) hash_element(&bookmark_hash, idx);
@@ -2472,7 +2476,7 @@ static void cleanup_variables(THD *thd,
*ptr= NULL;
}
}
- rw_unlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
DBUG_ASSERT(vars->table_plugin == NULL);
@@ -2489,7 +2493,7 @@ void plugin_thdvar_cleanup(THD *thd)
plugin_ref *list;
DBUG_ENTER("plugin_thdvar_cleanup");
- pthread_mutex_lock(&LOCK_plugin);
+ MYSQL_MUTEX_LOCK(&LOCK_plugin);
unlock_variables(thd, &thd->variables);
cleanup_variables(thd, &thd->variables);
@@ -2503,7 +2507,7 @@ void plugin_thdvar_cleanup(THD *thd)
}
reap_plugins();
- pthread_mutex_unlock(&LOCK_plugin);
+ MYSQL_MUTEX_UNLOCK(&LOCK_plugin);
reset_dynamic(&thd->lex->plugins);
@@ -2677,7 +2681,7 @@ void sys_var_pluginvar::set_default(THD
if (is_readonly())
return;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
tgt= real_value_ptr(thd, type);
src= ((void **) (plugin_var + 1) + 1);
@@ -2720,11 +2724,11 @@ void sys_var_pluginvar::set_default(THD
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || type == OPT_GLOBAL)
{
plugin_var->update(thd, plugin_var, tgt, src);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
{
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
plugin_var->update(thd, plugin_var, tgt, src);
}
}
@@ -2743,18 +2747,18 @@ bool sys_var_pluginvar::update(THD *thd,
if (is_readonly())
return 1;
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
tgt= real_value_ptr(thd, var->type);
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || var->type == OPT_GLOBAL)
{
/* variable we are updating has global scope, so we unlock after updating */
plugin_var->update(thd, plugin_var, tgt, &var->save_result);
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
}
else
{
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
plugin_var->update(thd, plugin_var, tgt, &var->save_result);
}
return 0;
=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc 2008-06-11 04:33:36 +0000
+++ b/sql/sql_rename.cc 2008-10-10 20:34:55 +0000
@@ -136,7 +136,7 @@ bool mysql_rename_tables(THD *thd, TABLE
if (lock_table_names(thd, table_list))
goto err;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (ren_table= table_list; ren_table; ren_table= ren_table->next_local)
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, ren_table->db,
@@ -174,7 +174,7 @@ bool mysql_rename_tables(THD *thd, TABLE
higher concurrency - query_cache_invalidate can take minutes to
complete.
*/
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/* Lets hope this doesn't fail as the result will be messy */
if (!silent && !error)
=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc 2008-09-04 18:30:34 +0000
+++ b/sql/sql_repl.cc 2008-10-10 20:34:55 +0000
@@ -178,7 +178,7 @@ void adjust_linfo_offsets(my_off_t purge
{
THD *tmp;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
I_List_iterator<THD> it(threads);
while ((tmp=it++))
@@ -186,7 +186,7 @@ void adjust_linfo_offsets(my_off_t purge
LOG_INFO* linfo;
if ((linfo = tmp->current_linfo))
{
- pthread_mutex_lock(&linfo->lock);
+ MYSQL_MUTEX_LOCK(&linfo->lock);
/*
Index file offset can be less that purge offset only if
we just started reading the index file. In that case
@@ -196,10 +196,10 @@ void adjust_linfo_offsets(my_off_t purge
linfo->fatal = (linfo->index_file_offset != 0);
else
linfo->index_file_offset -= purge_offset;
- pthread_mutex_unlock(&linfo->lock);
+ MYSQL_MUTEX_UNLOCK(&linfo->lock);
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
}
@@ -209,7 +209,7 @@ bool log_in_use(const char* log_name)
THD *tmp;
bool result = 0;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
I_List_iterator<THD> it(threads);
while ((tmp=it++))
@@ -217,16 +217,16 @@ bool log_in_use(const char* log_name)
LOG_INFO* linfo;
if ((linfo = tmp->current_linfo))
{
- pthread_mutex_lock(&linfo->lock);
+ MYSQL_MUTEX_LOCK(&linfo->lock);
result = !bcmp((uchar*) log_name, (uchar*) linfo->log_file_name,
log_name_len);
- pthread_mutex_unlock(&linfo->lock);
+ MYSQL_MUTEX_UNLOCK(&linfo->lock);
if (result)
break;
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
return result;
}
@@ -398,7 +398,7 @@ void mysql_binlog_send(THD* thd, char* l
int error;
const char *errmsg = "Unknown error";
NET* net = &thd->net;
- pthread_mutex_t *log_lock;
+ mysql_mutex_t *log_lock;
bool binlog_can_be_corrupted= FALSE;
#ifndef DBUG_OFF
int left_events = max_binlog_dump_events;
@@ -460,9 +460,9 @@ void mysql_binlog_send(THD* thd, char* l
goto err;
}
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->current_linfo = &linfo;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0)
{
@@ -710,11 +710,11 @@ impossible position";
has not been updated since last read.
*/
- pthread_mutex_lock(log_lock);
- switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*)0)) {
+ MYSQL_MUTEX_LOCK(log_lock);
+ switch (Log_event::read_log_event(&log, packet, (mysql_mutex_t*)0)) {
case 0:
/* we read successfully, so we'll need to send it to the slave */
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
read_packet = 1;
if (coord)
coord->pos= uint4korr(packet->ptr() + 1 + LOG_POS_OFFSET);
@@ -726,7 +726,7 @@ impossible position";
DBUG_PRINT("wait",("waiting for data in binary log"));
if (thd->server_id==0) // for mysqlbinlog (mysqlbinlog.server_id==0)
{
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
goto end;
}
@@ -757,7 +757,7 @@ impossible position";
{
errmsg = "Failed on my_net_write()";
my_errno= ER_UNKNOWN_ERROR;
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
goto err;
}
}
@@ -767,12 +767,12 @@ impossible position";
DBUG_PRINT("wait",("binary log received update"));
}
} while (ret != 0 && coord != NULL && !thd->killed);
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
}
break;
default:
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
fatal_error = 1;
break;
}
@@ -866,9 +866,9 @@ end:
my_eof(thd);
thd_proc_info(thd, "Waiting to finalize termination");
- 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);
DBUG_VOID_RETURN;
err:
@@ -881,9 +881,9 @@ err:
this mutex will make sure that it never tried to update our linfo
after we return from this stack frame
*/
- 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));
@@ -924,7 +924,7 @@ int start_slave(THD* thd , Master_info*
*/
if (thread_mask & SLAVE_SQL)
{
- pthread_mutex_lock(&mi->rli.data_lock);
+ MYSQL_MUTEX_LOCK(&mi->rli.data_lock);
if (thd->lex->mi.pos)
{
@@ -978,7 +978,7 @@ int start_slave(THD* thd , Master_info*
ER(ER_MISSING_SKIP_SLAVE));
}
- pthread_mutex_unlock(&mi->rli.data_lock);
+ MYSQL_MUTEX_UNLOCK(&mi->rli.data_lock);
}
else if (thd->lex->mi.pos || thd->lex->mi.relay_log_pos)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
@@ -1145,7 +1145,7 @@ err:
Kill all Binlog_dump threads which previously talked to the same slave
("same" means with the same server id). Indeed, if the slave stops, if the
- Binlog_dump thread is waiting (pthread_cond_wait) for binlog update, then it
+ Binlog_dump thread is waiting (MYSQL_COND_WAIT) for binlog update, then it
will keep existing until a query is written to the binlog. If the master is
idle, then this could last long, and if the slave reconnects, we could have 2
Binlog_dump threads in SHOW PROCESSLIST, until a query is written to the
@@ -1163,7 +1163,7 @@ err:
void kill_zombie_dump_threads(uint32 slave_server_id)
{
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
I_List_iterator<THD> it(threads);
THD *tmp;
@@ -1172,11 +1172,11 @@ void kill_zombie_dump_threads(uint32 sla
if (tmp->command == COM_BINLOG_DUMP &&
tmp->server_id == slave_server_id)
{
- pthread_mutex_lock(&tmp->LOCK_delete); // Lock from delete
+ MYSQL_MUTEX_LOCK(&tmp->LOCK_delete); // Lock from delete
break;
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (tmp)
{
/*
@@ -1185,7 +1185,7 @@ void kill_zombie_dump_threads(uint32 sla
again. We just to do kill the thread ourselves.
*/
tmp->awake(THD::KILL_QUERY);
- pthread_mutex_unlock(&tmp->LOCK_delete);
+ MYSQL_MUTEX_UNLOCK(&tmp->LOCK_delete);
}
}
@@ -1386,7 +1386,7 @@ bool change_master(THD* thd, Master_info
if (!mi->rli.group_master_log_name[0]) // uninitialized case
mi->rli.group_master_log_pos=0;
- pthread_mutex_lock(&mi->rli.data_lock);
+ MYSQL_MUTEX_LOCK(&mi->rli.data_lock);
mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */
/* Clear the errors, for a clean start */
mi->rli.clear_error();
@@ -1399,8 +1399,8 @@ bool change_master(THD* thd, Master_info
not exist anymore).
*/
flush_relay_log_info(&mi->rli);
- pthread_cond_broadcast(&mi->data_cond);
- pthread_mutex_unlock(&mi->rli.data_lock);
+ MYSQL_COND_BROADCAST(&mi->data_cond);
+ MYSQL_MUTEX_UNLOCK(&mi->rli.data_lock);
unlock_slave_threads(mi);
thd_proc_info(thd, 0);
@@ -1470,7 +1470,7 @@ bool mysql_show_binlog_events(THD* thd)
my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
char search_file_name[FN_REFLEN], *name;
const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
+ mysql_mutex_t *log_lock = mysql_bin_log.get_log_lock();
LOG_INFO linfo;
Log_event* ev;
@@ -1492,9 +1492,9 @@ bool mysql_show_binlog_events(THD* thd)
goto err;
}
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->current_linfo = &linfo;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
goto err;
@@ -1504,7 +1504,7 @@ bool mysql_show_binlog_events(THD* thd)
*/
thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
- pthread_mutex_lock(log_lock);
+ MYSQL_MUTEX_LOCK(log_lock);
/*
open_binlog() sought to position 4.
@@ -1514,7 +1514,7 @@ bool mysql_show_binlog_events(THD* thd)
This code will fail on a mixed relay log (one which has Format_desc then
Rotate then Format_desc).
*/
- ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
+ ev = Log_event::read_log_event(&log,(mysql_mutex_t*)0,description_event);
if (ev)
{
if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
@@ -1535,7 +1535,7 @@ bool mysql_show_binlog_events(THD* thd)
}
for (event_count = 0;
- (ev = Log_event::read_log_event(&log,(pthread_mutex_t*) 0,
+ (ev = Log_event::read_log_event(&log,(mysql_mutex_t*) 0,
description_event)); )
{
if (event_count >= limit_start &&
@@ -1543,7 +1543,7 @@ bool mysql_show_binlog_events(THD* thd)
{
errmsg = "Net error";
delete ev;
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
goto err;
}
@@ -1557,11 +1557,11 @@ bool mysql_show_binlog_events(THD* thd)
if (event_count < limit_end && log.error)
{
errmsg = "Wrong offset or I/O error";
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
goto err;
}
- pthread_mutex_unlock(log_lock);
+ MYSQL_MUTEX_UNLOCK(log_lock);
}
ret= FALSE;
@@ -1580,9 +1580,9 @@ err:
else
my_eof(thd);
- 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);
DBUG_RETURN(ret);
}
@@ -1657,12 +1657,12 @@ bool show_binlogs(THD* thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
- pthread_mutex_lock(mysql_bin_log.get_log_lock());
+ MYSQL_MUTEX_LOCK(mysql_bin_log.get_log_lock());
mysql_bin_log.lock_index();
index_file=mysql_bin_log.get_index_file();
mysql_bin_log.raw_get_current_log(&cur); // dont take mutex
- pthread_mutex_unlock(mysql_bin_log.get_log_lock()); // lockdep, OK
+ MYSQL_MUTEX_UNLOCK(mysql_bin_log.get_log_lock()); // lockdep, OK
cur_dir_len= dirname_length(cur.log_file_name);
@@ -1790,7 +1790,7 @@ static void fix_slave_net_timeout(THD *t
{
DBUG_ENTER("fix_slave_net_timeout");
#ifdef HAVE_REPLICATION
- pthread_mutex_lock(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
DBUG_PRINT("info",("slave_net_timeout=%lu mi->heartbeat_period=%.3f",
slave_net_timeout,
(active_mi? active_mi->heartbeat_period : 0.0)));
@@ -1801,7 +1801,7 @@ static void fix_slave_net_timeout(THD *t
" exceeds the new value of `slave_net_timeout' sec."
" A sensible value for the period should be"
" less than the timeout.");
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
#endif
DBUG_VOID_RETURN;
}
@@ -1871,15 +1871,15 @@ static int show_slave_skip_errors(THD *t
bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
{
int result= 0;
- pthread_mutex_lock(&LOCK_active_mi);
- pthread_mutex_lock(&active_mi->rli.run_lock);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&active_mi->rli.run_lock);
if (active_mi->rli.slave_running)
{
my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0));
result=1;
}
- pthread_mutex_unlock(&active_mi->rli.run_lock);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&active_mi->rli.run_lock);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
var->save_result.ulong_value= (ulong) var->value->val_int();
return result;
}
@@ -1887,8 +1887,8 @@ bool sys_var_slave_skip_counter::check(T
bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
{
- pthread_mutex_lock(&LOCK_active_mi);
- pthread_mutex_lock(&active_mi->rli.run_lock);
+ MYSQL_MUTEX_LOCK(&LOCK_active_mi);
+ MYSQL_MUTEX_LOCK(&active_mi->rli.run_lock);
/*
The following test should normally never be true as we test this
in the check function; To be safe against multiple
@@ -1896,12 +1896,12 @@ bool sys_var_slave_skip_counter::update(
*/
if (!active_mi->rli.slave_running)
{
- pthread_mutex_lock(&active_mi->rli.data_lock);
+ MYSQL_MUTEX_LOCK(&active_mi->rli.data_lock);
active_mi->rli.slave_skip_counter= var->save_result.ulong_value;
- pthread_mutex_unlock(&active_mi->rli.data_lock);
+ MYSQL_MUTEX_UNLOCK(&active_mi->rli.data_lock);
}
- pthread_mutex_unlock(&active_mi->rli.run_lock);
- pthread_mutex_unlock(&LOCK_active_mi);
+ MYSQL_MUTEX_UNLOCK(&active_mi->rli.run_lock);
+ MYSQL_MUTEX_UNLOCK(&LOCK_active_mi);
return 0;
}
=== modified file 'sql/sql_servers.cc'
--- a/sql/sql_servers.cc 2008-07-17 19:55:18 +0000
+++ b/sql/sql_servers.cc 2008-10-10 20:34:55 +0000
@@ -47,7 +47,10 @@
static HASH servers_cache;
static MEM_ROOT mem;
-static rw_lock_t THR_LOCK_servers;
+#ifdef HAVE_PSI_INTERFACE
+PSI_rwlock_key key_THR_LOCK_servers;
+#endif
+static mysql_rwlock_t THR_LOCK_servers;
static bool get_server_from_table_to_cache(TABLE *table);
@@ -116,7 +119,7 @@ bool servers_init(bool dont_read_servers
DBUG_ENTER("servers_init");
/* init the mutex */
- if (my_rwlock_init(&THR_LOCK_servers, NULL))
+ if (MYSQL_RWLOCK_INIT(&THR_LOCK_servers, key_THR_LOCK_servers, NULL))
DBUG_RETURN(TRUE);
/* initialise our servers cache */
@@ -228,7 +231,7 @@ bool servers_reload(THD *thd)
thd->locked_tables_list.unlock_locked_tables(thd);
DBUG_PRINT("info", ("locking servers_cache"));
- rw_wrlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_servers);
bzero((char*) tables, sizeof(tables));
tables[0].alias= tables[0].table_name= (char*) "servers";
@@ -254,7 +257,7 @@ bool servers_reload(THD *thd)
end:
close_thread_tables(thd);
DBUG_PRINT("info", ("unlocking servers_cache"));
- rw_unlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_servers);
DBUG_RETURN(return_val);
}
@@ -586,7 +589,7 @@ int drop_server(THD *thd, LEX_SERVER_OPT
tables.alias= tables.table_name= (char*) "servers";
alloc_mdl_locks(&tables, thd->mem_root);
- rw_wrlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_servers);
/* hit the memory hit first */
if ((error= delete_server_record_in_cache(server_options)))
@@ -610,7 +613,7 @@ int drop_server(THD *thd, LEX_SERVER_OPT
}
end:
- rw_unlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_servers);
DBUG_RETURN(error);
}
@@ -962,7 +965,7 @@ int create_server(THD *thd, LEX_SERVER_O
DBUG_PRINT("info", ("server_options->server_name %s",
server_options->server_name));
- rw_wrlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_servers);
/* hit the memory first */
if (hash_search(&servers_cache, (uchar*) server_options->server_name,
@@ -983,7 +986,7 @@ int create_server(THD *thd, LEX_SERVER_O
DBUG_PRINT("info", ("error returned %d", error));
end:
- rw_unlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_servers);
DBUG_RETURN(error);
}
@@ -1012,7 +1015,7 @@ int alter_server(THD *thd, LEX_SERVER_OP
DBUG_PRINT("info", ("server_options->server_name %s",
server_options->server_name));
- rw_wrlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_servers);
if (!(existing= (FOREIGN_SERVER *) hash_search(&servers_cache,
(uchar*) name.str,
@@ -1037,7 +1040,7 @@ int alter_server(THD *thd, LEX_SERVER_OP
end:
DBUG_PRINT("info", ("error returned %d", error));
- rw_unlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_servers);
DBUG_RETURN(error);
}
@@ -1203,7 +1206,7 @@ void servers_free(bool end)
my_hash_reset(&servers_cache);
DBUG_VOID_RETURN;
}
- rwlock_destroy(&THR_LOCK_servers);
+ MYSQL_RWLOCK_DESTROY(&THR_LOCK_servers);
free_root(&mem,MYF(0));
hash_free(&servers_cache);
DBUG_VOID_RETURN;
@@ -1285,7 +1288,7 @@ FOREIGN_SERVER *get_server_by_name(MEM_R
}
DBUG_PRINT("info", ("locking servers_cache"));
- rw_rdlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_RDLOCK(&THR_LOCK_servers);
if (!(server= (FOREIGN_SERVER *) hash_search(&servers_cache,
(uchar*) server_name,
server_name_length)))
@@ -1299,7 +1302,7 @@ FOREIGN_SERVER *get_server_by_name(MEM_R
server= clone_server(mem, server, buff);
DBUG_PRINT("info", ("unlocking servers_cache"));
- rw_unlock(&THR_LOCK_servers);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_servers);
DBUG_RETURN(server);
}
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2008-09-16 17:58:49 +0000
+++ b/sql/sql_show.cc 2008-10-10 20:34:55 +0000
@@ -1661,7 +1661,7 @@ void mysqld_list_processes(THD *thd,cons
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_VOID_RETURN;
- pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count); // For unlink from list
if (!thd->killed)
{
I_List_iterator<THD> it(threads);
@@ -1694,7 +1694,7 @@ void mysqld_list_processes(THD *thd,cons
thd_info->db=thd->strdup(thd_info->db);
thd_info->command=(int) tmp->command;
if ((mysys_var= tmp->mysys_var))
- pthread_mutex_lock(&mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&mysys_var->mutex);
thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);
#ifndef EMBEDDED_LIBRARY
thd_info->state_info= (char*) (tmp->net.reading_or_writing ?
@@ -1710,7 +1710,7 @@ void mysqld_list_processes(THD *thd,cons
thd_info->state_info= (char*)"Writing to net";
#endif
if (mysys_var)
- pthread_mutex_unlock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&mysys_var->mutex);
thd_info->start_time= tmp->start_time;
thd_info->query=0;
@@ -1728,7 +1728,7 @@ void mysqld_list_processes(THD *thd,cons
}
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
thread_info *thd_info;
time_t now= my_time(0);
@@ -1767,7 +1767,7 @@ int fill_schema_processlist(THD* thd, TA
user= thd->security_ctx->master_access & PROCESS_ACL ?
NullS : thd->security_ctx->priv_user;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
if (!thd->killed)
{
@@ -1811,7 +1811,7 @@ int fill_schema_processlist(THD* thd, TA
}
if ((mysys_var= tmp->mysys_var))
- pthread_mutex_lock(&mysys_var->mutex);
+ MYSQL_MUTEX_LOCK(&mysys_var->mutex);
/* COMMAND */
if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
table->field[4]->store(val, strlen(val), cs);
@@ -1842,7 +1842,7 @@ int fill_schema_processlist(THD* thd, TA
}
if (mysys_var)
- pthread_mutex_unlock(&mysys_var->mutex);
+ MYSQL_MUTEX_UNLOCK(&mysys_var->mutex);
/* INFO */
if (tmp->query)
@@ -1855,13 +1855,13 @@ int fill_schema_processlist(THD* thd, TA
if (schema_table_store_record(thd, table))
{
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_RETURN(1);
}
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_RETURN(0);
}
@@ -1920,7 +1920,7 @@ int add_status_vars(SHOW_VAR *list)
{
int res= 0;
if (status_vars_inited)
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
if (!all_status_vars.buffer && // array is not allocated yet - do it now
my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20))
{
@@ -1935,7 +1935,7 @@ int add_status_vars(SHOW_VAR *list)
sort_dynamic(&all_status_vars, show_var_cmp);
err:
if (status_vars_inited)
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
return res;
}
@@ -1997,7 +1997,7 @@ void remove_status_vars(SHOW_VAR *list)
{
if (status_vars_inited)
{
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *);
int a= 0, b= all_status_vars.elements, c= (a+b)/2;
@@ -2018,7 +2018,7 @@ void remove_status_vars(SHOW_VAR *list)
all[c].type= SHOW_UNDEF;
}
shrink_var_array(&all_status_vars);
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
}
else
{
@@ -2097,7 +2097,7 @@ static bool show_status_array(THD *thd,
char *value=var->value;
const char *pos, *end; // We assign a lot of const's
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (show_type == SHOW_SYS)
{
@@ -2186,7 +2186,7 @@ static bool show_status_array(THD *thd,
table->field[1]->store(pos, (uint32) (end - pos), system_charset_info);
table->field[1]->set_notnull();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
if (schema_table_store_record(thd, table))
DBUG_RETURN(TRUE);
@@ -2205,7 +2205,7 @@ void calc_sum_of_all_status(STATUS_VAR *
DBUG_ENTER("calc_sum_of_all_status");
/* Ensure that thread id not killed during loop */
- 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);
THD *tmp;
@@ -2217,7 +2217,7 @@ void calc_sum_of_all_status(STATUS_VAR *
while ((tmp= it++))
add_to_status(to, &tmp->status_var);
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
@@ -3108,7 +3108,7 @@ static int fill_schema_table_from_frm(TH
}
key_length= create_table_def_key(thd, key, &table_list, 0);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
share= get_table_share(thd, &table_list, key,
key_length, OPEN_VIEW, &error);
if (!share)
@@ -3163,7 +3163,7 @@ err_share:
release_table_share(share);
err_unlock:
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
err:
mdl_release_lock(&thd->mdl_context, &mdl_lock_data);
@@ -5583,10 +5583,10 @@ int fill_variables(THD *thd, TABLE_LIST
schema_table_idx == SCH_GLOBAL_VARIABLES)
option_type= OPT_GLOBAL;
- rw_rdlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_RDLOCK(&LOCK_system_variables_hash);
res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars),
option_type, NULL, "", tables->table, upper_case_names);
- rw_unlock(&LOCK_system_variables_hash);
+ MYSQL_RWLOCK_UNLOCK(&LOCK_system_variables_hash);
DBUG_RETURN(res);
}
@@ -5622,14 +5622,14 @@ int fill_status(THD *thd, TABLE_LIST *ta
tmp1= &thd->status_var;
}
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
if (option_type == OPT_GLOBAL)
calc_sum_of_all_status(&tmp);
res= show_status_array(thd, wild,
(SHOW_VAR *)all_status_vars.buffer,
option_type, tmp1, "", tables->table,
upper_case_names);
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
DBUG_RETURN(res);
}
@@ -7338,7 +7338,7 @@ TABLE_LIST *get_trigger_table(THD *thd,
{
/* Acquire LOCK_open (stop the server). */
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
/*
Load base table name from the TRN-file and create TABLE_LIST object.
@@ -7348,7 +7348,7 @@ TABLE_LIST *get_trigger_table(THD *thd,
/* Release LOCK_open (continue the server). */
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/* That's it. */
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2008-09-04 20:00:04 +0000
+++ b/sql/sql_table.cc 2008-10-10 20:34:55 +0000
@@ -310,7 +310,11 @@ struct st_global_ddl_log
st_global_ddl_log global_ddl_log;
-pthread_mutex_t LOCK_gdl;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_LOCK_gdl;
+#endif
+
+mysql_mutex_t LOCK_gdl;
#define DDL_LOG_ENTRY_TYPE_POS 0
#define DDL_LOG_ACTION_TYPE_POS 1
@@ -467,7 +471,7 @@ static uint read_ddl_log_header()
global_ddl_log.first_free= NULL;
global_ddl_log.first_used= NULL;
global_ddl_log.num_entries= 0;
- pthread_mutex_init(&LOCK_gdl, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&LOCK_gdl, key_LOCK_gdl, MY_MUTEX_INIT_FAST);
global_ddl_log.do_release= true;
DBUG_RETURN(entry_no);
}
@@ -1036,7 +1040,7 @@ bool execute_ddl_log_entry(THD *thd, uin
uint read_entry= first_entry;
DBUG_ENTER("execute_ddl_log_entry");
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
do
{
if (read_ddl_log_entry(read_entry, &ddl_log_entry))
@@ -1058,7 +1062,7 @@ bool execute_ddl_log_entry(THD *thd, uin
}
read_entry= ddl_log_entry.next_entry;
} while (read_entry);
- pthread_mutex_unlock(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
DBUG_RETURN(FALSE);
}
@@ -1162,7 +1166,7 @@ void release_ddl_log()
if (!global_ddl_log.do_release)
DBUG_VOID_RETURN;
- pthread_mutex_lock(&LOCK_gdl);
+ MYSQL_MUTEX_LOCK(&LOCK_gdl);
while (used_list)
{
DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry;
@@ -1177,8 +1181,8 @@ void release_ddl_log()
}
close_ddl_log();
global_ddl_log.inited= 0;
- pthread_mutex_unlock(&LOCK_gdl);
- pthread_mutex_destroy(&LOCK_gdl);
+ MYSQL_MUTEX_UNLOCK(&LOCK_gdl);
+ MYSQL_MUTEX_DESTROY(&LOCK_gdl);
global_ddl_log.do_release= false;
DBUG_VOID_RETURN;
}
@@ -1355,7 +1359,7 @@ bool mysql_write_frm(ALTER_PARTITION_PAR
completing this we write a new phase to the log entry that will
deactivate it.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (my_delete(frm_name, MYF(MY_WME)) ||
#ifdef WITH_PARTITION_STORAGE_ENGINE
lpt->table->file->ha_create_handler_files(path, shadow_path,
@@ -1406,7 +1410,7 @@ bool mysql_write_frm(ALTER_PARTITION_PAR
#endif
err:
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
#ifdef WITH_PARTITION_STORAGE_ENGINE
deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos);
part_info->frm_log_entry= NULL;
@@ -1561,7 +1565,7 @@ int mysql_rm_table_part2(THD *thd, TABLE
.frm file to find if the table is a normal table (not view) and what
engine to use.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (table= tables; table; table= table->next_local)
{
TABLE_SHARE *share;
@@ -1574,12 +1578,12 @@ int mysql_rm_table_part2(THD *thd, TABLE
check_if_log_table(table->db_length, table->db,
table->table_name_length, table->table_name, 1))
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP");
DBUG_RETURN(1);
}
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (!drop_temporary)
{
@@ -1587,10 +1591,10 @@ int mysql_rm_table_part2(THD *thd, TABLE
{
if (lock_table_names(thd, tables))
DBUG_RETURN(1);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (table= tables; table; table= table->next_local)
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
else
{
@@ -1703,7 +1707,7 @@ int mysql_rm_table_part2(THD *thd, TABLE
TODO: Investigate what should be done to remove this lock completely.
Is exclusive meta-data lock enough ?
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (drop_temporary ||
(table_type == NULL &&
(access(path, F_OK) &&
@@ -1756,7 +1760,7 @@ int mysql_rm_table_part2(THD *thd, TABLE
error|= new_error;
}
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (error)
{
if (wrong_tables.length())
@@ -3544,7 +3548,7 @@ bool mysql_create_table_no_lock(THD *thd
file->engine_name()->str,
"TRANSACTIONAL=1");
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
{
if (!access(path,F_OK))
@@ -3669,7 +3673,7 @@ bool mysql_create_table_no_lock(THD *thd
write_bin_log(thd, TRUE, thd->query, thd->query_length);
error= FALSE;
unlock_and_end:
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
err:
thd_proc_info(thd, "After create");
@@ -3743,21 +3747,21 @@ bool mysql_create_table(THD *thd, const
DBUG_ENTER("mysql_create_table");
/* Wait for any database locks */
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
while (!thd->killed &&
hash_search(&lock_db_cache,(uchar*) db, strlen(db)))
{
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
}
if (thd->killed)
{
- pthread_mutex_unlock(&LOCK_lock_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
DBUG_RETURN(TRUE);
}
creating_table++;
- pthread_mutex_unlock(&LOCK_lock_db);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
{
@@ -3796,10 +3800,10 @@ unlock:
mdl_release_lock(&thd->mdl_context, target_lock_data);
mdl_remove_lock(&thd->mdl_context, target_lock_data);
}
- pthread_mutex_lock(&LOCK_lock_db);
+ MYSQL_MUTEX_LOCK(&LOCK_lock_db);
if (!--creating_table && creating_database)
- pthread_cond_signal(&COND_refresh);
- pthread_mutex_unlock(&LOCK_lock_db);
+ MYSQL_COND_SIGNAL(&COND_refresh);
+ MYSQL_MUTEX_UNLOCK(&LOCK_lock_db);
DBUG_RETURN(result);
}
@@ -3986,21 +3990,21 @@ static int prepare_for_repair(THD *thd,
DBUG_RETURN(0);
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (!(share= (get_table_share(thd, table_list, key, key_length, 0,
&error))))
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(0); // Can't open frm file
}
if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, OTM_OPEN))
{
release_table_share(share);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
DBUG_RETURN(0); // Out of memory
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
table= &tmp_table;
table_list->mdl_lock_data= mdl_lock_data;
}
@@ -4112,9 +4116,9 @@ end:
thd->locked_tables_list.unlink_all_closed_tables();
if (table == &tmp_table)
{
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
closefrm(table, 1); // Free allocated memory
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
/* In case of a temporary table there will be no metadata lock. */
if (error && mdl_lock_data)
@@ -4661,14 +4665,14 @@ bool mysql_assign_to_keycache(THD* thd,
DBUG_ENTER("mysql_assign_to_keycache");
check_opt.init();
- pthread_mutex_lock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_LOCK(&LOCK_global_system_variables);
if (!(key_cache= get_key_cache(key_cache_name)))
{
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str);
DBUG_RETURN(TRUE);
}
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ MYSQL_MUTEX_UNLOCK(&LOCK_global_system_variables);
check_opt.key_cache= key_cache;
DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt,
"assign_to_keycache", TL_READ_NO_INSERT, 0, 0,
@@ -4880,12 +4884,12 @@ bool mysql_create_like_table(THD* thd, T
info). So we should double check and probably fix this code
to not acquire this mutex.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (src_table->schema_table)
{
if (mysql_create_like_schema_frm(thd, src_table, dst_path, create_info))
{
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
goto err;
}
}
@@ -4895,7 +4899,7 @@ bool mysql_create_like_table(THD* thd, T
my_error(ER_BAD_DB_ERROR,MYF(0),db);
else
my_error(ER_CANT_CREATE_FILE,MYF(0),dst_path,my_errno);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
goto err;
}
@@ -4924,7 +4928,7 @@ bool mysql_create_like_table(THD* thd, T
if (thd->variables.keep_files_on_create)
create_info->options|= HA_CREATE_KEEP_FILES;
err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
@@ -4990,14 +4994,14 @@ bool mysql_create_like_table(THD* thd, T
write_bin_log(thd, TRUE, query.ptr(), query.length());
DBUG_ASSERT(thd->open_tables == table->table);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
/*
When opening the table, we ignored the locked tables
(MYSQL_OPEN_GET_NEW_TABLE). Now we can close the table without
risking to close some locked table.
*/
close_thread_table(thd, &thd->open_tables);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
else // Case 1
write_bin_log(thd, TRUE, thd->query, thd->query_length);
@@ -5854,13 +5858,13 @@ mysql_fast_or_online_alter_table(THD *th
The final .frm file is already created as a temporary file.
Let's rename it to the original table name.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
error= mysql_rename_table(NULL,
altered_table->s->db.str,
altered_table->s->table_name.str,
table_list->db, table_list->table_name,
FN_FROM_IS_TMP);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/*
The ALTER TABLE is always in its own transaction.
@@ -5895,9 +5899,9 @@ mysql_fast_or_online_alter_table(THD *th
error= 2;
DBUG_ASSERT(thd->open_tables == table);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
close_thread_table(thd, &thd->open_tables);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
table_list->table= 0;
}
DBUG_ASSERT(table_list->table == 0);
@@ -6488,7 +6492,7 @@ bool mysql_alter_table(THD *thd,char *ne
goto view_err;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (!do_rename(thd, table_list, new_db, new_name, new_name, 1))
{
@@ -6500,7 +6504,7 @@ bool mysql_alter_table(THD *thd,char *ne
}
my_ok(thd);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
unlock_table_names(thd);
@@ -6701,7 +6705,7 @@ view_err:
else
{
*fn_ext(new_name)=0;
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (mysql_rename_table(old_db_type,db,table_name,new_db,new_alias, 0))
error= -1;
else if (Table_triggers_list::change_table_name(thd, db, table_name,
@@ -6711,7 +6715,7 @@ view_err:
table_name, 0);
error= -1;
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
}
}
@@ -7084,7 +7088,7 @@ view_err:
table is renamed and the SE is also changed, then an intermediate table
is created and the additional call will not take place.
*/
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
if (mysql_rename_table(old_db_type, db, table_name, db, old_name,
FN_TO_IS_TMP))
{
@@ -7108,7 +7112,7 @@ view_err:
if (! error)
(void) quick_rm_table(old_db_type, db, old_name, FN_IS_TMP);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (error)
goto err_with_mdl;
=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc 2008-06-28 11:00:59 +0000
+++ b/sql/sql_test.cc 2008-10-10 20:34:55 +0000
@@ -77,7 +77,7 @@ void print_cached_tables(void)
TABLE *start_link, *lnk, *entry;
/* purecov: begin tested */
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
puts("DB Table Version Thread Open Lock");
for (idx=unused=0 ; idx < table_def_cache.records ; idx++)
@@ -124,7 +124,7 @@ void print_cached_tables(void)
if (hash_check(&table_def_cache))
printf("Error: Table definition hash table is corrupted\n");
fflush(stdout);
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
/* purecov: end */
return;
}
@@ -425,12 +425,12 @@ static void display_table_locks(void)
DYNAMIC_ARRAY saved_table_locks;
(void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), table_cache_count + 20,50);
- pthread_mutex_lock(&THR_LOCK_lock);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_lock);
for (list= thr_lock_thread_list; list; list= list_rest(list))
{
THR_LOCK *lock=(THR_LOCK*) list->data;
- pthread_mutex_lock(&lock->mutex);
+ MYSQL_MUTEX_LOCK(&lock->mutex);
push_locks_into_array(&saved_table_locks, lock->write.data, FALSE,
"Locked - write");
push_locks_into_array(&saved_table_locks, lock->write_wait.data, TRUE,
@@ -439,9 +439,9 @@ static void display_table_locks(void)
"Locked - read");
push_locks_into_array(&saved_table_locks, lock->read_wait.data, TRUE,
"Waiting - read");
- pthread_mutex_unlock(&lock->mutex);
+ MYSQL_MUTEX_UNLOCK(&lock->mutex);
}
- pthread_mutex_unlock(&THR_LOCK_lock);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_lock);
if (!saved_table_locks.elements) goto end;
qsort((uchar*) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare);
@@ -517,7 +517,7 @@ void mysql_print_status()
/* Print key cache status */
puts("\nKey caches:");
process_key_caches(print_key_cache_status);
- pthread_mutex_lock(&LOCK_status);
+ MYSQL_MUTEX_LOCK(&LOCK_status);
printf("\nhandler status:\n\
read_key: %10lu\n\
read_next: %10lu\n\
@@ -533,7 +533,7 @@ update: %10lu\n",
tmp.ha_write_count,
tmp.ha_delete_count,
tmp.ha_update_count);
- pthread_mutex_unlock(&LOCK_status);
+ MYSQL_MUTEX_UNLOCK(&LOCK_status);
printf("\nTable status:\n\
Opened tables: %10lu\n\
Open tables: %10lu\n\
=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc 2008-07-15 16:29:51 +0000
+++ b/sql/sql_trigger.cc 2008-10-10 20:34:55 +0000
@@ -482,11 +482,11 @@ bool mysql_create_or_drop_trigger(THD *t
goto end;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
result= (create ?
table->triggers->create_trigger(thd, tables, &stmt_query):
table->triggers->drop_trigger(thd, tables, &stmt_query));
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (result)
goto end;
@@ -1857,7 +1857,7 @@ bool Table_triggers_list::change_table_n
*/
#ifndef DBUG_OFF
if (mdl_is_exclusive_lock_owner(&thd->mdl_context, 0, db, old_table))
- safe_mutex_assert_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_open);
#endif
DBUG_ASSERT(my_strcasecmp(table_alias_charset, db, new_db) ||
=== modified file 'sql/sql_udf.cc'
--- a/sql/sql_udf.cc 2008-08-26 12:00:01 +0000
+++ b/sql/sql_udf.cc 2008-10-10 20:34:55 +0000
@@ -44,7 +44,11 @@ extern "C"
static bool initialized = 0;
static MEM_ROOT mem;
static HASH udf_hash;
-static rw_lock_t THR_LOCK_udf;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_rwlock_key key_THR_LOCK_udf;
+#endif
+static mysql_rwlock_t THR_LOCK_udf;
static udf_func *add_udf(LEX_STRING *name, Item_result ret,
@@ -119,7 +123,7 @@ void udf_init()
if (initialized)
DBUG_VOID_RETURN;
- my_rwlock_init(&THR_LOCK_udf,NULL);
+ MYSQL_RWLOCK_INIT(&THR_LOCK_udf, key_THR_LOCK_udf, NULL);
init_sql_alloc(&mem, UDF_ALLOC_BLOCK_SIZE, 0);
THD *new_thd = new THD;
@@ -257,7 +261,7 @@ void udf_free()
if (initialized)
{
initialized= 0;
- rwlock_destroy(&THR_LOCK_udf);
+ MYSQL_RWLOCK_DESTROY(&THR_LOCK_udf);
}
DBUG_VOID_RETURN;
}
@@ -295,7 +299,7 @@ void free_udf(udf_func *udf)
if (!initialized)
DBUG_VOID_RETURN;
- rw_wrlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_udf);
if (!--udf->usage_count)
{
/*
@@ -307,7 +311,7 @@ void free_udf(udf_func *udf)
if (!find_udf_dl(udf->dl))
dlclose(udf->dlhandle);
}
- rw_unlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_udf);
DBUG_VOID_RETURN;
}
@@ -324,9 +328,9 @@ udf_func *find_udf(const char *name,uint
/* TODO: This should be changed to reader locks someday! */
if (mark_used)
- rw_wrlock(&THR_LOCK_udf); /* Called during fix_fields */
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_udf); /* Called during fix_fields */
else
- rw_rdlock(&THR_LOCK_udf); /* Called during parsing */
+ MYSQL_RWLOCK_RDLOCK(&THR_LOCK_udf); /* Called during parsing */
if ((udf=(udf_func*) hash_search(&udf_hash,(uchar*) name,
length ? length : (uint) strlen(name))))
@@ -336,7 +340,7 @@ udf_func *find_udf(const char *name,uint
else if (mark_used)
udf->usage_count++;
}
- rw_unlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_udf);
DBUG_RETURN(udf);
}
@@ -436,7 +440,7 @@ int mysql_create_function(THD *thd,udf_f
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
- rw_wrlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_udf);
if ((hash_search(&udf_hash,(uchar*) udf->name.str, udf->name.length)))
{
my_error(ER_UDF_EXISTS, MYF(0), udf->name.str);
@@ -500,7 +504,7 @@ int mysql_create_function(THD *thd,udf_f
del_udf(u_d);
goto err;
}
- rw_unlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_udf);
/* Binlog the create function. */
write_bin_log(thd, TRUE, thd->query, thd->query_length);
@@ -510,7 +514,7 @@ int mysql_create_function(THD *thd,udf_f
err:
if (new_dl)
dlclose(dl);
- rw_unlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_udf);
DBUG_RETURN(1);
}
@@ -540,7 +544,7 @@ int mysql_drop_function(THD *thd,const L
if (thd->current_stmt_binlog_row_based)
thd->clear_current_stmt_binlog_row_based();
- rw_wrlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_WRLOCK(&THR_LOCK_udf);
if (!(udf=(udf_func*) hash_search(&udf_hash,(uchar*) udf_name->str,
(uint) udf_name->length)))
{
@@ -576,14 +580,14 @@ int mysql_drop_function(THD *thd,const L
}
close_thread_tables(thd);
- rw_unlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_udf);
/* Binlog the drop function. */
write_bin_log(thd, TRUE, thd->query, thd->query_length);
DBUG_RETURN(0);
err:
- rw_unlock(&THR_LOCK_udf);
+ MYSQL_RWLOCK_UNLOCK(&THR_LOCK_udf);
DBUG_RETURN(1);
}
=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc 2008-07-15 16:29:51 +0000
+++ b/sql/sql_view.cc 2008-10-10 20:34:55 +0000
@@ -617,7 +617,7 @@ bool mysql_create_view(THD *thd, TABLE_L
goto err;
}
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
res= mysql_register_view(thd, view, mode);
if (mysql_bin_log.is_open())
@@ -662,7 +662,7 @@ bool mysql_create_view(THD *thd, TABLE_L
buff.ptr(), buff.length(), FALSE, FALSE);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (view->revision != 1)
query_cache_invalidate3(thd, view, 0);
start_waiting_global_read_lock(thd);
@@ -1592,7 +1592,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
if (lock_table_names(thd, views))
DBUG_RETURN(TRUE);
- pthread_mutex_lock(&LOCK_open);
+ MYSQL_MUTEX_LOCK(&LOCK_open);
for (view= views; view; view= view->next_local)
{
TABLE_SHARE *share;
@@ -1667,7 +1667,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
write_bin_log(thd, !something_wrong, thd->query, thd->query_length);
}
- pthread_mutex_unlock(&LOCK_open);
+ MYSQL_MUTEX_UNLOCK(&LOCK_open);
if (something_wrong)
{
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2008-09-16 08:34:30 +0000
+++ b/sql/table.cc 2008-10-10 20:34:55 +0000
@@ -380,7 +380,7 @@ TABLE_SHARE *alloc_table_share(TABLE_LIS
share->free_tables.empty();
memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
- pthread_mutex_init(&share->LOCK_ha_data, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&share->LOCK_ha_data, key_LOCK_ha_data, MY_MUTEX_INIT_FAST);
}
DBUG_RETURN(share);
}
@@ -471,7 +471,7 @@ void free_table_share(TABLE_SHARE *share
/* The mutex is initialized only for shares that are part of the TDC */
if (share->tmp_table == NO_TMP_TABLE)
- pthread_mutex_destroy(&share->LOCK_ha_data);
+ MYSQL_MUTEX_DESTROY(&share->LOCK_ha_data);
hash_free(&share->name_hash);
plugin_unlock(NULL, share->db_plugin);
=== modified file 'sql/table.h'
--- a/sql/table.h 2008-09-16 17:58:49 +0000
+++ b/sql/table.h 2008-10-10 20:34:55 +0000
@@ -240,6 +240,10 @@ TABLE_CATEGORY get_table_category(const
struct TABLE_share;
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_ha_data;
+#endif
+
/*
This structure is shared between different table objects. There is one
instance of table share per one table in the database.
@@ -258,7 +262,7 @@ struct TABLE_SHARE
TYPELIB keynames; /* Pointers to keynames */
TYPELIB fieldnames; /* Pointer to fieldnames */
TYPELIB *intervals; /* pointer to interval info */
- pthread_mutex_t LOCK_ha_data; /* To protect access to ha_data */
+ mysql_mutex_t LOCK_ha_data; /* To protect access to ha_data */
TABLE_SHARE *next, **prev; /* Link to unused shares */
/*
=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc 2008-05-08 20:43:28 +0000
+++ b/sql/tztime.cc 2008-10-10 20:34:55 +0000
@@ -1429,7 +1429,10 @@ static MEM_ROOT tz_storage;
time zone in offset_tzs or creating if it didn't existed before in
tz_storage. So contention is low.
*/
-static pthread_mutex_t tz_LOCK;
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_tz_LOCK;
+#endif
+static mysql_mutex_t tz_LOCK;
static bool tz_inited= 0;
/*
@@ -1592,7 +1595,7 @@ my_tz_init(THD *org_thd, const char *def
goto end;
}
init_sql_alloc(&tz_storage, 32 * 1024, 0);
- pthread_mutex_init(&tz_LOCK, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&tz_LOCK, key_tz_LOCK, MY_MUTEX_INIT_FAST);
tz_inited= 1;
/* Add 'SYSTEM' time zone to tz_names hash */
@@ -1770,7 +1773,7 @@ void my_tz_free()
if (tz_inited)
{
tz_inited= 0;
- pthread_mutex_destroy(&tz_LOCK);
+ MYSQL_MUTEX_DESTROY(&tz_LOCK);
hash_free(&offset_tzs);
hash_free(&tz_names);
free_root(&tz_storage, MYF(0));
@@ -2231,7 +2234,7 @@ my_tz_find(THD *thd, const String *name)
if (!name)
DBUG_RETURN(0);
- pthread_mutex_lock(&tz_LOCK);
+ MYSQL_MUTEX_LOCK(&tz_LOCK);
if (!str_to_offset(name->ptr(), name->length(), &offset))
{
@@ -2273,7 +2276,7 @@ my_tz_find(THD *thd, const String *name)
}
}
- pthread_mutex_unlock(&tz_LOCK);
+ MYSQL_MUTEX_UNLOCK(&tz_LOCK);
DBUG_RETURN(result_tz);
}
=== modified file 'sql/udf_example.c'
--- a/sql/udf_example.c 2008-05-29 15:44:11 +0000
+++ b/sql/udf_example.c 2008-10-10 20:34:55 +0000
@@ -139,7 +139,7 @@ typedef long long longlong;
#include <mysql.h>
#include <ctype.h>
-static pthread_mutex_t LOCK_hostname;
+static mysql_mutex_t LOCK_hostname;
#ifdef HAVE_DLOPEN
@@ -727,7 +727,7 @@ my_bool lookup_init(UDF_INIT *initid, UD
void lookup_deinit(UDF_INIT *initid __attribute__((unused)))
{
#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_SOLARIS_STYLE_GETHOST)
- (void) pthread_mutex_destroy(&LOCK_hostname);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_hostname);
#endif
}
@@ -762,14 +762,14 @@ char *lookup(UDF_INIT *initid __attribut
return 0;
}
#else
- pthread_mutex_lock(&LOCK_hostname);
+ MYSQL_MUTEX_LOCK(&LOCK_hostname);
if (!(hostent= gethostbyname((char*) name_buff)))
{
- pthread_mutex_unlock(&LOCK_hostname);
+ MYSQL_MUTEX_UNLOCK(&LOCK_hostname);
*null_value= 1;
return 0;
}
- pthread_mutex_unlock(&LOCK_hostname);
+ MYSQL_MUTEX_UNLOCK(&LOCK_hostname);
#endif
memcpy_fixed((char*) &in,(char*) *hostent->h_addr_list, sizeof(in.s_addr));
*res_length= (ulong) (strmov(result, inet_ntoa(in)) - result);
@@ -807,7 +807,7 @@ my_bool reverse_lookup_init(UDF_INIT *in
void reverse_lookup_deinit(UDF_INIT *initid __attribute__((unused)))
{
#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_SOLARIS_STYLE_GETHOST)
- (void) pthread_mutex_destroy(&LOCK_hostname);
+ (void) MYSQL_MUTEX_DESTROY(&LOCK_hostname);
#endif
}
@@ -866,14 +866,14 @@ char *reverse_lookup(UDF_INIT *initid __
return 0;
}
#else
- pthread_mutex_lock(&LOCK_hostname);
+ MYSQL_MUTEX_LOCK(&LOCK_hostname);
if (!(hp= gethostbyaddr((char*) &taddr, sizeof(taddr), AF_INET)))
{
- pthread_mutex_unlock(&LOCK_hostname);
+ MYSQL_MUTEX_UNLOCK(&LOCK_hostname);
*null_value= 1;
return 0;
}
- pthread_mutex_unlock(&LOCK_hostname);
+ MYSQL_MUTEX_UNLOCK(&LOCK_hostname);
#endif
*res_length=(ulong) (strmov(result,hp->h_name) - result);
return result;
=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc 2008-08-15 19:58:03 +0000
+++ b/storage/federated/ha_federated.cc 2008-10-10 20:34:55 +0000
@@ -387,7 +387,13 @@
/* Variables for federated share methods */
static HASH federated_open_tables; // To track open tables
-pthread_mutex_t federated_mutex; // To init the hash
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_FEDERATED_SHARE_mutex;
+PSI_mutex_key key_federated_mutex;
+#endif
+
+mysql_mutex_t federated_mutex; // To init the hash
static char ident_quote_char= '`'; // Character for quoting
// identifiers
static char value_quote_char= '\''; // Character for quoting
@@ -456,7 +462,7 @@ int federated_db_init(void *p)
federated_hton->commit= 0;
federated_hton->rollback= 0;
- if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
+ if (MYSQL_MUTEX_INIT(&federated_mutex, key_federated_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (!hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0,
(hash_get_key) federated_get_key, 0, 0))
@@ -464,7 +470,7 @@ int federated_db_init(void *p)
DBUG_RETURN(FALSE);
}
- pthread_mutex_destroy(&federated_mutex);
+ MYSQL_MUTEX_DESTROY(&federated_mutex);
error:
DBUG_RETURN(TRUE);
}
@@ -483,7 +489,7 @@ error:
int federated_done(void *p)
{
hash_free(&federated_open_tables);
- pthread_mutex_destroy(&federated_mutex);
+ MYSQL_MUTEX_DESTROY(&federated_mutex);
return 0;
}
@@ -1484,7 +1490,7 @@ static FEDERATED_SHARE *get_share(const
init_alloc_root(&mem_root, 256, 0);
- pthread_mutex_lock(&federated_mutex);
+ MYSQL_MUTEX_LOCK(&federated_mutex);
tmp_share.share_key= table_name;
tmp_share.share_key_length= strlen(table_name);
@@ -1526,18 +1532,18 @@ static FEDERATED_SHARE *get_share(const
if (my_hash_insert(&federated_open_tables, (uchar*) share))
goto error;
thr_lock_init(&share->lock);
- pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
+ MYSQL_MUTEX_INIT(&share->mutex, key_FEDERATED_SHARE_mutex, MY_MUTEX_INIT_FAST);
}
else
free_root(&mem_root, MYF(0)); /* prevents memory leak */
share->use_count++;
- pthread_mutex_unlock(&federated_mutex);
+ MYSQL_MUTEX_UNLOCK(&federated_mutex);
DBUG_RETURN(share);
error:
- pthread_mutex_unlock(&federated_mutex);
+ MYSQL_MUTEX_UNLOCK(&federated_mutex);
free_root(&mem_root, MYF(0));
DBUG_RETURN(NULL);
}
@@ -1554,15 +1560,15 @@ static int free_share(FEDERATED_SHARE *s
MEM_ROOT mem_root= share->mem_root;
DBUG_ENTER("free_share");
- pthread_mutex_lock(&federated_mutex);
+ MYSQL_MUTEX_LOCK(&federated_mutex);
if (!--share->use_count)
{
hash_delete(&federated_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
- pthread_mutex_destroy(&share->mutex);
+ MYSQL_MUTEX_DESTROY(&share->mutex);
free_root(&mem_root, MYF(0));
}
- pthread_mutex_unlock(&federated_mutex);
+ MYSQL_MUTEX_UNLOCK(&federated_mutex);
DBUG_RETURN(0);
}
@@ -3079,7 +3085,7 @@ int ha_federated::real_connect()
to establish Federated connection to guard against a trivial
Denial of Service scenerio.
*/
- safe_mutex_assert_not_owner(&LOCK_open);
+ MYSQL_MUTEX_ASSERT_NOT_OWNER(&LOCK_open);
DBUG_ASSERT(mysql == NULL);
=== modified file 'storage/federated/ha_federated.h'
--- a/storage/federated/ha_federated.h 2008-08-15 12:18:06 +0000
+++ b/storage/federated/ha_federated.h 2008-10-10 20:34:55 +0000
@@ -38,6 +38,10 @@
#define FEDERATED_RECORDS_IN_RANGE 2
#define FEDERATED_MAX_KEY_LENGTH 3500 // Same as innodb
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_FEDERATED_SHARE_mutex;
+#endif
+
/*
FEDERATED_SHARE is a structure that will be shared amoung all open handlers
The example implements the minimum of what you will probably need.
@@ -71,7 +75,7 @@ typedef struct st_federated_share {
ushort port;
uint table_name_length, server_name_length, connect_string_length, use_count;
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
THR_LOCK lock;
} FEDERATED_SHARE;
=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc 2008-09-04 18:30:34 +0000
+++ b/storage/maria/ha_maria.cc 2008-10-10 20:34:55 +0000
@@ -1035,14 +1035,14 @@ int ha_maria::check(THD * thd, HA_CHECK_
(param.testflag & T_STATISTICS) || maria_is_crashed(file))
{
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->state.changed &= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR);
if (!(table->db_stat & HA_READ_ONLY))
error= maria_update_state_info(¶m, file,
UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST);
}
@@ -1086,9 +1086,9 @@ int ha_maria::analyze(THD *thd, HA_CHECK
error= maria_chk_key(¶m, file);
if (!error)
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
error= maria_update_state_info(¶m, file, UPDATE_STAT);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
else if (!maria_is_crashed(file) && !thd->killed)
maria_mark_crashed(file);
@@ -1169,9 +1169,9 @@ int ha_maria::zerofill(THD * thd, HA_CHE
if (!error)
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
maria_update_state_info(¶m, file, UPDATE_TIME | UPDATE_OPEN_COUNT);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
return error;
}
@@ -1324,7 +1324,7 @@ int ha_maria::repair(THD *thd, HA_CHECK
}
}
thd_proc_info(thd, "Saving state");
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (!error)
{
if ((share->state.changed & STATE_CHANGED) || maria_is_crashed(file))
@@ -1364,7 +1364,7 @@ int ha_maria::repair(THD *thd, HA_CHECK
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
maria_update_state_info(param, file, 0);
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
thd_proc_info(thd, old_proc_info);
if (!thd->locked_tables_mode)
maria_lock_database(file, F_UNLCK);
@@ -1810,10 +1810,10 @@ bool ha_maria::check_and_repair(THD *thd
old_query= thd->query;
old_query_length= thd->query_length;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query= table->s->table_name.str;
thd->query_length= table->s->table_name.length;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if (!(crashed= maria_is_crashed(file)))
{
@@ -1831,10 +1831,10 @@ bool ha_maria::check_and_repair(THD *thd
if (repair(thd, &check_opt))
error= 1;
}
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query= old_query;
thd->query_length= old_query_length;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_RETURN(error);
}
@@ -2050,7 +2050,7 @@ int ha_maria::info(uint flag)
/* Update share */
if (share->tmp_table == NO_TMP_TABLE)
- pthread_mutex_lock(&share->LOCK_ha_data);
+ MYSQL_MUTEX_LOCK(&share->LOCK_ha_data);
share->keys_in_use.set_prefix(share->keys);
share->keys_in_use.intersect_extended(maria_info.key_map);
share->keys_for_keyread.intersect(share->keys_in_use);
@@ -2063,7 +2063,7 @@ int ha_maria::info(uint flag)
*to= (ulong) (*from + 0.5);
}
if (share->tmp_table == NO_TMP_TABLE)
- pthread_mutex_unlock(&share->LOCK_ha_data);
+ MYSQL_MUTEX_UNLOCK(&share->LOCK_ha_data);
/*
Set data_file_name and index_file_name to point at the symlink value
=== modified file 'storage/maria/lockman.c'
--- a/storage/maria/lockman.c 2008-02-21 00:51:51 +0000
+++ b/storage/maria/lockman.c 2008-10-10 20:34:55 +0000
@@ -676,14 +676,14 @@ enum lockman_getlock_result lockman_getl
if there're other active LOCK_OWNERs.
*/
/* QQ: race condition here */
- pthread_mutex_lock(wait_for_lo->mutex);
+ MYSQL_MUTEX_LOCK(wait_for_lo->mutex);
if (DELETED(blocker->link))
{
/*
blocker transaction was ended, or a savepoint that owned
the lock was rolled back. Either way - the lock was removed
*/
- pthread_mutex_unlock(wait_for_lo->mutex);
+ MYSQL_MUTEX_UNLOCK(wait_for_lo->mutex);
lf_rwlock_by_pins(pins);
continue;
}
@@ -693,9 +693,9 @@ enum lockman_getlock_result lockman_getl
set_timespec_nsec(timeout,lm->lock_timeout * 1000000);
do
{
- pthread_cond_timedwait(wait_for_lo->cond, wait_for_lo->mutex, &timeout);
+ MYSQL_COND_TIMEDWAIT(wait_for_lo->cond, wait_for_lo->mutex, &timeout);
} while (!DELETED(blocker->link) && my_getsystime() < deadline);
- pthread_mutex_unlock(wait_for_lo->mutex);
+ MYSQL_MUTEX_UNLOCK(wait_for_lo->mutex);
lf_rwlock_by_pins(pins);
if (!DELETED(blocker->link))
{
@@ -729,7 +729,7 @@ int lockman_release_locks(LOCKMAN *lm, L
uint bucket;
LF_PINS *pins= lo->pins;
- pthread_mutex_lock(lo->mutex);
+ MYSQL_MUTEX_LOCK(lo->mutex);
lf_rwlock_by_pins(pins);
for (node= lo->all_locks; node; node= next)
{
@@ -744,8 +744,8 @@ int lockman_release_locks(LOCKMAN *lm, L
lf_rwunlock_by_pins(pins);
lo->all_locks= 0;
/* now signal all waiters */
- pthread_cond_broadcast(lo->cond);
- pthread_mutex_unlock(lo->mutex);
+ MYSQL_COND_BROADCAST(lo->cond);
+ MYSQL_MUTEX_UNLOCK(lo->mutex);
return 0;
}
=== modified file 'storage/maria/lockman.h'
--- a/storage/maria/lockman.h 2007-12-18 22:22:55 +0000
+++ b/storage/maria/lockman.h 2008-10-10 20:34:55 +0000
@@ -40,8 +40,8 @@ struct st_lock_owner {
LF_PINS *pins; /* must be allocated from lockman's pinbox */
struct lockman_lock *all_locks; /* a LIFO */
LOCK_OWNER *waiting_for;
- pthread_cond_t *cond; /* transactions waiting for this, wait on 'cond' */
- pthread_mutex_t *mutex; /* mutex is required to use 'cond' */
+ mysql_cond_t *cond; /* transactions waiting for this, wait on 'cond' */
+ mysql_mutex_t *mutex; /* mutex is required to use 'cond' */
uint16 loid;
};
=== modified file 'storage/maria/ma_bitmap.c'
--- a/storage/maria/ma_bitmap.c 2008-04-03 13:40:25 +0000
+++ b/storage/maria/ma_bitmap.c 2008-10-10 20:34:55 +0000
@@ -260,8 +260,8 @@ my_bool _ma_bitmap_init(MARIA_SHARE *sha
my_bool _ma_bitmap_end(MARIA_SHARE *share)
{
my_bool res= _ma_bitmap_flush(share);
- pthread_mutex_destroy(&share->bitmap.bitmap_lock);
- pthread_cond_destroy(&share->bitmap.bitmap_cond);
+ MYSQL_MUTEX_DESTROY(&share->bitmap.bitmap_lock);
+ MYSQL_COND_DESTROY(&share->bitmap.bitmap_cond);
delete_dynamic(&share->bitmap.pinned_pages);
my_free((uchar*) share->bitmap.map, MYF(MY_ALLOW_ZERO_PTR));
share->bitmap.map= 0;
@@ -293,13 +293,13 @@ my_bool _ma_bitmap_flush(MARIA_SHARE *sh
DBUG_ENTER("_ma_bitmap_flush");
if (share->bitmap.changed)
{
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
if (share->bitmap.changed)
{
share->bitmap.changed= 0;
res= write_changed_bitmap(share, &share->bitmap);
}
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
}
DBUG_RETURN(res);
}
@@ -319,18 +319,18 @@ my_bool _ma_bitmap_wait_or_flush(MARIA_S
DBUG_ENTER("_ma_bitmap_flush");
if (bitmap->changed)
{
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_LOCK(&bitmap->bitmap_lock);
while (bitmap->non_flushable && bitmap->changed)
{
DBUG_PRINT("info", ("waiting for bitmap to be flushable"));
- pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
+ MYSQL_COND_WAIT(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
if (bitmap->changed)
{
bitmap->changed= 0;
res= write_changed_bitmap(share, bitmap);
}
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
}
DBUG_RETURN(res);
}
@@ -369,7 +369,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE
my_bool res= 0;
MARIA_FILE_BITMAP *bitmap= &share->bitmap;
DBUG_ENTER("_ma_bitmap_flush_all");
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_LOCK(&bitmap->bitmap_lock);
if (bitmap->changed)
{
bitmap->flush_all_requested= TRUE;
@@ -377,7 +377,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE
while (bitmap->non_flushable > 0)
{
DBUG_PRINT("info", ("waiting for bitmap to be flushable"));
- pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
+ MYSQL_COND_WAIT(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
#endif
/*
@@ -410,9 +410,9 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE
become false, wake them up.
*/
DBUG_PRINT("info", ("bitmap flusher waking up others"));
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ MYSQL_COND_BROADCAST(&bitmap->bitmap_cond);
}
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
DBUG_RETURN(res);
}
@@ -1703,7 +1703,7 @@ my_bool _ma_bitmap_find_place(MARIA_HA *
info->bitmap_blocks.elements= ELEMENTS_RESERVED_FOR_MAIN_PART;
max_page_size= (share->block_size - PAGE_OVERHEAD_SIZE);
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
if (row->total_length <= max_page_size)
{
@@ -1765,7 +1765,7 @@ end:
res= 0;
abort:
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -1809,7 +1809,7 @@ my_bool _ma_bitmap_find_new_place(MARIA_
row->extents_count= 0;
info->bitmap_blocks.elements= ELEMENTS_RESERVED_FOR_MAIN_PART;
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
/*
First allocate all blobs (so that we can find out the needed size for
@@ -1861,7 +1861,7 @@ end:
res= 0;
abort:
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -2001,7 +2001,7 @@ my_bool _ma_bitmap_reset_full_page_bits(
uchar *data;
DBUG_ENTER("_ma_bitmap_reset_full_page_bits");
DBUG_PRINT("enter", ("page: %lu page_count: %u", (ulong) page, page_count));
- safe_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&info->s->bitmap.bitmap_lock);
bitmap_page= page - page % bitmap->pages_covered;
DBUG_ASSERT(page != bitmap_page);
@@ -2079,7 +2079,7 @@ my_bool _ma_bitmap_set_full_page_bits(MA
uchar *data;
DBUG_ENTER("_ma_bitmap_set_full_page_bits");
DBUG_PRINT("enter", ("page: %lu page_count: %u", (ulong) page, page_count));
- safe_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&info->s->bitmap.bitmap_lock);
bitmap_page= page - page % bitmap->pages_covered;
if (bitmap_page != bitmap->page &&
@@ -2162,7 +2162,7 @@ void _ma_bitmap_flushable(MARIA_HA *info
bitmap= &share->bitmap;
if (non_flushable_inc == -1)
{
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_LOCK(&bitmap->bitmap_lock);
DBUG_ASSERT((int) bitmap->non_flushable > 0 &&
info->non_flushable_state == 1);
info->non_flushable_state= 0;
@@ -2177,11 +2177,11 @@ void _ma_bitmap_flushable(MARIA_HA *info
if (unlikely(bitmap->flush_all_requested))
{
DBUG_PRINT("info", ("bitmap flushable waking up flusher"));
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ MYSQL_COND_BROADCAST(&bitmap->bitmap_cond);
}
}
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
return;
}
DBUG_ASSERT(non_flushable_inc == 1 && info->non_flushable_state == 0);
@@ -2199,13 +2199,13 @@ void _ma_bitmap_flushable(MARIA_HA *info
our thread), it is not going to increase it more so is not going to come
here.
*/
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_LOCK(&bitmap->bitmap_lock);
while (bitmap->flush_all_requested)
{
DBUG_PRINT("info", ("waiting for bitmap flusher"));
- pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
+ MYSQL_COND_WAIT(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
}
/*
Ok to set without mutex: we didn't touch the bitmap's content yet; when we
@@ -2259,7 +2259,7 @@ my_bool _ma_bitmap_release_unused(MARIA_
*/
current_bitmap_value= FULL_HEAD_PAGE;
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_LOCK(&bitmap->bitmap_lock);
/* First handle head block */
if (block->used & BLOCKUSED_USED)
@@ -2332,17 +2332,17 @@ my_bool _ma_bitmap_release_unused(MARIA_
if (unlikely(bitmap->flush_all_requested))
{
DBUG_PRINT("info", ("bitmap flushable waking up flusher"));
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ MYSQL_COND_BROADCAST(&bitmap->bitmap_cond);
}
}
}
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
DBUG_RETURN(0);
err:
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
DBUG_RETURN(1);
}
@@ -2371,7 +2371,7 @@ my_bool _ma_bitmap_free_full_pages(MARIA
MARIA_FILE_BITMAP *bitmap= &info->s->bitmap;
DBUG_ENTER("_ma_bitmap_free_full_pages");
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_LOCK(&bitmap->bitmap_lock);
for (; count--; extents+= ROW_EXTENT_SIZE)
{
pgcache_page_no_t page= uint5korr(extents);
@@ -2385,12 +2385,12 @@ my_bool _ma_bitmap_free_full_pages(MARIA
page_count, PAGECACHE_LOCK_WRITE, 1) ||
_ma_bitmap_reset_full_page_bits(info, bitmap, page, page_count))
{
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
DBUG_RETURN(1);
}
}
}
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&bitmap->bitmap_lock);
DBUG_RETURN(0);
}
@@ -2418,12 +2418,12 @@ my_bool _ma_bitmap_set(MARIA_HA *info, p
my_bool res;
DBUG_ENTER("_ma_bitmap_set");
- pthread_mutex_lock(&info->s->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&info->s->bitmap.bitmap_lock);
bits= (head ?
_ma_free_size_to_head_pattern(bitmap, empty_space) :
free_size_to_tail_pattern(bitmap, empty_space));
res= set_page_bits(info, bitmap, page, bits);
- pthread_mutex_unlock(&info->s->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&info->s->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
=== modified file 'storage/maria/ma_blockrec.c'
--- a/storage/maria/ma_blockrec.c 2008-08-11 14:40:32 +0000
+++ b/storage/maria/ma_blockrec.c 2008-10-10 20:34:55 +0000
@@ -2285,10 +2285,10 @@ static my_bool extent_to_bitmap_blocks(M
else
{
my_bool res;
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
res= _ma_bitmap_set_full_page_bits(info, &share->bitmap,
block->page, block->page_count);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
if (res)
DBUG_RETURN(1);
block->used= BLOCKUSED_USED;
@@ -2438,10 +2438,10 @@ static my_bool free_full_page_range(MARI
log_data, NULL))
res= 1;
}
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
if (_ma_bitmap_reset_full_page_bits(info, &share->bitmap, page, count))
res= 1;
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -6274,10 +6274,10 @@ uint _ma_apply_redo_free_blocks(MARIA_HA
DBUG_PRINT("info", ("page: %lu pages: %u", (long) page, page_range));
/** @todo leave bitmap lock to the bitmap code... */
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
res= _ma_bitmap_reset_full_page_bits(info, &share->bitmap, start_page,
page_range);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
if (res)
{
_ma_mark_file_crashed(share);
@@ -6355,9 +6355,9 @@ uint _ma_apply_redo_free_head_or_tail(MA
push_dynamic(&info->pinned_pages, (void*) &page_link);
}
/** @todo leave bitmap lock to the bitmap code... */
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
res= _ma_bitmap_reset_full_page_bits(info, &share->bitmap, page, 1);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
if (res)
goto err;
DBUG_RETURN(0);
@@ -6531,10 +6531,10 @@ uint _ma_apply_redo_insert_row_blobs(MAR
goto err;
}
/** @todo leave bitmap lock to the bitmap code... */
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_LOCK(&share->bitmap.bitmap_lock);
res= _ma_bitmap_set_full_page_bits(info, &share->bitmap, start_page,
page_range);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ MYSQL_MUTEX_UNLOCK(&share->bitmap.bitmap_lock);
if (res)
goto err;
}
=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_check.c 2008-10-10 20:34:55 +0000
@@ -2988,10 +2988,10 @@ int maria_sort_index(HA_CHECK *param, re
/* Put same locks as old file */
share->r_locks= share->w_locks= share->tot_locks= 0;
(void) _ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
(void)(my_close(share->kfile.file, MYF(MY_WME)));
share->kfile.file = -1;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
(void) my_close(new_file,MYF(MY_WME));
if (maria_change_to_newfile(share->index_file_name.str, MARIA_NAME_IEXT,
INDEX_TMP_EXT, sync_dir) ||
@@ -4210,7 +4210,7 @@ int maria_repair_parallel(HA_CHECK *para
sort_param[0].calc_checksum= test(param->testflag & T_CALC_CHECKSUM);
sort_info.got_error=0;
- pthread_mutex_lock(&sort_info.mutex);
+ MYSQL_MUTEX_LOCK(&sort_info.mutex);
/*
Initialize the I/O cache share for use with the read caches and, in
@@ -4276,8 +4276,8 @@ int maria_repair_parallel(HA_CHECK *para
/* waiting for all threads to finish */
while (sort_info.threads_running)
- pthread_cond_wait(&sort_info.cond, &sort_info.mutex);
- pthread_mutex_unlock(&sort_info.mutex);
+ MYSQL_COND_WAIT(&sort_info.cond, &sort_info.mutex);
+ MYSQL_MUTEX_UNLOCK(&sort_info.mutex);
if ((got_error= _ma_thr_write_keys(sort_param)))
{
@@ -4427,8 +4427,8 @@ err:
share->state.changed&= ~(STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_ZEROFILLED |
STATE_NOT_MOVABLE);
- pthread_cond_destroy (&sort_info.cond);
- pthread_mutex_destroy(&sort_info.mutex);
+ MYSQL_COND_DESTROY (&sort_info.cond);
+ MYSQL_MUTEX_DESTROY(&sort_info.mutex);
my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
my_free((uchar*) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR));
=== modified file 'storage/maria/ma_checkpoint.c'
--- a/storage/maria/ma_checkpoint.c 2008-08-25 11:49:47 +0000
+++ b/storage/maria/ma_checkpoint.c 2008-10-10 20:34:55 +0000
@@ -40,9 +40,9 @@
/** @brief type of checkpoint currently running */
static CHECKPOINT_LEVEL checkpoint_in_progress= CHECKPOINT_NONE;
/** @brief protects checkpoint_in_progress */
-static pthread_mutex_t LOCK_checkpoint;
+static mysql_mutex_t LOCK_checkpoint;
/** @brief for killing the background checkpoint thread */
-static pthread_cond_t COND_checkpoint;
+static mysql_cond_t COND_checkpoint;
/** @brief if checkpoint module was inited or not */
static my_bool checkpoint_inited= FALSE;
/** @brief 'kill' flag for the background checkpoint thread */
@@ -109,7 +109,7 @@ int ma_checkpoint_execute(CHECKPOINT_LEV
DBUG_ASSERT(level > CHECKPOINT_NONE);
/* look for already running checkpoints */
- pthread_mutex_lock(&LOCK_checkpoint);
+ MYSQL_MUTEX_LOCK(&LOCK_checkpoint);
while (checkpoint_in_progress != CHECKPOINT_NONE)
{
if (no_wait && (checkpoint_in_progress >= level))
@@ -119,18 +119,18 @@ int ma_checkpoint_execute(CHECKPOINT_LEV
smarter to flush pages instead of waiting here while the other thread
finishes its checkpoint).
*/
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
goto end;
}
- pthread_cond_wait(&COND_checkpoint, &LOCK_checkpoint);
+ MYSQL_COND_WAIT(&COND_checkpoint, &LOCK_checkpoint);
}
checkpoint_in_progress= level;
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
/* from then on, we are sure to be and stay the only checkpointer */
result= really_execute_checkpoint();
- pthread_cond_broadcast(&COND_checkpoint);
+ MYSQL_COND_BROADCAST(&COND_checkpoint);
end:
DBUG_RETURN(result);
}
@@ -291,11 +291,11 @@ err:
end:
for (i= 0; i < (sizeof(record_pieces)/sizeof(record_pieces[0])); i++)
my_free(record_pieces[i].str, MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_lock(&LOCK_checkpoint);
+ MYSQL_MUTEX_LOCK(&LOCK_checkpoint);
checkpoint_in_progress= CHECKPOINT_NONE;
checkpoints_total++;
checkpoints_ok_total+= !error;
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
DBUG_RETURN(error);
}
@@ -355,7 +355,7 @@ static void flush_all_tables(int what_to
{
int res= 0;
LIST *pos; /**< to iterate over open tables */
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
for (pos= maria_open_list; pos; pos= pos->next)
{
MARIA_HA *info= (MARIA_HA*)pos->data;
@@ -380,7 +380,7 @@ static void flush_all_tables(int what_to
}
DBUG_ASSERT(res == 0);
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
}
#endif
@@ -425,7 +425,7 @@ void ma_checkpoint_end(void)
if (checkpoint_inited)
{
- pthread_mutex_lock(&LOCK_checkpoint);
+ MYSQL_MUTEX_LOCK(&LOCK_checkpoint);
if (checkpoint_thread_die != 2) /* thread was started ok */
{
DBUG_PRINT("info",("killing Maria background checkpoint thread"));
@@ -433,19 +433,19 @@ void ma_checkpoint_end(void)
do /* and wait for it to be dead */
{
/* wake it up if it was in a sleep */
- pthread_cond_broadcast(&COND_checkpoint);
+ MYSQL_COND_BROADCAST(&COND_checkpoint);
DBUG_PRINT("info",("waiting for Maria background checkpoint thread"
" to die"));
- pthread_cond_wait(&COND_checkpoint, &LOCK_checkpoint);
+ MYSQL_COND_WAIT(&COND_checkpoint, &LOCK_checkpoint);
}
while (checkpoint_thread_die != 2);
}
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
my_free((uchar *)dfiles, MYF(MY_ALLOW_ZERO_PTR));
my_free((uchar *)kfiles, MYF(MY_ALLOW_ZERO_PTR));
dfiles= kfiles= NULL;
- pthread_mutex_destroy(&LOCK_checkpoint);
- pthread_cond_destroy(&COND_checkpoint);
+ MYSQL_MUTEX_DESTROY(&LOCK_checkpoint);
+ MYSQL_COND_DESTROY(&COND_checkpoint);
checkpoint_inited= FALSE;
}
DBUG_VOID_RETURN;
@@ -691,25 +691,25 @@ pthread_handler_t ma_checkpoint_backgrou
sleep_time= interval - (sleeps % interval);
}
}
- pthread_mutex_lock(&LOCK_checkpoint);
+ MYSQL_MUTEX_LOCK(&LOCK_checkpoint);
if (checkpoint_thread_die == 1)
break;
#if 0 /* good for testing, to do a lot of checkpoints, finds a lot of bugs */
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
my_sleep(100000); /* a tenth of a second */
- pthread_mutex_lock(&LOCK_checkpoint);
+ MYSQL_MUTEX_LOCK(&LOCK_checkpoint);
#else
/* To have a killable sleep, we use timedwait like our SQL GET_LOCK() */
DBUG_PRINT("info", ("sleeping %u seconds", sleep_time));
set_timespec(abstime, sleep_time);
- pthread_cond_timedwait(&COND_checkpoint, &LOCK_checkpoint, &abstime);
+ MYSQL_COND_TIMEDWAIT(&COND_checkpoint, &LOCK_checkpoint, &abstime);
#endif
if (checkpoint_thread_die == 1)
break;
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
sleeps+= sleep_time;
}
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
DBUG_PRINT("info",("Maria background checkpoint thread ends"));
{
CHECKPOINT_LEVEL level= CHECKPOINT_FULL;
@@ -720,12 +720,12 @@ pthread_handler_t ma_checkpoint_backgrou
DBUG_EXECUTE_IF("maria_checkpoint_indirect", level= CHECKPOINT_INDIRECT;);
ma_checkpoint_execute(level, FALSE);
}
- pthread_mutex_lock(&LOCK_checkpoint);
+ MYSQL_MUTEX_LOCK(&LOCK_checkpoint);
checkpoint_thread_die= 2; /* indicate that we are dead */
/* wake up ma_checkpoint_end() which may be waiting for our death */
- pthread_cond_broadcast(&COND_checkpoint);
+ MYSQL_COND_BROADCAST(&COND_checkpoint);
/* broadcast was inside unlock because ma_checkpoint_end() destroys mutex */
- pthread_mutex_unlock(&LOCK_checkpoint);
+ MYSQL_MUTEX_UNLOCK(&LOCK_checkpoint);
my_thread_end();
return 0;
}
@@ -773,7 +773,7 @@ static int collect_tables(LEX_STRING *st
LINT_INIT(state_copies_horizon);
/* let's make a list of distinct shares */
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
for (nb= 0, pos= maria_open_list; pos; pos= pos->next)
{
MARIA_HA *info= (MARIA_HA*)pos->data;
@@ -825,7 +825,7 @@ static int collect_tables(LEX_STRING *st
}
DBUG_ASSERT(i == nb);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
DBUG_PRINT("info",("found %u table shares", nb));
str->length=
@@ -956,7 +956,7 @@ static int collect_tables(LEX_STRING *st
/* OS file descriptors are ints which we stored in 4 bytes */
compile_time_assert(sizeof(int) <= 4);
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
/*
Tables in a normal state have their two file descriptors open.
In some rare cases like REPAIR, some descriptor may be closed or even
@@ -1058,22 +1058,22 @@ static int collect_tables(LEX_STRING *st
TODO: Only do this call if there has been # (10?) ended transactions
since last call.
*/
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
_ma_remove_not_visible_states_with_lock(share);
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->in_checkpoint & MARIA_CHECKPOINT_SHOULD_FREE_ME)
{
/* maria_close() left us to free the share */
- pthread_mutex_unlock(&share->intern_lock);
- pthread_mutex_destroy(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
+ MYSQL_MUTEX_DESTROY(&share->intern_lock);
my_free((uchar *)share, MYF(0));
}
else
{
/* share goes back to normal state */
share->in_checkpoint= 0;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
/*
@@ -1172,14 +1172,14 @@ err:
if (unlikely(unmark_tables))
{
/* maria_close() uses THR_LOCK_maria from start to end */
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
for (i= 0; i < nb; i++)
{
MARIA_SHARE *share= distinct_shares[i];
if (share->in_checkpoint & MARIA_CHECKPOINT_SHOULD_FREE_ME)
{
/* maria_close() left us to free the share */
- pthread_mutex_destroy(&share->intern_lock);
+ MYSQL_MUTEX_DESTROY(&share->intern_lock);
my_free((uchar *)share, MYF(0));
}
else
@@ -1188,7 +1188,7 @@ err:
share->in_checkpoint= 0;
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
}
my_free((uchar *)distinct_shares, MYF(MY_ALLOW_ZERO_PTR));
my_free((uchar *)state_copies, MYF(MY_ALLOW_ZERO_PTR));
=== modified file 'storage/maria/ma_close.c'
--- a/storage/maria/ma_close.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_close.c 2008-10-10 20:34:55 +0000
@@ -35,7 +35,7 @@ int maria_close(register MARIA_HA *info)
/* Check that we have unlocked key delete-links properly */
DBUG_ASSERT(info->used_key_del == 0);
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
@@ -47,7 +47,7 @@ int maria_close(register MARIA_HA *info)
if (maria_lock_database(info,F_UNLCK))
error=my_errno;
}
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->options & HA_OPTION_READ_ONLY_DATA)
{
@@ -117,9 +117,9 @@ int maria_close(register MARIA_HA *info)
{
int i,keys;
keys = share->state.header.keys;
- (void)(rwlock_destroy(&share->mmap_lock));
+ (void)(MYSQL_RWLOCK_DESTROY(&share->mmap_lock));
for(i=0; i<keys; i++) {
- (void)(rwlock_destroy(&share->keyinfo[i].root_lock));
+ (void)(MYSQL_RWLOCK_DESTROY(&share->keyinfo[i].root_lock));
}
}
#endif
@@ -158,11 +158,11 @@ int maria_close(register MARIA_HA *info)
}
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
if (share_can_be_freed)
{
- (void)(pthread_mutex_destroy(&share->intern_lock));
+ (void)(MYSQL_MUTEX_DESTROY(&share->intern_lock));
my_free((uchar *)share, MYF(0));
}
if (info->ftparser_param)
=== modified file 'storage/maria/ma_create.c'
--- a/storage/maria/ma_create.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_create.c 2008-10-10 20:34:55 +0000
@@ -766,7 +766,7 @@ int maria_create(const char *name, enum
if (! (flags & HA_DONT_TOUCH_DATA))
share.state.create_time= (long) time((time_t*) 0);
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
/*
NOTE: For test_if_reopen() we need a real path name. Hence we need
@@ -1134,7 +1134,7 @@ int maria_create(const char *name, enum
if (my_close(dfile,MYF(0)))
goto err;
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
res= 0;
my_free((char*) rec_per_key_part,MYF(0));
errpos=0;
@@ -1143,7 +1143,7 @@ int maria_create(const char *name, enum
DBUG_RETURN(res);
err:
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
err_no_lock:
save_errno=my_errno;
@@ -1301,10 +1301,10 @@ int _ma_update_state_lsns(MARIA_SHARE *s
my_bool do_sync, my_bool update_create_rename_lsn)
{
int res;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
res= _ma_update_state_lsns_sub(share, lsn, create_trid, do_sync,
update_create_rename_lsn);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
return res;
}
=== modified file 'storage/maria/ma_dynrec.c'
--- a/storage/maria/ma_dynrec.c 2008-06-05 16:11:22 +0000
+++ b/storage/maria/ma_dynrec.c 2008-10-10 20:34:55 +0000
@@ -137,7 +137,7 @@ size_t _ma_mmap_pread(MARIA_HA *info, uc
{
DBUG_PRINT("info", ("maria_read with mmap %d\n", info->dfile.file));
if (info->s->lock_key_trees)
- rw_rdlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_RDLOCK(&info->s->mmap_lock);
/*
The following test may fail in the following cases:
@@ -150,13 +150,13 @@ size_t _ma_mmap_pread(MARIA_HA *info, uc
{
memcpy(Buffer, info->s->file_map + offset, Count);
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
return 0;
}
else
{
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
return my_pread(info->dfile.file, Buffer, Count, offset, MyFlags);
}
}
@@ -192,7 +192,7 @@ size_t _ma_mmap_pwrite(MARIA_HA *info, c
{
DBUG_PRINT("info", ("maria_write with mmap %d\n", info->dfile.file));
if (info->s->lock_key_trees)
- rw_rdlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_RDLOCK(&info->s->mmap_lock);
/*
The following test may fail in the following cases:
@@ -205,14 +205,14 @@ size_t _ma_mmap_pwrite(MARIA_HA *info, c
{
memcpy(info->s->file_map + offset, Buffer, Count);
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
return 0;
}
else
{
info->s->nonmmaped_inserts++;
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
return my_pwrite(info->dfile.file, Buffer, Count, offset, MyFlags);
}
=== modified file 'storage/maria/ma_extra.c'
--- a/storage/maria/ma_extra.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_extra.c 2008-10-10 20:34:55 +0000
@@ -80,17 +80,17 @@ int maria_extra(MARIA_HA *info, enum ha_
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if ((share->options & HA_OPTION_COMPRESS_RECORD))
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (_ma_memmap_file(info))
{
/* We don't nead MADV_SEQUENTIAL if small file */
madvise((char*) share->file_map, share->state.state.data_file_length,
share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
MADV_RANDOM : MADV_SEQUENTIAL);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
break;
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
#endif
if (info->opt_flag & WRITE_CACHE_USED)
@@ -232,10 +232,10 @@ int maria_extra(MARIA_HA *info, enum ha_
break;
case HA_EXTRA_NO_KEYS:
/* we're going to modify pieces of the state, stall Checkpoint */
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (info->lock_type == F_UNLCK)
{
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
error= 1; /* Not possibly if not lock */
break;
}
@@ -274,7 +274,7 @@ int maria_extra(MARIA_HA *info, enum ha_
DBUG_ASSERT(!maria_in_recovery);
error= _ma_state_info_write(share, 1|2);
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
break;
case HA_EXTRA_FORCE_REOPEN:
/*
@@ -288,24 +288,24 @@ int maria_extra(MARIA_HA *info, enum ha_
FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE);
if (!error && share->changed)
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (!(error= _ma_state_info_write(share, 1|2)))
share->changed= 0;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
- pthread_mutex_lock(&THR_LOCK_maria);
- pthread_mutex_lock(&share->intern_lock); /* protect against Checkpoint */
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&share->intern_lock); /* protect against Checkpoint */
/* this makes the share not be re-used next time the table is opened */
share->last_version= 0L; /* Impossible version */
- pthread_mutex_unlock(&share->intern_lock);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
break;
case HA_EXTRA_PREPARE_FOR_DROP:
case HA_EXTRA_PREPARE_FOR_RENAME:
{
my_bool do_flush= test(function != HA_EXTRA_PREPARE_FOR_DROP);
enum flush_type type;
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
/*
This share, to have last_version=0, needs to save all its data/index
blocks to disk if this is not for a DROP TABLE. Otherwise they would be
@@ -321,7 +321,7 @@ int maria_extra(MARIA_HA *info, enum ha_
}
if (share->kfile.file >= 0)
_ma_decrement_open_count(info);
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (info->trn)
{
_ma_remove_table_from_trnman(share, info->trn);
@@ -367,8 +367,8 @@ int maria_extra(MARIA_HA *info, enum ha_
}
/* For protection against Checkpoint, we set under intern_lock: */
share->last_version= 0L; /* Impossible version */
- pthread_mutex_unlock(&share->intern_lock);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
break;
}
case HA_EXTRA_FLUSH:
@@ -412,7 +412,7 @@ int maria_extra(MARIA_HA *info, enum ha_
#ifdef HAVE_MMAP
if (block_records)
break; /* Not supported */
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
/*
Memory map the data file if it is not already mapped. It is safe
to memory map a file while other threads are using file I/O on it.
@@ -433,13 +433,13 @@ int maria_extra(MARIA_HA *info, enum ha_
share->file_write= _ma_mmap_pwrite;
}
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
#endif
break;
case HA_EXTRA_MARK_AS_LOG_TABLE:
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->is_log_table= TRUE;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
break;
case HA_EXTRA_KEY_CACHE:
case HA_EXTRA_NO_KEY_CACHE:
=== modified file 'storage/maria/ma_info.c'
--- a/storage/maria/ma_info.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_info.c 2008-10-10 20:34:55 +0000
@@ -42,10 +42,10 @@ int maria_status(MARIA_HA *info, registe
DBUG_RETURN(0); /* Compatible with ISAM */
if (!(flag & HA_STATUS_NO_LOCK))
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
(void)(_ma_readinfo(info,F_RDLCK,0));
fast_ma_writeinfo(info);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
if (flag & HA_STATUS_VARIABLE)
{
=== modified file 'storage/maria/ma_init.c'
--- a/storage/maria/ma_init.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_init.c 2008-10-10 20:34:55 +0000
@@ -96,7 +96,7 @@ void maria_end(void)
end_pagecache(maria_log_pagecache, TRUE);
end_pagecache(maria_pagecache, TRUE);
ma_control_file_end();
- pthread_mutex_destroy(&THR_LOCK_maria);
+ MYSQL_MUTEX_DESTROY(&THR_LOCK_maria);
hash_free(&maria_stored_state);
}
}
=== modified file 'storage/maria/ma_key_recover.c'
--- a/storage/maria/ma_key_recover.c 2008-07-09 09:02:27 +0000
+++ b/storage/maria/ma_key_recover.c 2008-10-10 20:34:55 +0000
@@ -1251,21 +1251,21 @@ my_bool _ma_lock_key_del(MARIA_HA *info,
*/
if (info->used_key_del != 1)
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->state.key_del == HA_OFFSET_ERROR && insert_at_end)
{
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
info->used_key_del= 2; /* insert-with-append */
return 1;
}
#ifdef THREAD
while (share->used_key_del)
- pthread_cond_wait(&share->intern_cond, &share->intern_lock);
+ MYSQL_COND_WAIT(&share->intern_cond, &share->intern_lock);
#endif
info->used_key_del= 1;
share->used_key_del= 1;
share->current_key_del= share->state.key_del;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
return share->current_key_del == HA_OFFSET_ERROR;
}
@@ -1281,11 +1281,11 @@ void _ma_unlock_key_del(MARIA_HA *info)
if (info->used_key_del == 1) /* Ignore insert-with-append */
{
MARIA_SHARE *share= info->s;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->used_key_del= 0;
share->state.key_del= share->current_key_del;
- pthread_mutex_unlock(&share->intern_lock);
- pthread_cond_signal(&share->intern_cond);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
+ MYSQL_COND_SIGNAL(&share->intern_cond);
}
info->used_key_del= 0;
}
=== modified file 'storage/maria/ma_keycache.c'
--- a/storage/maria/ma_keycache.c 2008-08-25 11:49:47 +0000
+++ b/storage/maria/ma_keycache.c 2008-10-10 20:34:55 +0000
@@ -97,7 +97,7 @@ int maria_assign_to_pagecache(MARIA_HA *
ensure that setting the key cache and changing the multi_pagecache
is done atomicly
*/
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
/*
Tell all threads to use the new key cache
This should be seen at the lastes for the next call to an maria function.
@@ -109,7 +109,7 @@ int maria_assign_to_pagecache(MARIA_HA *
share->unique_file_name.length,
share->pagecache))
error= my_errno;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
DBUG_RETURN(error);
}
@@ -144,7 +144,7 @@ void maria_change_pagecache(PAGECACHE *o
/*
Lock list to ensure that no one can close the table while we manipulate it
*/
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info= (MARIA_HA*) pos->data;
@@ -159,6 +159,6 @@ void maria_change_pagecache(PAGECACHE *o
open a new table that will be associted with the old key cache
*/
multi_pagecache_change(old_pagecache, new_pagecache);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
DBUG_VOID_RETURN;
}
=== modified file 'storage/maria/ma_locking.c'
--- a/storage/maria/ma_locking.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_locking.c 2008-10-10 20:34:55 +0000
@@ -47,7 +47,7 @@ int maria_lock_database(MARIA_HA *info,
}
error=0;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->kfile.file >= 0) /* May only be false on windows */
{
switch (lock_type) {
@@ -97,11 +97,11 @@ int maria_lock_database(MARIA_HA *info,
(share->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
{
if (share->lock_key_trees)
- rw_wrlock(&share->mmap_lock);
+ MYSQL_RWLOCK_WRLOCK(&share->mmap_lock);
_ma_remap_file(info, share->state.state.data_file_length);
share->nonmmaped_inserts= 0;
if (share->lock_key_trees)
- rw_unlock(&share->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&share->mmap_lock);
}
#endif
#ifdef EXTERNAL_LOCKING
@@ -237,7 +237,7 @@ int maria_lock_database(MARIA_HA *info,
}
}
#endif
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
DBUG_RETURN(error);
} /* maria_lock_database */
=== modified file 'storage/maria/ma_loghandler.c'
--- a/storage/maria/ma_loghandler.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_loghandler.c 2008-10-10 20:34:55 +0000
@@ -129,7 +129,7 @@ struct st_translog_buffer
/* File handler for this buffer */
TRANSLOG_FILE *file;
/* Threads which are waiting for buffer filling/freeing */
- pthread_cond_t waiting_filling_buffer;
+ mysql_cond_t waiting_filling_buffer;
/* Number of records which are in copy progress */
uint copy_to_buffer_in_progress;
/* list of waiting buffer ready threads */
@@ -164,7 +164,7 @@ struct st_translog_buffer
Because of above and number of buffers equal 5 we can't get dead lock (it is
impossible to get all 5 buffers locked simultaneously).
*/
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
/*
Some thread is going to close the buffer and it should be
done only by that thread
@@ -249,7 +249,7 @@ struct st_translog_descriptor
/* min/max number of file in the array */
uint32 max_file, min_file;
/* the opened files list guard */
- rw_lock_t open_files_lock;
+ mysql_rwlock_t open_files_lock;
/*
File descriptor of the directory where we store log files for syncing
@@ -261,7 +261,7 @@ struct st_translog_descriptor
/* Mask where 1 in position N mean that buffer N is not flushed */
dirty_buffer_mask_t dirty_buffer_mask;
/* The above variable protection */
- pthread_mutex_t dirty_buffer_mask_lock;
+ mysql_mutex_t dirty_buffer_mask_lock;
/*
horizon - visible end of the log (here is absolute end of the log:
position where next chunk can start
@@ -287,22 +287,22 @@ struct st_translog_descriptor
/* All what is after this address is not sent to disk yet */
TRANSLOG_ADDRESS in_buffers_only;
/* protection of sent_to_disk and in_buffers_only */
- pthread_mutex_t sent_to_disk_lock;
+ mysql_mutex_t sent_to_disk_lock;
/*
Protect flushed (see above) and for flush serialization (will
be removed in v1.5
*/
- pthread_mutex_t log_flush_lock;
- pthread_cond_t log_flush_cond;
+ mysql_mutex_t log_flush_lock;
+ mysql_cond_t log_flush_cond;
/* Protects changing of headers of finished files (max_lsn) */
- pthread_mutex_t file_header_lock;
+ mysql_mutex_t file_header_lock;
/*
Sorted array (with protection) of files where we started writing process
and so we can't give last LSN yet
*/
- pthread_mutex_t unfinished_files_lock;
+ mysql_mutex_t unfinished_files_lock;
DYNAMIC_ARRAY unfinished_files;
/*
@@ -313,7 +313,7 @@ struct st_translog_descriptor
/* Purger data: minimum file in the log (or 0 if unknown) */
uint32 min_file_number;
/* Protect purger from many calls and it's data */
- pthread_mutex_t purger_lock;
+ mysql_mutex_t purger_lock;
/* last low water mark checked */
LSN last_lsn_checked;
/**
@@ -381,9 +381,9 @@ LOG_DESC log_record_type_descriptor[LOGR
#ifndef DBUG_OFF
#define translog_buffer_lock_assert_owner(B) \
- safe_mutex_assert_owner(&(B)->mutex)
+ MYSQL_MUTEX_ASSERT_OWNER(&(B)->mutex)
#define translog_lock_assert_owner() \
- safe_mutex_assert_owner(&log_descriptor.bc.buffer->mutex)
+ MYSQL_MUTEX_ASSERT_OWNER(&log_descriptor.bc.buffer->mutex)
void translog_lock_handler_assert_owner()
{
translog_lock_assert_owner();
@@ -928,12 +928,12 @@ static TRANSLOG_FILE *get_logfile_by_num
{
TRANSLOG_FILE *file;
DBUG_ENTER("get_logfile_by_number");
- rw_rdlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_RDLOCK(&log_descriptor.open_files_lock);
if (log_descriptor.max_file - file_no >=
log_descriptor.open_files.elements)
{
DBUG_PRINT("info", ("File #%u is not opened", file_no));
- rw_unlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_UNLOCK(&log_descriptor.open_files_lock);
DBUG_RETURN(NULL);
}
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
@@ -943,7 +943,7 @@ static TRANSLOG_FILE *get_logfile_by_num
file= *dynamic_element(&log_descriptor.open_files,
log_descriptor.max_file - file_no, TRANSLOG_FILE **);
- rw_unlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_UNLOCK(&log_descriptor.open_files_lock);
DBUG_PRINT("info", ("File 0x%lx File no: %lu, File handler: %d",
(ulong)file, (ulong)file_no,
(file ? file->handler.file : -1)));
@@ -961,11 +961,11 @@ static TRANSLOG_FILE *get_logfile_by_num
static TRANSLOG_FILE *get_current_logfile()
{
TRANSLOG_FILE *file;
- rw_rdlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_RDLOCK(&log_descriptor.open_files_lock);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
file= *dynamic_element(&log_descriptor.open_files, 0, TRANSLOG_FILE **);
- rw_unlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_UNLOCK(&log_descriptor.open_files_lock);
return (file);
}
@@ -1188,7 +1188,7 @@ static my_bool translog_set_lsn_for_file
translog_unlock();
/* Checks finished files if they are */
- pthread_mutex_lock(&log_descriptor.file_header_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.file_header_lock);
for (file= from_file; file <= to_file; file++)
{
LOGHANDLER_FILE_INFO info;
@@ -1203,7 +1203,7 @@ static my_bool translog_set_lsn_for_file
DBUG_RETURN(1);
}
}
- pthread_mutex_unlock(&log_descriptor.file_header_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.file_header_lock);
DBUG_RETURN(0);
}
@@ -1232,7 +1232,7 @@ static void translog_mark_file_unfinishe
DBUG_PRINT("enter", ("file: %lu", (ulong) file));
fc.file= file; fc.counter= 1;
- pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.unfinished_files_lock);
if (log_descriptor.unfinished_files.elements == 0)
{
@@ -1283,7 +1283,7 @@ static void translog_mark_file_unfinishe
place + 1, struct st_file_counter *),
&fc, sizeof(struct st_file_counter));
end:
- pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.unfinished_files_lock);
DBUG_VOID_RETURN;
}
@@ -1303,7 +1303,7 @@ static void translog_mark_file_finished(
LINT_INIT(fc_ptr);
- pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.unfinished_files_lock);
DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0);
for (i= 0;
@@ -1321,7 +1321,7 @@ static void translog_mark_file_finished(
if (! --fc_ptr->counter)
delete_dynamic_element(&log_descriptor.unfinished_files, i);
- pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.unfinished_files_lock);
DBUG_VOID_RETURN;
}
@@ -1345,7 +1345,7 @@ LSN translog_get_file_max_lsn_stored(uin
DBUG_ASSERT(translog_status == TRANSLOG_OK ||
translog_status == TRANSLOG_READONLY);
- pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.unfinished_files_lock);
/* find file with minimum file number "in progress" */
if (log_descriptor.unfinished_files.elements > 0)
@@ -1355,7 +1355,7 @@ LSN translog_get_file_max_lsn_stored(uin
0, struct st_file_counter *);
limit= fc_ptr->file; /* minimal file number "in progress" */
}
- pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.unfinished_files_lock);
/*
if there is no "in progress file" then unfinished file is in progress
@@ -1521,7 +1521,7 @@ static my_bool translog_create_new_file(
if (translog_max_lsn_to_header(old->handler.file, log_descriptor.max_lsn))
goto error;
- rw_wrlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_WRLOCK(&log_descriptor.open_files_lock);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
DBUG_ASSERT(file_no == log_descriptor.max_file + 1);
@@ -1547,7 +1547,7 @@ static my_bool translog_create_new_file(
set_dynamic(&log_descriptor.open_files, (uchar*)&file, 0);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
- rw_unlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_UNLOCK(&log_descriptor.open_files_lock);
DBUG_PRINT("info", ("file_no: %lu", (ulong)file_no));
@@ -1565,7 +1565,7 @@ static my_bool translog_create_new_file(
DBUG_RETURN(0);
error_lock:
- rw_unlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_UNLOCK(&log_descriptor.open_files_lock);
error:
translog_stop_writing();
DBUG_RETURN(1);
@@ -1589,7 +1589,7 @@ static void translog_buffer_lock(struct
DBUG_PRINT("enter",
("Lock buffer #%u: (0x%lx)", (uint) buffer->buffer_no,
(ulong) buffer));
- pthread_mutex_lock(&buffer->mutex);
+ MYSQL_MUTEX_LOCK(&buffer->mutex);
DBUG_VOID_RETURN;
}
@@ -1612,7 +1612,7 @@ static void translog_buffer_unlock(struc
DBUG_PRINT("enter", ("Unlock buffer... #%u (0x%lx)",
(uint) buffer->buffer_no, (ulong) buffer));
- pthread_mutex_unlock(&buffer->mutex);
+ MYSQL_MUTEX_UNLOCK(&buffer->mutex);
DBUG_VOID_RETURN;
}
@@ -1873,7 +1873,7 @@ static void translog_wait_for_closing(st
DBUG_PRINT("info", ("wait for writers... buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
DBUG_ASSERT(buffer->file != NULL);
- pthread_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
+ MYSQL_COND_WAIT(&buffer->waiting_filling_buffer, &buffer->mutex);
DBUG_PRINT("info", ("wait for writers done buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
}
@@ -1905,7 +1905,7 @@ static void translog_wait_for_writers(st
DBUG_PRINT("info", ("wait for writers... buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
DBUG_ASSERT(buffer->file != NULL);
- pthread_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
+ MYSQL_COND_WAIT(&buffer->waiting_filling_buffer, &buffer->mutex);
DBUG_PRINT("info", ("wait for writers done buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
}
@@ -1949,7 +1949,7 @@ static void translog_wait_for_buffer_fre
{
DBUG_PRINT("info", ("wait for writers... buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
- pthread_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
+ MYSQL_COND_WAIT(&buffer->waiting_filling_buffer, &buffer->mutex);
DBUG_PRINT("info", ("wait for writers done. buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
}
@@ -2021,9 +2021,9 @@ static void translog_start_buffer(struct
cursor->chaser, (ulong) cursor->buffer->size,
(ulong) (cursor->ptr - cursor->buffer->buffer)));
translog_check_cursor(cursor);
- pthread_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.dirty_buffer_mask_lock);
log_descriptor.dirty_buffer_mask|= (1 << buffer->buffer_no);
- pthread_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.dirty_buffer_mask_lock);
DBUG_VOID_RETURN;
}
@@ -2126,7 +2126,7 @@ static my_bool translog_buffer_next(TRAN
static void translog_set_sent_to_disk(LSN lsn, TRANSLOG_ADDRESS in_buffers)
{
DBUG_ENTER("translog_set_sent_to_disk");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.sent_to_disk_lock);
DBUG_PRINT("enter", ("lsn: (%lu,0x%lx) in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx) start: (%lu,0x%lx) "
"sent_to_disk: (%lu,0x%lx)",
@@ -2149,7 +2149,7 @@ static void translog_set_sent_to_disk(LS
log_descriptor.in_buffers_only= in_buffers;
DBUG_PRINT("info", ("set new in_buffers_only"));
}
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.sent_to_disk_lock);
DBUG_VOID_RETURN;
}
@@ -2166,7 +2166,7 @@ static void translog_set_sent_to_disk(LS
static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers)
{
DBUG_ENTER("translog_set_only_in_buffers");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.sent_to_disk_lock);
DBUG_PRINT("enter", ("in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx)",
LSN_IN_PARTS(in_buffers),
@@ -2179,7 +2179,7 @@ static void translog_set_only_in_buffers
log_descriptor.in_buffers_only= in_buffers;
DBUG_PRINT("info", ("set new in_buffers_only"));
}
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.sent_to_disk_lock);
DBUG_VOID_RETURN;
}
@@ -2198,9 +2198,9 @@ static TRANSLOG_ADDRESS translog_only_in
{
register TRANSLOG_ADDRESS addr;
DBUG_ENTER("translog_only_in_buffers");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.sent_to_disk_lock);
addr= log_descriptor.in_buffers_only;
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.sent_to_disk_lock);
DBUG_RETURN(addr);
}
@@ -2219,10 +2219,10 @@ static LSN translog_get_sent_to_disk()
{
register LSN lsn;
DBUG_ENTER("translog_get_sent_to_disk");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.sent_to_disk_lock);
lsn= log_descriptor.sent_to_disk;
DBUG_PRINT("info", ("sent to disk up to (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.sent_to_disk_lock);
DBUG_RETURN(lsn);
}
@@ -2561,10 +2561,10 @@ static my_bool translog_buffer_flush(str
buffer->file= NULL;
buffer->overlay= 0;
buffer->ver++;
- pthread_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.dirty_buffer_mask_lock);
log_descriptor.dirty_buffer_mask&= ~(1 << buffer->buffer_no);
- pthread_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
- pthread_cond_broadcast(&buffer->waiting_filling_buffer);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.dirty_buffer_mask_lock);
+ MYSQL_COND_BROADCAST(&buffer->waiting_filling_buffer);
DBUG_RETURN(0);
}
@@ -4025,8 +4025,8 @@ static void translog_buffer_destroy(stru
translog_buffer_unlock(buffer);
}
DBUG_PRINT("info", ("Destroy mutex: 0x%lx", (ulong) &buffer->mutex));
- pthread_mutex_destroy(&buffer->mutex);
- pthread_cond_destroy(&buffer->waiting_filling_buffer);
+ MYSQL_MUTEX_DESTROY(&buffer->mutex);
+ MYSQL_COND_DESTROY(&buffer->waiting_filling_buffer);
DBUG_VOID_RETURN;
}
@@ -4068,14 +4068,14 @@ void translog_destroy()
/* close files */
while ((file= (TRANSLOG_FILE **)pop_dynamic(&log_descriptor.open_files)))
translog_close_log_file(*file);
- pthread_mutex_destroy(&log_descriptor.sent_to_disk_lock);
- pthread_mutex_destroy(&log_descriptor.file_header_lock);
- pthread_mutex_destroy(&log_descriptor.unfinished_files_lock);
- pthread_mutex_destroy(&log_descriptor.purger_lock);
- pthread_mutex_destroy(&log_descriptor.log_flush_lock);
- pthread_mutex_destroy(&log_descriptor.dirty_buffer_mask_lock);
- pthread_cond_destroy(&log_descriptor.log_flush_cond);
- rwlock_destroy(&log_descriptor.open_files_lock);
+ MYSQL_MUTEX_DESTROY(&log_descriptor.sent_to_disk_lock);
+ MYSQL_MUTEX_DESTROY(&log_descriptor.file_header_lock);
+ MYSQL_MUTEX_DESTROY(&log_descriptor.unfinished_files_lock);
+ MYSQL_MUTEX_DESTROY(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_DESTROY(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_DESTROY(&log_descriptor.dirty_buffer_mask_lock);
+ MYSQL_COND_DESTROY(&log_descriptor.log_flush_cond);
+ MYSQL_RWLOCK_DESTROY(&log_descriptor.open_files_lock);
delete_dynamic(&log_descriptor.open_files);
delete_dynamic(&log_descriptor.unfinished_files);
@@ -4372,7 +4372,7 @@ static void translog_buffer_decrease_wri
(uint) buffer->buffer_no, (ulong) buffer,
buffer->copy_to_buffer_in_progress));
if (buffer->copy_to_buffer_in_progress == 0)
- pthread_cond_broadcast(&buffer->waiting_filling_buffer);
+ MYSQL_COND_BROADCAST(&buffer->waiting_filling_buffer);
DBUG_VOID_RETURN;
}
@@ -7417,7 +7417,7 @@ static void translog_force_current_buffe
old_buffer->is_closing_buffer= 0;
DBUG_PRINT("enter", ("Buffer #%u 0x%lx is_closing_buffer cleared",
(uint) old_buffer->buffer_no, (ulong) old_buffer));
- pthread_cond_broadcast(&old_buffer->waiting_filling_buffer);
+ MYSQL_COND_BROADCAST(&old_buffer->waiting_filling_buffer);
if (left)
{
@@ -7448,9 +7448,9 @@ void translog_flush_wait_for_end(LSN ls
{
DBUG_ENTER("translog_flush_wait_for_end");
DBUG_PRINT("enter", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
- safe_mutex_assert_owner(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&log_descriptor.log_flush_lock);
while (cmp_translog_addr(log_descriptor.flushed, lsn) < 0)
- pthread_cond_wait(&log_descriptor.log_flush_cond,
+ MYSQL_COND_WAIT(&log_descriptor.log_flush_cond,
&log_descriptor.log_flush_lock);
DBUG_VOID_RETURN;
}
@@ -7467,7 +7467,7 @@ void translog_flush_set_new_goal_and_wai
{
DBUG_ENTER("translog_flush_set_new_goal_and_wait");
DBUG_PRINT("enter", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
- safe_mutex_assert_owner(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&log_descriptor.log_flush_lock);
if (cmp_translog_addr(lsn, log_descriptor.next_pass_max_lsn) > 0)
{
log_descriptor.next_pass_max_lsn= lsn;
@@ -7475,7 +7475,7 @@ void translog_flush_set_new_goal_and_wai
}
while (log_descriptor.flush_in_progress)
{
- pthread_cond_wait(&log_descriptor.log_flush_cond,
+ MYSQL_COND_WAIT(&log_descriptor.log_flush_cond,
&log_descriptor.log_flush_lock);
}
DBUG_VOID_RETURN;
@@ -7508,12 +7508,12 @@ my_bool translog_flush(TRANSLOG_ADDRESS
translog_status == TRANSLOG_READONLY);
LINT_INIT(sent_to_disk);
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.log_flush_lock);
DBUG_PRINT("info", ("Everything is flushed up to (%lu,0x%lx)",
LSN_IN_PARTS(log_descriptor.flushed)));
if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0)
{
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.log_flush_lock);
DBUG_RETURN(0);
}
if (log_descriptor.flush_in_progress)
@@ -7525,7 +7525,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS
if (cmp_translog_addr(lsn, log_descriptor.bc.buffer->last_lsn) > 0)
lsn= BUFFER_MAX_LSN(log_descriptor.bc.buffer);
translog_flush_wait_for_end(lsn);
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.log_flush_lock);
DBUG_RETURN(0);
}
log_descriptor.next_pass_max_lsn= LSN_IMPOSSIBLE;
@@ -7533,7 +7533,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS
log_descriptor.flush_in_progress= 1;
flush_horizon= log_descriptor.previous_flush_horizon;
DBUG_PRINT("info", ("flush_in_progress is set"));
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.log_flush_lock);
translog_lock();
if (log_descriptor.is_everything_flushed)
@@ -7648,13 +7648,13 @@ my_bool translog_flush(TRANSLOG_ADDRESS
rc|= sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD));
log_descriptor.previous_flush_horizon= flush_horizon;
out:
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.log_flush_lock);
if (sent_to_disk != LSN_IMPOSSIBLE)
log_descriptor.flushed= sent_to_disk;
log_descriptor.flush_in_progress= 0;
DBUG_PRINT("info", ("flush_in_progress is dropped"));
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);\
- pthread_cond_broadcast(&log_descriptor.log_flush_cond);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.log_flush_lock);\
+ MYSQL_COND_BROADCAST(&log_descriptor.log_flush_cond);
DBUG_RETURN(rc);
}
@@ -7685,7 +7685,7 @@ int translog_assign_id_to_share(MARIA_HA
*/
DBUG_ASSERT(share->data_file_type == BLOCK_RECORD);
/* re-check under mutex to avoid having 2 ids for the same share */
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (unlikely(share->id == 0))
{
LSN lsn;
@@ -7732,11 +7732,11 @@ int translog_assign_id_to_share(MARIA_HA
sizeof(log_array)/sizeof(log_array[0]),
log_array, log_data, NULL)))
{
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
return 1;
}
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
return 0;
}
@@ -7759,7 +7759,7 @@ void translog_deassign_id_from_share(MAR
happening. But a Checkpoint may be reading share->id, so we require this
mutex:
*/
- safe_mutex_assert_owner(&share->intern_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&share->intern_lock);
my_atomic_rwlock_rdlock(&LOCK_id_to_share);
my_atomic_storeptr((void **)&id_to_share[share->id], 0);
my_atomic_rwlock_rdunlock(&LOCK_id_to_share);
@@ -7813,14 +7813,14 @@ static uint32 translog_first_file(TRANSL
uint min_file= 0, max_file;
DBUG_ENTER("translog_first_file");
if (!is_protected)
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.purger_lock);
if (log_descriptor.min_file_number &&
translog_is_file(log_descriptor.min_file_number))
{
DBUG_PRINT("info", ("cached %lu",
(ulong) log_descriptor.min_file_number));
if (!is_protected)
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.purger_lock);
DBUG_RETURN(log_descriptor.min_file_number);
}
@@ -7841,7 +7841,7 @@ static uint32 translog_first_file(TRANSL
}
log_descriptor.min_file_number= max_file;
if (!is_protected)
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.purger_lock);
DBUG_PRINT("info", ("first file :%lu", (ulong) max_file));
DBUG_ASSERT(max_file >= 1);
DBUG_RETURN(max_file);
@@ -8029,7 +8029,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS
DBUG_ASSERT(translog_status == TRANSLOG_OK ||
translog_status == TRANSLOG_READONLY);
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.purger_lock);
if (LSN_FILE_NO(log_descriptor.last_lsn_checked) < last_need_file)
{
uint32 i;
@@ -8058,7 +8058,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS
if (i >= log_descriptor.min_file)
{
TRANSLOG_FILE *file;
- rw_wrlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_WRLOCK(&log_descriptor.open_files_lock);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
DBUG_ASSERT(log_descriptor.min_file == i);
@@ -8068,7 +8068,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS
log_descriptor.min_file++;
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
- rw_unlock(&log_descriptor.open_files_lock);
+ MYSQL_RWLOCK_UNLOCK(&log_descriptor.open_files_lock);
translog_close_log_file(file);
}
if (log_purge_type == TRANSLOG_PURGE_IMMIDIATE)
@@ -8084,7 +8084,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS
log_descriptor.min_need_file= i;
}
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.purger_lock);
DBUG_RETURN(rc);
}
@@ -8121,12 +8121,12 @@ my_bool translog_purge_at_flush()
DBUG_RETURN(0);
}
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.purger_lock);
if (unlikely(log_descriptor.min_need_file == 0))
{
DBUG_PRINT("info", ("No info about min need file => exit"));
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.purger_lock);
DBUG_RETURN(0);
}
@@ -8140,7 +8140,7 @@ my_bool translog_purge_at_flush()
rc= test(my_delete(file_name, MYF(MY_WME)));
}
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.purger_lock);
DBUG_RETURN(rc);
}
@@ -8170,9 +8170,9 @@ uint32 translog_get_first_file(TRANSLOG_
uint32 translog_get_first_needed_file()
{
uint32 file_no;
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_LOCK(&log_descriptor.purger_lock);
file_no= log_descriptor.min_need_file;
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ MYSQL_MUTEX_UNLOCK(&log_descriptor.purger_lock);
return file_no;
}
=== modified file 'storage/maria/ma_open.c'
--- a/storage/maria/ma_open.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_open.c 2008-10-10 20:34:55 +0000
@@ -162,7 +162,7 @@ static MARIA_HA *maria_clone_internal(MA
goto err;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
info.read_record= share->read_record;
share->reopen++;
share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL);
@@ -188,7 +188,7 @@ static MARIA_HA *maria_clone_internal(MA
}
info.state_start= info.state; /* Initial values */
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
/* Allocate buffer for one record */
/* prerequisites: info->rec_buffer == 0 && info->rec_buff_size == 0 */
@@ -234,11 +234,11 @@ err:
MARIA_HA *maria_clone(MARIA_SHARE *share, int mode)
{
MARIA_HA *new_info;
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
new_info= maria_clone_internal(share, mode,
share->data_file_type == BLOCK_RECORD ?
share->bitmap.file.file : -1);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
return new_info;
}
@@ -278,7 +278,7 @@ MARIA_HA *maria_open(const char *name, i
my_realpath(name_buff, fn_format(org_name,name,"",MARIA_NAME_IEXT,
MY_UNPACK_FILENAME),MYF(0));
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
old_info= 0;
if ((open_flags & HA_OPEN_COPY) ||
!(old_info=_ma_test_if_reopen(name_buff)))
@@ -508,7 +508,7 @@ MARIA_HA *maria_open(const char *name, i
&share->open_file_name.str,
share->open_file_name.length+1,
&share->state.key_root,keys*sizeof(my_off_t),
- &share->mmap_lock,sizeof(rw_lock_t),
+ &share->mmap_lock,sizeof(mysql_rwlock_t),
NullS))
goto err;
errpos= 4;
@@ -885,7 +885,7 @@ MARIA_HA *maria_open(const char *name, i
if (!(m_info= maria_clone_internal(share, mode, data_file)))
goto err;
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
DBUG_RETURN(m_info);
err:
@@ -924,7 +924,7 @@ err:
default:
break;
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
my_errno= save_errno;
DBUG_RETURN (NULL);
} /* maria_open */
@@ -1178,10 +1178,10 @@ uint _ma_state_info_write(MARIA_SHARE *s
return 0;
if (pWrite & 4)
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
else if (maria_multi_threaded)
{
- safe_mutex_assert_owner(&share->intern_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&share->intern_lock);
}
if (share->base.born_transactional && translog_status == TRANSLOG_OK &&
!maria_in_recovery)
@@ -1197,7 +1197,7 @@ uint _ma_state_info_write(MARIA_SHARE *s
}
res= _ma_state_info_write_sub(share->kfile.file, &share->state, pWrite);
if (pWrite & 4)
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
share->changed= 0;
return res;
}
@@ -1737,11 +1737,11 @@ int _ma_open_keyfile(MARIA_SHARE *share)
Modifications to share->kfile should be under intern_lock to protect
against a concurrent checkpoint.
*/
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->kfile.file= my_open(share->unique_file_name.str,
share->mode | O_SHARE,
MYF(MY_WME));
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
return (share->kfile.file < 0);
}
=== modified file 'storage/maria/ma_page.c'
--- a/storage/maria/ma_page.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_page.c 2008-10-10 20:34:55 +0000
@@ -329,18 +329,18 @@ my_off_t _ma_new(register MARIA_HA *info
if (_ma_lock_key_del(info, 1))
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
pos= share->state.state.key_file_length;
if (pos >= share->base.max_key_file_length - block_size)
{
my_errno=HA_ERR_INDEX_FILE_FULL;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
DBUG_RETURN(HA_OFFSET_ERROR);
}
share->state.state.key_file_length+= block_size;
/* Following is for not transactional tables */
info->state->key_file_length= share->state.state.key_file_length;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
(*page_link)->changed= 0;
(*page_link)->write_lock= PAGECACHE_LOCK_WRITE;
}
=== modified file 'storage/maria/ma_pagecache.h'
--- a/storage/maria/ma_pagecache.h 2008-03-04 11:58:21 +0000
+++ b/storage/maria/ma_pagecache.h 2008-10-10 20:34:55 +0000
@@ -140,7 +140,7 @@ typedef struct st_pagecache
uchar HUGE_PTR *block_mem; /* memory for block buffers */
PAGECACHE_BLOCK_LINK *used_last;/* ptr to the last block of the LRU chain */
PAGECACHE_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 */
WQUEUE resize_queue; /* threads waiting during resize operation */
WQUEUE waiting_for_hash_link;/* waiting for a free hash link */
WQUEUE waiting_for_block; /* requests waiting for a free block */
=== modified file 'storage/maria/ma_panic.c'
--- a/storage/maria/ma_panic.c 2007-12-31 11:52:45 +0000
+++ b/storage/maria/ma_panic.c 2008-10-10 20:34:55 +0000
@@ -45,7 +45,7 @@ int maria_panic(enum ha_panic_function f
if (!maria_inited)
DBUG_RETURN(0);
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
for (list_element=maria_open_list ; list_element ; list_element=next_open)
{
next_open=list_element->next; /* Save if close */
@@ -57,10 +57,10 @@ int maria_panic(enum ha_panic_function f
happen in MySQL), as we release the mutex, the list may change and so
we may crash.
*/
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
if (maria_close(info))
error=my_errno;
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
break;
case HA_PANIC_WRITE: /* Do this to free databases */
#ifdef CANT_OPEN_FILES_TWICE
@@ -131,7 +131,7 @@ int maria_panic(enum ha_panic_function f
break;
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
if (flag == HA_PANIC_CLOSE)
maria_end();
if (!error)
=== modified file 'storage/maria/ma_range.c'
--- a/storage/maria/ma_range.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_range.c 2008-10-10 20:34:55 +0000
@@ -60,7 +60,7 @@ ha_rows maria_records_in_range(MARIA_HA
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
keyinfo= share->keyinfo + inx;
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_RDLOCK(&keyinfo->root_lock);
switch (keyinfo->key_alg) {
#ifdef HAVE_RTREE_KEYS
@@ -109,7 +109,7 @@ ha_rows maria_records_in_range(MARIA_HA
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
fast_ma_writeinfo(info);
/**
=== modified file 'storage/maria/ma_recovery.c'
--- a/storage/maria/ma_recovery.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_recovery.c 2008-10-10 20:34:55 +0000
@@ -3121,7 +3121,7 @@ static int close_all_tables(void)
TRANSLOG_ADDRESS addr;
DBUG_ENTER("close_all_tables");
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
if (maria_open_list == NULL)
goto end;
tprint(tracef, "Closing all tables\n");
@@ -3152,7 +3152,7 @@ static int close_all_tables(void)
break;
next_open= list_element->next;
info= (MARIA_HA*)list_element->data;
- pthread_mutex_unlock(&THR_LOCK_maria); /* ok, UNDO phase not online yet */
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria); /* ok, UNDO phase not online yet */
/*
Tables which we see here are exactly those which were open at time of
crash. They might have open_count>0 as Checkpoint maybe flushed their
@@ -3162,10 +3162,10 @@ static int close_all_tables(void)
info->s->state.open_count= 0;
prepare_table_for_close(info, addr);
error|= maria_close(info);
- pthread_mutex_lock(&THR_LOCK_maria);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_maria);
}
end:
- pthread_mutex_unlock(&THR_LOCK_maria);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_maria);
DBUG_RETURN(error);
}
=== modified file 'storage/maria/ma_rkey.c'
--- a/storage/maria/ma_rkey.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rkey.c 2008-10-10 20:34:55 +0000
@@ -79,7 +79,7 @@ int maria_rkey(MARIA_HA *info, uchar *bu
if (fast_ma_readinfo(info))
goto err;
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_RDLOCK(&keyinfo->root_lock);
nextflag= maria_read_vec[search_flag] | key.flag;
@@ -155,7 +155,7 @@ int maria_rkey(MARIA_HA *info, uchar *bu
}
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
if (info->cur_row.lastpos == HA_OFFSET_ERROR)
{
=== modified file 'storage/maria/ma_rnext.c'
--- a/storage/maria/ma_rnext.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rnext.c 2008-10-10 20:34:55 +0000
@@ -43,7 +43,7 @@ int maria_rnext(MARIA_HA *info, uchar *b
DBUG_RETURN(my_errno);
keyinfo= share->keyinfo + inx;
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_RDLOCK(&keyinfo->root_lock);
changed= _ma_test_if_changed(info);
if (!flag)
{
@@ -100,7 +100,7 @@ int maria_rnext(MARIA_HA *info, uchar *b
}
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
=== modified file 'storage/maria/ma_rnext_same.c'
--- a/storage/maria/ma_rnext_same.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rnext_same.c 2008-10-10 20:34:55 +0000
@@ -40,7 +40,7 @@ int maria_rnext_same(MARIA_HA *info, uch
keyinfo= info->s->keyinfo+inx;
if (info->s->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_RDLOCK(&keyinfo->root_lock);
switch (keyinfo->key_alg) {
#ifdef HAVE_RTREE_KEYS
@@ -85,7 +85,7 @@ int maria_rnext_same(MARIA_HA *info, uch
}
}
if (info->s->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME;
=== modified file 'storage/maria/ma_rprev.c'
--- a/storage/maria/ma_rprev.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rprev.c 2008-10-10 20:34:55 +0000
@@ -42,7 +42,7 @@ int maria_rprev(MARIA_HA *info, uchar *b
keyinfo= share->keyinfo + inx;
changed= _ma_test_if_changed(info);
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_RDLOCK(&keyinfo->root_lock);
if (!flag)
error= _ma_search_last(info, keyinfo, share->state.key_root[inx]);
else if (!changed)
@@ -65,7 +65,7 @@ int maria_rprev(MARIA_HA *info, uchar *b
}
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_PREV_FOUND;
if (error)
=== modified file 'storage/maria/ma_rsame.c'
--- a/storage/maria/ma_rsame.c 2008-06-26 17:48:42 +0000
+++ b/storage/maria/ma_rsame.c 2008-10-10 20:34:55 +0000
@@ -62,11 +62,11 @@ int maria_rsame(MARIA_HA *info, uchar *r
info->cur_row.lastpos,
info->cur_row.trid);
if (info->s->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_RDLOCK(&keyinfo->root_lock);
(void)(_ma_search(info, &info->last_key, SEARCH_SAME,
info->s->state.key_root[inx]));
if (info->s->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
}
if (!(*info->read_record)(info, record, info->cur_row.lastpos))
=== modified file 'storage/maria/ma_sort.c'
--- a/storage/maria/ma_sort.c 2008-06-26 17:48:42 +0000
+++ b/storage/maria/ma_sort.c 2008-10-10 20:34:55 +0000
@@ -484,10 +484,10 @@ ok:
if (sort_param->read_cache.share)
remove_io_thread(&sort_param->read_cache);
- pthread_mutex_lock(&sort_param->sort_info->mutex);
+ MYSQL_MUTEX_LOCK(&sort_param->sort_info->mutex);
if (!--sort_param->sort_info->threads_running)
- pthread_cond_signal(&sort_param->sort_info->cond);
- pthread_mutex_unlock(&sort_param->sort_info->mutex);
+ MYSQL_COND_SIGNAL(&sort_param->sort_info->cond);
+ MYSQL_MUTEX_UNLOCK(&sort_param->sort_info->mutex);
DBUG_PRINT("exit", ("======== ending thread ========"));
}
my_thread_end();
=== modified file 'storage/maria/ma_state.c'
--- a/storage/maria/ma_state.c 2008-08-18 22:21:22 +0000
+++ b/storage/maria/ma_state.c 2008-10-10 20:34:55 +0000
@@ -77,7 +77,7 @@ my_bool _ma_setup_live_state(MARIA_HA *i
trn->used_tables= tables;
tables->share= share;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->in_trans++;
DBUG_PRINT("info", ("share: 0x%lx in_trans: %d",
(ulong) share, share->in_trans));
@@ -93,7 +93,7 @@ my_bool _ma_setup_live_state(MARIA_HA *i
*/
while (trn->trid < history->trid)
history= history->next;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
/* The current item can't be deleted as it's the first one visible for us */
tables->state_start= tables->state_current= history->state;
DBUG_PRINT("info", ("records: %ld", (ulong) tables->state_start.records));
@@ -190,10 +190,10 @@ MARIA_STATE_HISTORY
void _ma_remove_not_visible_states_with_lock(MARIA_SHARE *share)
{
trnman_lock();
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->state_history= _ma_remove_not_visible_states(share->state_history, 0,
1);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
trnman_unlock();
}
@@ -374,7 +374,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *t
{
MARIA_STATE_HISTORY *history;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (active_transactions && share->now_transactional &&
trnman_exists_active_transactions(share->state_history->trid,
trn->commit_trid, 1))
@@ -383,7 +383,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *t
{
/* purecov: begin inspected */
error= 1;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
my_free(tables, MYF(0));
continue;
/* purecov: end */
@@ -412,7 +412,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *t
DBUG_PRINT("info", ("share: 0x%lx in_trans: %d",
(ulong) share, share->in_trans));
share->in_trans--;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
else
{
@@ -421,9 +421,9 @@ my_bool _ma_trnman_end_trans_hook(TRN *t
We need to keep share->in_trans correct in the debug library
because of the assert in maria_close()
*/
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->in_trans--;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
#endif
}
my_free(tables, MYF(0));
@@ -450,7 +450,7 @@ void _ma_remove_table_from_trnman(MARIA_
DBUG_PRINT("enter", ("share: 0x%lx in_trans: %d",
(ulong) share, share->in_trans));
- safe_mutex_assert_owner(&share->intern_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&share->intern_lock);
for (prev= (MARIA_USED_TABLES**) &trn->used_tables, tables= *prev;
tables;
@@ -547,10 +547,10 @@ void maria_versioning(MARIA_HA *info, my
void _ma_set_share_data_file_length(MARIA_SHARE *share, ulonglong new_length)
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->state.state.data_file_length < new_length)
share->state.state.data_file_length= new_length;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
=== modified file 'storage/maria/ma_static.c'
--- a/storage/maria/ma_static.c 2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_static.c 2008-10-10 20:34:55 +0000
@@ -36,7 +36,7 @@ my_bool maria_flush= 0, maria_single_use
my_bool maria_delay_key_write= 0, maria_page_checksums= 1;
my_bool maria_inited= FALSE;
my_bool maria_in_ha_maria= FALSE; /* If used from ha_maria or not */
-pthread_mutex_t THR_LOCK_maria;
+mysql_mutex_t THR_LOCK_maria;
#if defined(THREAD) && !defined(DONT_USE_RW_LOCKS)
ulong maria_concurrent_insert= 2;
#else
=== modified file 'storage/maria/ma_write.c'
--- a/storage/maria/ma_write.c 2008-08-25 18:23:18 +0000
+++ b/storage/maria/ma_write.c 2008-10-10 20:34:55 +0000
@@ -165,7 +165,7 @@ int maria_write(MARIA_HA *info, uchar *r
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
{
- rw_wrlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_WRLOCK(&keyinfo->root_lock);
keyinfo->version++;
}
if (keyinfo->flag & HA_FULLTEXT )
@@ -173,7 +173,7 @@ int maria_write(MARIA_HA *info, uchar *r
if (_ma_ft_add(info,i, buff,record,filepos))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
@@ -186,7 +186,7 @@ int maria_write(MARIA_HA *info, uchar *r
info->trn->trid)))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
@@ -196,7 +196,7 @@ int maria_write(MARIA_HA *info, uchar *r
info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
}
}
if (share->calc_write_checksum)
@@ -276,7 +276,7 @@ err:
is_tree_inited(&info->bulk_insert[i])));
keyinfo= share->keyinfo + i;
if (local_lock_tree)
- rw_wrlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_WRLOCK(&keyinfo->root_lock);
/**
@todo RECOVERY BUG
The key deletes below should generate CLR_ENDs
@@ -286,7 +286,7 @@ err:
if (_ma_ft_del(info,i,buff,record,filepos))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
break;
}
}
@@ -298,12 +298,12 @@ err:
filepos, info->trn->trid)))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
break;
}
}
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
}
}
}
@@ -1545,7 +1545,7 @@ static int keys_free(uchar *key, TREE_FR
case free_init:
if (share->lock_key_trees)
{
- rw_wrlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_WRLOCK(&keyinfo->root_lock);
keyinfo->version++;
}
return 0;
@@ -1566,7 +1566,7 @@ static int keys_free(uchar *key, TREE_FR
return _ma_ck_write_btree(param->info, &tmp_key);
case free_end:
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ MYSQL_RWLOCK_UNLOCK(&keyinfo->root_lock);
return 0;
}
return 1;
=== modified file 'storage/maria/maria_def.h'
--- a/storage/maria/maria_def.h 2008-08-25 11:49:47 +0000
+++ b/storage/maria/maria_def.h 2008-10-10 20:34:55 +0000
@@ -246,8 +246,8 @@ typedef struct st_maria_file_bitmap
PAGECACHE_FILE file; /* datafile where bitmap is stored */
#ifdef THREAD
- pthread_mutex_t bitmap_lock;
- pthread_cond_t bitmap_cond; /**< When bitmap becomes flushable */
+ mysql_mutex_t bitmap_lock;
+ mysql_cond_t bitmap_cond; /**< When bitmap becomes flushable */
#endif
/* Constants, allocated when initiating bitmaps */
uint sizes[8]; /* Size per bit combination */
@@ -384,14 +384,14 @@ typedef struct st_maria_share
#ifdef THREAD
THR_LOCK lock;
void (*lock_restore_status)(void *);
- pthread_mutex_t intern_lock; /* Locking for use with _locking */
- pthread_cond_t intern_cond;
+ mysql_mutex_t intern_lock; /* Locking for use with _locking */
+ mysql_cond_t intern_cond;
#endif
my_off_t mmaped_length;
uint nonmmaped_inserts; /* counter of writing in
non-mmaped area */
MARIA_FILE_BITMAP bitmap;
- rw_lock_t mmap_lock;
+ mysql_rwlock_t mmap_lock;
LSN lsn_of_file_id; /**< LSN of its last LOGREC_FILE_ID */
} MARIA_SHARE;
@@ -729,12 +729,12 @@ struct st_maria_handler
#define maria_unique_store(A,B) mi_int4store((A),(B))
#ifdef THREAD
-extern pthread_mutex_t THR_LOCK_maria;
+extern mysql_mutex_t THR_LOCK_maria;
#endif
#if !defined(THREAD) || defined(DONT_USE_RW_LOCKS)
-#define rw_wrlock(A) {}
-#define rw_rdlock(A) {}
-#define rw_unlock(A) {}
+#define MYSQL_RWLOCK_WRLOCK(A) {}
+#define MYSQL_RWLOCK_RDLOCK(A) {}
+#define MYSQL_RWLOCK_UNLOCK(A) {}
#endif
/* Some tuning parameters */
=== modified file 'storage/maria/tablockman.c'
--- a/storage/maria/tablockman.c 2008-01-10 12:21:53 +0000
+++ b/storage/maria/tablockman.c 2008-10-10 20:34:55 +0000
@@ -282,7 +282,7 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE
DBUG_ASSERT(lo->waiting_for == 0);
DBUG_ASSERT(lo->waiting_for_loid == 0);
- pthread_mutex_lock(& table->mutex);
+ MYSQL_MUTEX_LOCK(& table->mutex);
/* do we already have a lock on this resource ? */
old= find_by_loid(table, lo->loid);
@@ -298,16 +298,16 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE
}
/* no, placing a new lock. first - take a free lock structure from the pool */
- pthread_mutex_lock(& lm->pool_mutex);
+ MYSQL_MUTEX_LOCK(& lm->pool_mutex);
new= lm->pool;
if (new)
{
lm->pool= new->next;
- pthread_mutex_unlock(& lm->pool_mutex);
+ MYSQL_MUTEX_UNLOCK(& lm->pool_mutex);
}
else
{
- pthread_mutex_unlock(& lm->pool_mutex);
+ MYSQL_MUTEX_UNLOCK(& lm->pool_mutex);
new= (TABLE_LOCK *)my_malloc(sizeof(*new), MYF(MY_WME));
if (unlikely(!new))
{
@@ -443,13 +443,13 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE
and we must release table's mutex.
note that blocker's mutex is locked _before_ table's mutex is released
*/
- pthread_mutex_lock(wait_for->mutex);
- pthread_mutex_unlock(& table->mutex);
+ MYSQL_MUTEX_LOCK(wait_for->mutex);
+ MYSQL_MUTEX_UNLOCK(& table->mutex);
/* now really wait */
- i= pthread_cond_timedwait(wait_for->cond, wait_for->mutex, & timeout);
+ i= MYSQL_COND_TIMEDWAIT(wait_for->cond, wait_for->mutex, & timeout);
- pthread_mutex_unlock(wait_for->mutex);
+ MYSQL_MUTEX_UNLOCK(wait_for->mutex);
if (i == ETIMEDOUT || i == ETIME)
{
@@ -458,7 +458,7 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE
goto ret2;
}
- pthread_mutex_lock(& table->mutex);
+ MYSQL_MUTEX_LOCK(& table->mutex);
/* ... and repeat from the beginning */
}
@@ -493,7 +493,7 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE
res= getlock_result[lock][lock];
ret:
- pthread_mutex_unlock(& table->mutex);
+ MYSQL_MUTEX_UNLOCK(& table->mutex);
ret2:
DBUG_ASSERT(res);
return res;
@@ -520,7 +520,7 @@ void tablockman_release_locks(TABLOCKMAN
if ((lock= lo->waiting_lock))
{
DBUG_ASSERT(lock->loid == lo->loid);
- pthread_mutex_lock(& lock->table->mutex);
+ MYSQL_MUTEX_LOCK(& lock->table->mutex);
remove_from_wait_queue(lock, lock->table);
/*
@@ -544,13 +544,13 @@ void tablockman_release_locks(TABLOCKMAN
if (lock->next &&
lock_compatibility_matrix[lock->next->lock_type][lock->lock_type])
{
- pthread_mutex_lock(lo->waiting_for->mutex);
- pthread_cond_broadcast(lo->waiting_for->cond);
- pthread_mutex_unlock(lo->waiting_for->mutex);
+ MYSQL_MUTEX_LOCK(lo->waiting_for->mutex);
+ MYSQL_COND_BROADCAST(lo->waiting_for->cond);
+ MYSQL_MUTEX_UNLOCK(lo->waiting_for->mutex);
}
lo->waiting_for= 0;
lo->waiting_for_loid= 0;
- pthread_mutex_unlock(& lock->table->mutex);
+ MYSQL_MUTEX_UNLOCK(& lock->table->mutex);
lock->next= local_pool;
local_pool= lock;
@@ -561,14 +561,14 @@ void tablockman_release_locks(TABLOCKMAN
while (lock)
{
TABLE_LOCK *cur= lock;
- pthread_mutex_t *mutex= & lock->table->mutex;
+ mysql_mutex_t *mutex= & lock->table->mutex;
DBUG_ASSERT(cur->loid == lo->loid);
DBUG_ASSERT(lock != lock->next_in_lo);
lock= lock->next_in_lo;
/* TODO ? group locks by table to reduce the number of mutex locks */
- pthread_mutex_lock(mutex);
+ MYSQL_MUTEX_LOCK(mutex);
hash_delete(& cur->table->latest_locks, (uchar *)cur);
if (cur->prev)
@@ -581,7 +581,7 @@ void tablockman_release_locks(TABLOCKMAN
cur->next= local_pool;
local_pool= cur;
- pthread_mutex_unlock(mutex);
+ MYSQL_MUTEX_UNLOCK(mutex);
}
lo->waiting_lock= lo->active_locks= 0;
@@ -590,15 +590,15 @@ void tablockman_release_locks(TABLOCKMAN
okay, all locks released. now signal that we're leaving,
in case somebody's waiting for it
*/
- pthread_mutex_lock(lo->mutex);
- pthread_cond_broadcast(lo->cond);
- pthread_mutex_unlock(lo->mutex);
+ MYSQL_MUTEX_LOCK(lo->mutex);
+ MYSQL_COND_BROADCAST(lo->cond);
+ MYSQL_MUTEX_UNLOCK(lo->mutex);
/* and push all freed locks to the lockman's pool */
- pthread_mutex_lock(& lm->pool_mutex);
+ MYSQL_MUTEX_LOCK(& lm->pool_mutex);
local_pool_end->next= lm->pool;
lm->pool= local_pool;
- pthread_mutex_unlock(& lm->pool_mutex);
+ MYSQL_MUTEX_UNLOCK(& lm->pool_mutex);
}
void tablockman_init(TABLOCKMAN *lm, loid_to_tlo_func *func, uint timeout)
@@ -618,7 +618,7 @@ void tablockman_destroy(TABLOCKMAN *lm)
lm->pool= tmp->next;
my_free((void *)tmp, MYF(0));
}
- pthread_mutex_destroy(& lm->pool_mutex);
+ MYSQL_MUTEX_DESTROY(& lm->pool_mutex);
}
/*
@@ -648,7 +648,7 @@ void tablockman_destroy_locked_table(LOC
DBUG_ASSERT(lt->active_locks[i] == 0);
hash_free(& lt->latest_locks);
- pthread_mutex_destroy(& lt->mutex);
+ MYSQL_MUTEX_DESTROY(& lt->mutex);
}
#ifdef EXTRA_DEBUG
=== modified file 'storage/maria/tablockman.h'
--- a/storage/maria/tablockman.h 2007-12-18 22:22:55 +0000
+++ b/storage/maria/tablockman.h 2008-10-10 20:34:55 +0000
@@ -50,13 +50,13 @@ typedef struct st_table_lock_owner {
TABLE_LOCK *active_locks; /* list of active locks */
TABLE_LOCK *waiting_lock; /* waiting lock (one lock only) */
struct st_table_lock_owner *waiting_for; /* transaction we're waiting for */
- pthread_cond_t *cond; /* transactions waiting for us, wait on 'cond' */
- pthread_mutex_t *mutex; /* mutex is required to use 'cond' */
+ mysql_cond_t *cond; /* transactions waiting for us, wait on 'cond' */
+ mysql_mutex_t *mutex; /* mutex is required to use 'cond' */
uint16 loid, waiting_for_loid; /* Lock Owner IDentifier */
} TABLE_LOCK_OWNER;
typedef struct st_locked_table {
- pthread_mutex_t mutex; /* mutex for everything below */
+ mysql_mutex_t mutex; /* mutex for everything below */
HASH latest_locks; /* latest locks in a hash */
TABLE_LOCK *active_locks[LOCK_TYPES]; /* dl-list of locks per type */
TABLE_LOCK *wait_queue_in, *wait_queue_out; /* wait deque (double-end queue)*/
@@ -65,7 +65,7 @@ typedef struct st_locked_table {
typedef TABLE_LOCK_OWNER *loid_to_tlo_func(uint16);
typedef struct {
- pthread_mutex_t pool_mutex;
+ mysql_mutex_t pool_mutex;
TABLE_LOCK *pool; /* lifo pool of free locks */
uint lock_timeout; /* lock timeout in milliseconds */
loid_to_tlo_func *loid_to_tlo; /* for mapping loid to TABLE_LOCK_OWNER */
=== modified file 'storage/maria/trnman.c'
--- a/storage/maria/trnman.c 2008-07-05 11:03:21 +0000
+++ b/storage/maria/trnman.c 2008-10-10 20:34:55 +0000
@@ -38,7 +38,7 @@ static TRN committed_list_min, committed
static TrID global_trid_generator;
/* the mutex for everything above */
-static pthread_mutex_t LOCK_trn_list;
+static mysql_mutex_t LOCK_trn_list;
/* LIFO pool of unused TRN structured for reuse */
static TRN *pool;
@@ -206,8 +206,8 @@ void trnman_destroy()
my_free((void *)trn, MYF(0));
}
lf_hash_destroy(&trid_to_committed_trn);
- DBUG_PRINT("info", ("pthread_mutex_destroy LOCK_trn_list"));
- pthread_mutex_destroy(&LOCK_trn_list);
+ DBUG_PRINT("info", ("MYSQL_MUTEX_DESTROY LOCK_trn_list"));
+ MYSQL_MUTEX_DESTROY(&LOCK_trn_list);
my_atomic_rwlock_destroy(&LOCK_short_trid_to_trn);
my_atomic_rwlock_destroy(&LOCK_pool);
my_free((void *)(short_trid_to_active_trn+1), MYF(0));
@@ -228,8 +228,8 @@ static TrID new_trid()
{
DBUG_ENTER("new_trid");
DBUG_ASSERT(global_trid_generator < 0xffffffffffffLL);
- DBUG_PRINT("info", ("safe_mutex_assert_owner LOCK_trn_list"));
- safe_mutex_assert_owner(&LOCK_trn_list);
+ DBUG_PRINT("info", ("MYSQL_MUTEX_ASSERT_OWNER LOCK_trn_list"));
+ MYSQL_MUTEX_ASSERT_OWNER(&LOCK_trn_list);
DBUG_RETURN(++global_trid_generator);
}
@@ -260,7 +260,7 @@ static void set_short_trid(TRN *trn)
mutex and cond will be used for lock waits
*/
-TRN *trnman_new_trn(pthread_mutex_t *mutex, pthread_cond_t *cond,
+TRN *trnman_new_trn(mysql_mutex_t *mutex, mysql_cond_t *cond,
void *stack_end)
{
TRN *trn;
@@ -275,8 +275,8 @@ TRN *trnman_new_trn(pthread_mutex_t *mut
mutex.
*/
- DBUG_PRINT("info", ("pthread_mutex_lock LOCK_trn_list"));
- pthread_mutex_lock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("MYSQL_MUTEX_LOCK LOCK_trn_list"));
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
/* Allocating a new TRN structure */
trn= pool;
@@ -302,8 +302,8 @@ TRN *trnman_new_trn(pthread_mutex_t *mut
trn= (TRN *)my_malloc(sizeof(TRN), MYF(MY_WME | MY_ZEROFILL));
if (unlikely(!trn))
{
- DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list"));
- pthread_mutex_unlock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("MYSQL_MUTEX_UNLOCK LOCK_trn_list"));
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
return 0;
}
trnman_allocated_transactions++;
@@ -325,8 +325,8 @@ TRN *trnman_new_trn(pthread_mutex_t *mut
trn->next= &active_list_max;
trn->prev= active_list_max.prev;
active_list_max.prev= trn->prev->next= trn;
- DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list"));
- pthread_mutex_unlock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("MYSQL_MUTEX_UNLOCK LOCK_trn_list"));
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
if (unlikely(!trn->min_read_from))
{
@@ -390,8 +390,8 @@ my_bool trnman_end_trn(TRN *trn, my_bool
DBUG_ASSERT(trn->rec_lsn == 0);
/* if a rollback, all UNDO records should have been executed */
DBUG_ASSERT(commit || trn->undo_lsn == 0);
- DBUG_PRINT("info", ("pthread_mutex_lock LOCK_trn_list"));
- pthread_mutex_lock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("MYSQL_MUTEX_LOCK LOCK_trn_list"));
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
/* remove from active list */
trn->next->prev= trn->prev;
@@ -467,7 +467,7 @@ my_bool trnman_end_trn(TRN *trn, my_bool
active_list_min.next != &active_list_max))
res= -1;
trnman_active_transactions--;
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
/* the rest is done outside of a critical section */
#ifdef NOT_USED
@@ -638,7 +638,7 @@ my_bool trnman_collect_transactions(LEX_
/* validate the use of read_non_atomic() in general: */
compile_time_assert((sizeof(LSN) == 8) && (sizeof(LSN_WITH_FLAGS) == 8));
- pthread_mutex_lock(&LOCK_trn_list);
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
str_act->length= 2 + /* number of active transactions */
LSN_STORE_SIZE + /* minimum of their rec_lsn */
TRANSID_SIZE + /* current TrID generator value */
@@ -758,7 +758,7 @@ my_bool trnman_collect_transactions(LEX_
err:
error= 1;
end:
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
DBUG_RETURN(error);
}
@@ -805,9 +805,9 @@ TrID trnman_get_min_trid()
return ~(TrID) 0;
}
- pthread_mutex_lock(&LOCK_trn_list);
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
min_read_from= active_list_min.next->min_read_from;
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
return min_read_from;
}
@@ -827,10 +827,10 @@ TrID trnman_get_min_trid()
TrID trnman_get_min_safe_trid()
{
TrID trid;
- pthread_mutex_lock(&LOCK_trn_list);
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
trid= min(active_list_min.next->min_read_from,
global_trid_generator);
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
return trid;
}
@@ -844,9 +844,9 @@ TrID trnman_get_max_trid()
TrID id;
if (short_trid_to_active_trn == NULL)
return 0;
- pthread_mutex_lock(&LOCK_trn_list);
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
id= global_trid_generator;
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
return id;
}
@@ -872,7 +872,7 @@ my_bool trnman_exists_active_transaction
my_bool ret= 0;
if (!trnman_is_locked)
- pthread_mutex_lock(&LOCK_trn_list);
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
for (trn= active_list_min.next; trn != &active_list_max; trn= trn->next)
{
if (trn->trid > min_id && trn->trid < max_id)
@@ -882,7 +882,7 @@ my_bool trnman_exists_active_transaction
}
}
if (!trnman_is_locked)
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
return ret;
}
@@ -893,7 +893,7 @@ my_bool trnman_exists_active_transaction
void trnman_lock()
{
- pthread_mutex_lock(&LOCK_trn_list);
+ MYSQL_MUTEX_LOCK(&LOCK_trn_list);
}
/**
@@ -902,5 +902,5 @@ void trnman_lock()
void trnman_unlock()
{
- pthread_mutex_unlock(&LOCK_trn_list);
+ MYSQL_MUTEX_UNLOCK(&LOCK_trn_list);
}
=== modified file 'storage/maria/trnman_public.h'
--- a/storage/maria/trnman_public.h 2008-07-05 11:03:21 +0000
+++ b/storage/maria/trnman_public.h 2008-10-10 20:34:55 +0000
@@ -38,7 +38,7 @@ extern my_bool (*trnman_end_trans_hook)(
int trnman_init(TrID);
void trnman_destroy(void);
-TRN *trnman_new_trn(pthread_mutex_t *, pthread_cond_t *, void *);
+TRN *trnman_new_trn(mysql_mutex_t *, mysql_cond_t *, void *);
my_bool trnman_end_trn(TRN *trn, my_bool commit);
#define trnman_commit_trn(T) trnman_end_trn(T, TRUE)
#define trnman_abort_trn(T) trnman_end_trn(T, FALSE)
=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc 2008-07-09 07:12:43 +0000
+++ b/storage/myisam/ha_myisam.cc 2008-10-10 20:34:55 +0000
@@ -523,7 +523,7 @@ void _mi_report_crashed(MI_INFO *file, c
THD *cur_thd;
LIST *element;
char buf[1024];
- pthread_mutex_lock(&file->s->intern_lock);
+ MYSQL_MUTEX_LOCK(&file->s->intern_lock);
if ((cur_thd= (THD*) file->in_use.data))
sql_print_error("Got an error from thread_id=%lu, %s:%d", cur_thd->thread_id,
sfile, sline);
@@ -537,7 +537,7 @@ void _mi_report_crashed(MI_INFO *file, c
sql_print_error("%s", thd ? thd_security_context(thd, buf, sizeof(buf), 0)
: "Unknown thread accessing table");
}
- pthread_mutex_unlock(&file->s->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&file->s->intern_lock);
}
}
@@ -787,14 +787,14 @@ int ha_myisam::check(THD* thd, HA_CHECK_
mi_is_crashed(file))
{
file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR |
STATE_BAD_OPEN_COUNT);
if (!(table->db_stat & HA_READ_ONLY))
error=update_state_info(¶m,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST);
}
@@ -838,9 +838,9 @@ int ha_myisam::analyze(THD *thd, HA_CHEC
error = chk_key(¶m, file);
if (!error)
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
error=update_state_info(¶m,file,UPDATE_STAT);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
else if (!mi_is_crashed(file) && !thd->killed)
mi_mark_crashed(file);
@@ -1434,10 +1434,10 @@ bool ha_myisam::check_and_repair(THD *th
old_query= thd->query;
old_query_length= thd->query_length;
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query= table->s->table_name.str;
thd->query_length= table->s->table_name.length;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt))
{
@@ -1450,10 +1450,10 @@ bool ha_myisam::check_and_repair(THD *th
if (repair(thd, &check_opt))
error=1;
}
- pthread_mutex_lock(&LOCK_thread_count);
+ MYSQL_MUTEX_LOCK(&LOCK_thread_count);
thd->query= old_query;
thd->query_length= old_query_length;
- pthread_mutex_unlock(&LOCK_thread_count);
+ MYSQL_MUTEX_UNLOCK(&LOCK_thread_count);
DBUG_RETURN(error);
}
@@ -1694,7 +1694,7 @@ int ha_myisam::info(uint flag)
/* Update share */
if (share->tmp_table == NO_TMP_TABLE)
- pthread_mutex_lock(&share->LOCK_ha_data);
+ MYSQL_MUTEX_LOCK(&share->LOCK_ha_data);
share->keys_in_use.set_prefix(share->keys);
share->keys_in_use.intersect_extended(misam_info.key_map);
share->keys_for_keyread.intersect(share->keys_in_use);
@@ -1704,7 +1704,7 @@ int ha_myisam::info(uint flag)
(char*) misam_info.rec_per_key,
sizeof(table->key_info[0].rec_per_key)*share->key_parts);
if (share->tmp_table == NO_TMP_TABLE)
- pthread_mutex_unlock(&share->LOCK_ha_data);
+ MYSQL_MUTEX_UNLOCK(&share->LOCK_ha_data);
/*
Set data_file_name and index_file_name to point at the symlink value
=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c 2008-08-24 16:12:12 +0000
+++ b/storage/myisam/mi_check.c 2008-10-10 20:34:55 +0000
@@ -2909,7 +2909,7 @@ int mi_repair_parallel(HA_CHECK *param,
sort_param[0].calc_checksum= test(param->testflag & T_CALC_CHECKSUM);
sort_info.got_error=0;
- pthread_mutex_lock(&sort_info.mutex);
+ MYSQL_MUTEX_LOCK(&sort_info.mutex);
/*
Initialize the I/O cache share for use with the read caches and, in
@@ -2975,8 +2975,8 @@ int mi_repair_parallel(HA_CHECK *param,
/* waiting for all threads to finish */
while (sort_info.threads_running)
- pthread_cond_wait(&sort_info.cond, &sort_info.mutex);
- pthread_mutex_unlock(&sort_info.mutex);
+ MYSQL_COND_WAIT(&sort_info.cond, &sort_info.mutex);
+ MYSQL_MUTEX_UNLOCK(&sort_info.mutex);
if ((got_error= thr_write_keys(sort_param)))
{
@@ -3120,8 +3120,8 @@ err:
share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS;
share->state.changed|=STATE_NOT_SORTED_PAGES;
- pthread_cond_destroy (&sort_info.cond);
- pthread_mutex_destroy(&sort_info.mutex);
+ MYSQL_COND_DESTROY (&sort_info.cond);
+ MYSQL_MUTEX_DESTROY(&sort_info.mutex);
my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
my_free((uchar*) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR));
=== modified file 'storage/myisam/mi_close.c'
--- a/storage/myisam/mi_close.c 2008-07-09 07:12:43 +0000
+++ b/storage/myisam/mi_close.c 2008-10-10 20:34:55 +0000
@@ -31,7 +31,7 @@ int mi_close(register MI_INFO *info)
info, (uint) share->reopen,
(uint) share->tot_locks));
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
@@ -43,7 +43,7 @@ int mi_close(register MI_INFO *info)
if (mi_lock_database(info,F_UNLCK))
error=my_errno;
}
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->options & HA_OPTION_READ_ONLY_DATA)
{
@@ -60,7 +60,7 @@ int mi_close(register MI_INFO *info)
}
flag= !--share->reopen;
myisam_open_list=list_delete(myisam_open_list,&info->open_list);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
if (flag)
@@ -102,20 +102,20 @@ int mi_close(register MI_INFO *info)
}
#ifdef THREAD
thr_lock_delete(&share->lock);
- pthread_mutex_destroy(&share->intern_lock);
+ MYSQL_MUTEX_DESTROY(&share->intern_lock);
my_atomic_rwlock_destroy(&share->physical_logging_rwlock);
{
int i,keys;
keys = share->state.header.keys;
- (void) rwlock_destroy(&share->mmap_lock);
+ (void) MYSQL_RWLOCK_DESTROY(&share->mmap_lock);
for(i=0; i<keys; i++) {
- (void) rwlock_destroy(&share->key_root_lock[i]);
+ (void) MYSQL_RWLOCK_DESTROY(&share->key_root_lock[i]);
}
}
#endif
my_free((uchar*) info->s,MYF(0));
}
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
if (info->ftparser_param)
{
my_free((uchar*)info->ftparser_param, MYF(0));
=== modified file 'storage/myisam/mi_create.c'
--- a/storage/myisam/mi_create.c 2008-08-25 18:23:27 +0000
+++ b/storage/myisam/mi_create.c 2008-10-10 20:34:55 +0000
@@ -580,7 +580,7 @@ int mi_create(const char *name,uint keys
my_atomic_rwlock_init(&share.physical_logging_rwlock);
#endif
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
/*
NOTE: For test_if_reopen() we need a real path name. Hence we need
@@ -843,7 +843,7 @@ int mi_create(const char *name,uint keys
goto err;
}
errpos=0;
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
res= 0;
if (my_close(file,MYF(0)))
res= my_errno;
@@ -854,7 +854,7 @@ int mi_create(const char *name,uint keys
DBUG_RETURN(res);
err:
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
err_no_lock:
save_errno=my_errno;
=== modified file 'storage/myisam/mi_dbug.c'
--- a/storage/myisam/mi_dbug.c 2008-05-29 15:44:11 +0000
+++ b/storage/myisam/mi_dbug.c 2008-10-10 20:34:55 +0000
@@ -173,7 +173,7 @@ my_bool check_table_is_closed(const char
LIST *pos;
DBUG_ENTER("check_table_is_closed");
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
(void) fn_format(filename,name,"",MI_NAME_IEXT,4+16+32);
for (pos=myisam_open_list ; pos ; pos=pos->next)
@@ -186,12 +186,12 @@ my_bool check_table_is_closed(const char
{
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
DBUG_RETURN(1);
}
}
}
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
DBUG_RETURN(0);
}
#endif /* EXTRA_DEBUG */
=== modified file 'storage/myisam/mi_dynrec.c'
--- a/storage/myisam/mi_dynrec.c 2008-07-23 12:46:33 +0000
+++ b/storage/myisam/mi_dynrec.c 2008-10-10 20:34:55 +0000
@@ -140,7 +140,7 @@ size_t mi_mmap_pread(MI_INFO *info, ucha
{
DBUG_PRINT("info", ("mi_read with mmap %d\n", info->dfile));
if (info->s->concurrent_insert)
- rw_rdlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_RDLOCK(&info->s->mmap_lock);
/*
The following test may fail in the following cases:
@@ -153,13 +153,13 @@ size_t mi_mmap_pread(MI_INFO *info, ucha
{
memcpy(Buffer, info->s->file_map + offset, Count);
if (info->s->concurrent_insert)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
return 0;
}
else
{
if (info->s->concurrent_insert)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
return my_pread(info->dfile, Buffer, Count, offset, MyFlags);
}
}
@@ -197,7 +197,7 @@ size_t mi_mmap_pwrite(MI_INFO *info, con
uint ret;
DBUG_PRINT("info", ("mi_write with mmap %d\n", info->dfile));
if (share->concurrent_insert)
- rw_rdlock(&share->mmap_lock);
+ MYSQL_RWLOCK_RDLOCK(&share->mmap_lock);
/*
The following test may fail in the following cases:
@@ -210,14 +210,14 @@ size_t mi_mmap_pwrite(MI_INFO *info, con
{
memcpy(share->file_map + offset, Buffer, Count);
if (share->concurrent_insert)
- rw_unlock(&share->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&share->mmap_lock);
ret= 0;
}
else
{
share->nonmmaped_inserts++;
if (share->concurrent_insert)
- rw_unlock(&share->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&share->mmap_lock);
ret= my_pwrite(info->dfile, Buffer, Count, offset, MyFlags);
}
if (unlikely(mi_get_physical_logging_state(share)))
=== modified file 'storage/myisam/mi_extra.c'
--- a/storage/myisam/mi_extra.c 2008-07-09 07:12:43 +0000
+++ b/storage/myisam/mi_extra.c 2008-10-10 20:34:55 +0000
@@ -76,17 +76,17 @@ int mi_extra(MI_INFO *info, enum ha_extr
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if ((share->options & HA_OPTION_COMPRESS_RECORD))
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (_mi_memmap_file(info))
{
/* We don't nead MADV_SEQUENTIAL if small file */
madvise((char*) share->file_map, share->state.state.data_file_length,
share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
MADV_RANDOM : MADV_SEQUENTIAL);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
break;
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
#endif
if (info->opt_flag & WRITE_CACHE_USED)
@@ -267,17 +267,17 @@ int mi_extra(MI_INFO *info, enum ha_extr
}
break;
case HA_EXTRA_FORCE_REOPEN:
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
share->last_version= 0L; /* Impossible version */
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
break;
case HA_EXTRA_PREPARE_FOR_RENAME:
case HA_EXTRA_PREPARE_FOR_DROP:
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
share->last_version= 0L; /* Impossible version */
#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND
/* Close the isam and data files as Win32 can't drop an open table */
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (flush_key_blocks(share->key_cache, share->kfile,
(function == HA_EXTRA_PREPARE_FOR_DROP ?
FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)))
@@ -319,9 +319,9 @@ int mi_extra(MI_INFO *info, enum ha_extr
}
}
share->kfile= -1; /* Files aren't open anymore */
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
#endif
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
break;
case HA_EXTRA_FLUSH:
if (!share->temporary)
@@ -365,7 +365,7 @@ int mi_extra(MI_INFO *info, enum ha_extr
break;
case HA_EXTRA_MMAP:
#ifdef HAVE_MMAP
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
/*
Memory map the data file if it is not already mapped. It is safe
to memory map a file while other threads are using file I/O on it.
@@ -386,13 +386,13 @@ int mi_extra(MI_INFO *info, enum ha_extr
share->file_write= mi_mmap_pwrite;
}
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
#endif
break;
case HA_EXTRA_MARK_AS_LOG_TABLE:
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
share->is_log_table= TRUE;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
break;
case HA_EXTRA_KEY_CACHE:
case HA_EXTRA_NO_KEY_CACHE:
@@ -463,7 +463,7 @@ int mi_reset(MI_INFO *info)
if (!share->temporary && (info->opt_flag & WRITE_CACHE_USED) &&
(info->lock.type <= TL_READ_NO_INSERT))
{
- safe_mutex_assert_owner(&share->intern_lock);
+ MYSQL_MUTEX_ASSERT_OWNER(&share->intern_lock);
}
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
error= end_io_cache(&info->rec_cache);
=== modified file 'storage/myisam/mi_info.c'
--- a/storage/myisam/mi_info.c 2008-04-09 00:56:49 +0000
+++ b/storage/myisam/mi_info.c 2008-10-10 20:34:55 +0000
@@ -42,10 +42,10 @@ int mi_status(MI_INFO *info, register MI
DBUG_RETURN(0); /* Compatible with ISAM */
if (!(flag & HA_STATUS_NO_LOCK))
{
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
(void) _mi_readinfo(info,F_RDLCK,0);
fast_mi_writeinfo(info);
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
}
if (flag & HA_STATUS_VARIABLE)
{
=== modified file 'storage/myisam/mi_keycache.c'
--- a/storage/myisam/mi_keycache.c 2008-04-08 01:47:13 +0000
+++ b/storage/myisam/mi_keycache.c 2008-10-10 20:34:55 +0000
@@ -96,7 +96,7 @@ int mi_assign_to_key_cache(MI_INFO *info
ensure that setting the key cache and changing the multi_key_cache
is done atomicly
*/
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
/*
Tell all threads to use the new key cache
This should be seen at the lastes for the next call to an myisam function.
@@ -108,7 +108,7 @@ int mi_assign_to_key_cache(MI_INFO *info
share->unique_name_length,
share->key_cache))
error= my_errno;
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
DBUG_RETURN(error);
}
@@ -143,7 +143,7 @@ void mi_change_key_cache(KEY_CACHE *old_
/*
Lock list to ensure that no one can close the table while we manipulate it
*/
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
for (pos=myisam_open_list ; pos ; pos=pos->next)
{
MI_INFO *info= (MI_INFO*) pos->data;
@@ -158,6 +158,6 @@ void mi_change_key_cache(KEY_CACHE *old_
open a new table that will be associted with the old key cache
*/
multi_key_cache_change(old_key_cache, new_key_cache);
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
DBUG_VOID_RETURN;
}
=== modified file 'storage/myisam/mi_locking.c'
--- a/storage/myisam/mi_locking.c 2008-07-23 12:46:33 +0000
+++ b/storage/myisam/mi_locking.c 2008-10-10 20:34:55 +0000
@@ -52,7 +52,7 @@ int mi_lock_database(MI_INFO *info, int
}
flag=error=0;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
if (share->kfile >= 0) /* May only be false on windows */
{
switch (lock_type) {
@@ -242,7 +242,7 @@ int mi_lock_database(MI_INFO *info, int
}
}
#endif
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
if (my_b_inited(&myisam_logical_log))
{
uchar lock_type_buff[4];
@@ -618,11 +618,11 @@ int mi_remap_file_and_write_state_for_un
(info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
{
if (info->s->concurrent_insert)
- rw_wrlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_WRLOCK(&info->s->mmap_lock);
mi_remap_file(info, info->s->state.state.data_file_length);
info->s->nonmmaped_inserts= 0;
if (info->s->concurrent_insert)
- rw_unlock(&info->s->mmap_lock);
+ MYSQL_RWLOCK_UNLOCK(&info->s->mmap_lock);
}
#endif
share->state.process= share->last_process=share->this_process;
=== modified file 'storage/myisam/mi_log.c'
--- a/storage/myisam/mi_log.c 2008-07-09 07:12:43 +0000
+++ b/storage/myisam/mi_log.c 2008-10-10 20:34:55 +0000
@@ -194,7 +194,7 @@ static int mi_log_open_cache(enum enum_m
DBUG_ENTER("mi_log_open_cache");
DBUG_ASSERT(log_filename != NULL);
- pthread_mutex_lock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam_log);
if (type == MI_LOG_LOGICAL)
{
log= &myisam_logical_log;
@@ -235,7 +235,7 @@ static int mi_log_open_cache(enum enum_m
my_close(file, MYF(MY_WME));
}
}
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
DBUG_RETURN(error);
}
@@ -255,7 +255,7 @@ static int mi_log_close_cache(enum enum_
int error= 0;
IO_CACHE *log;
DBUG_ENTER("mi_log_close_cache");
- pthread_mutex_lock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam_log);
if (type == MI_LOG_LOGICAL)
log = &myisam_logical_log;
else
@@ -270,7 +270,7 @@ static int mi_log_close_cache(enum enum_
error= my_errno;
log->file= -1;
}
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
DBUG_RETURN(error);
}
@@ -349,7 +349,7 @@ retry:
- mi_close() flushes indexes while holding THR_LOCK_myisam, and that flush
can cause log writes, so we would lock the mutex twice.
*/
- pthread_mutex_lock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam_log);
/*
We need to check that 'log' is not closed, this can happen for a physical
log. Indeed we do not have full control on the table from the thread doing
@@ -386,7 +386,7 @@ retry:
else if (unlikely(!share->MI_LOG_OPEN_stored_in_physical_log))
{
DBUG_ASSERT(command != MI_LOG_CLOSE);
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
_myisam_log_command(&myisam_physical_log, MI_LOG_OPEN, share,
(uchar *)share->unresolv_file_name,
strlen(share->unresolv_file_name), 0);
@@ -420,7 +420,7 @@ retry:
error=my_lock(log->file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
}
}
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
my_errno=old_errno;
}
@@ -475,7 +475,7 @@ void _myisam_log_record_logical(enum myi
headerlen= 15;
}
- pthread_mutex_lock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam_log);
error= my_lock(myisam_logical_log.file, F_WRLCK, 0L, F_TO_EOF,
MYF(MY_SEEK_NOT_DONE));
(void) my_b_write(&myisam_logical_log, header, headerlen);
@@ -497,7 +497,7 @@ void _myisam_log_record_logical(enum myi
if (!error)
error= my_lock(myisam_logical_log.file, F_UNLCK, 0L, F_TO_EOF,
MYF(MY_SEEK_NOT_DONE));
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
my_errno=old_errno;
}
@@ -553,12 +553,12 @@ void myisam_log_pwrite_physical(enum myi
}
/* pid and result are not needed */
retry:
- pthread_mutex_lock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam_log);
if (likely(my_b_inited(&myisam_physical_log) != NULL))
{
if (unlikely(!share->MI_LOG_OPEN_stored_in_physical_log))
{
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
_myisam_log_command(&myisam_physical_log, MI_LOG_OPEN, share,
(uchar *)share->unresolv_file_name,
strlen(share->unresolv_file_name), 0);
@@ -567,7 +567,7 @@ retry:
(void) my_b_write(&myisam_physical_log, header, headerlen);
(void) my_b_write(&myisam_physical_log, buffert, length);
}
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
my_errno= old_errno;
DBUG_VOID_RETURN;
}
@@ -606,12 +606,12 @@ void myisam_log_chsize_kfile_physical(MY
}
/* pid and result are not needed */
retry:
- pthread_mutex_lock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam_log);
if (likely(my_b_inited(&myisam_physical_log) != NULL))
{
if (unlikely(!share->MI_LOG_OPEN_stored_in_physical_log))
{
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
_myisam_log_command(&myisam_physical_log, MI_LOG_OPEN, share,
(uchar *)share->unresolv_file_name,
strlen(share->unresolv_file_name), 0);
@@ -619,7 +619,7 @@ retry:
}
(void) my_b_write(&myisam_physical_log, header, headerlen);
}
- pthread_mutex_unlock(&THR_LOCK_myisam_log);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam_log);
my_errno= old_errno;
DBUG_VOID_RETURN;
}
@@ -669,10 +669,10 @@ static int mi_log_start_physical(const c
DBUG_ASSERT(log_filename != NULL);
DBUG_ASSERT(hash_inited(tables));
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
if (mi_log_tables_physical) /* physical logging already running */
{
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
DBUG_ASSERT(0); /* because it should not happen */
DBUG_RETURN(1);
}
@@ -712,7 +712,7 @@ static int mi_log_start_physical(const c
}
error= 0;
end:
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
if (unlikely(error))
mi_log_stop_physical(MI_LOG_ACTION_CLOSE_INCONSISTENT, MI_LOG_PHYSICAL,
NULL, NULL);
@@ -754,10 +754,10 @@ static int mi_log_stop_physical(enum enu
DBUG_ASSERT(action == MI_LOG_ACTION_CLOSE_CONSISTENT ||
action == MI_LOG_ACTION_CLOSE_INCONSISTENT);
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
if (mi_log_tables_physical == NULL) /* no physical logging running */
{
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
DBUG_RETURN(0); /* it's ok if it happens */
}
/*
@@ -788,7 +788,7 @@ static int mi_log_stop_physical(enum enu
Must take intern_lock, at least because key cache isn't safe if two
calls to flush_key_blocks_int() run concurrently on the same file.
*/
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
/*
It is possible that some statement just finished, has not called
mi_lock_database(F_UNLCK) yet, and so some key blocks would still be
@@ -830,7 +830,7 @@ static int mi_log_stop_physical(enum enu
mi_print_error(share, HA_ERR_CRASHED);
mi_mark_crashed(info); /* Mark that table must be checked */
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
} /* ... for (list_item=...) */
} /* ... if (action == MI_LOG_ACTION_CLOSE_CONSISTENT) */
@@ -868,7 +868,7 @@ static int mi_log_stop_physical(enum enu
share->MI_LOG_OPEN_stored_in_physical_log= FALSE;
}
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
/*
From this moment on, from the point of view of MyISAM, a new physical log
(a new backup) can start (new log will use a different tmp name).
=== modified file 'storage/myisam/mi_open.c'
--- a/storage/myisam/mi_open.c 2008-08-25 14:26:49 +0000
+++ b/storage/myisam/mi_open.c 2008-10-10 20:34:55 +0000
@@ -112,7 +112,7 @@ MI_INFO *mi_open(const char *name, int m
DBUG_RETURN (NULL);
}
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
if (!(old_info=test_if_reopen(name_buff)))
{
share= &share_buff;
@@ -345,9 +345,9 @@ MI_INFO *mi_open(const char *name, int m
&share->state.key_del,
(share->state.header.max_block_size_index*sizeof(my_off_t)),
#ifdef THREAD
- &share->key_root_lock,sizeof(rw_lock_t)*keys,
+ &share->key_root_lock,sizeof(mysql_rwlock_t)*keys,
#endif
- &share->mmap_lock,sizeof(rw_lock_t),
+ &share->mmap_lock,sizeof(mysql_rwlock_t),
NullS))
goto err;
errpos=4;
@@ -651,7 +651,7 @@ MI_INFO *mi_open(const char *name, int m
info.ft1_to_ft2=0;
info.errkey= -1;
info.page_changed=1;
- pthread_mutex_lock(&share->intern_lock);
+ MYSQL_MUTEX_LOCK(&share->intern_lock);
info.read_record=share->read_record;
share->reopen++;
share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL);
@@ -682,7 +682,7 @@ MI_INFO *mi_open(const char *name, int m
mi_state_info_write(share, share->kfile, &share->state, 1);
}
- pthread_mutex_unlock(&share->intern_lock);
+ MYSQL_MUTEX_UNLOCK(&share->intern_lock);
/* Allocate buffer for one record */
@@ -702,7 +702,7 @@ MI_INFO *mi_open(const char *name, int m
m_info->open_list.data=(void*) m_info;
myisam_open_list=list_add(myisam_open_list,&m_info->open_list);
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
if (my_b_inited(&myisam_logical_log))
{
intern_filename(name_buff,share->index_file_name);
@@ -743,7 +743,7 @@ err:
default:
break;
}
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
my_errno=save_errno;
DBUG_RETURN (NULL);
} /* mi_open */
=== modified file 'storage/myisam/mi_panic.c'
--- a/storage/myisam/mi_panic.c 2008-07-01 20:32:27 +0000
+++ b/storage/myisam/mi_panic.c 2008-10-10 20:34:55 +0000
@@ -30,17 +30,17 @@ int mi_panic(enum ha_panic_function flag
MI_INFO *info;
DBUG_ENTER("mi_panic");
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
for (list_element=myisam_open_list ; list_element ; list_element=next_open)
{
next_open=list_element->next; /* Save if close */
info=(MI_INFO*) list_element->data;
switch (flag) {
case HA_PANIC_CLOSE:
- pthread_mutex_unlock(&THR_LOCK_myisam); /* Not exactly right... */
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam); /* Not exactly right... */
if (mi_close(info))
error=my_errno;
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
break;
case HA_PANIC_WRITE: /* Do this to free databases */
#ifdef CANT_OPEN_FILES_TWICE
@@ -110,7 +110,7 @@ int mi_panic(enum ha_panic_function flag
mi_log(MI_LOG_ACTION_CLOSE_INCONSISTENT, MI_LOG_LOGICAL, NULL, NULL);
ft_free_stopwords();
}
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
if (!error)
DBUG_RETURN(0);
DBUG_RETURN(my_errno=error);
=== modified file 'storage/myisam/mi_range.c'
--- a/storage/myisam/mi_range.c 2008-06-26 05:18:28 +0000
+++ b/storage/myisam/mi_range.c 2008-10-10 20:34:55 +0000
@@ -57,7 +57,7 @@ ha_rows mi_records_in_range(MI_INFO *inf
DBUG_RETURN(HA_POS_ERROR);
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
if (info->s->concurrent_insert)
- rw_rdlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_RDLOCK(&info->s->key_root_lock[inx]);
switch(info->s->keyinfo[inx].key_alg){
#ifdef HAVE_RTREE_KEYS
@@ -106,7 +106,7 @@ ha_rows mi_records_in_range(MI_INFO *inf
}
if (info->s->concurrent_insert)
- rw_unlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&info->s->key_root_lock[inx]);
fast_mi_writeinfo(info);
DBUG_PRINT("info",("records: %ld",(ulong) (res)));
=== modified file 'storage/myisam/mi_rkey.c'
--- a/storage/myisam/mi_rkey.c 2008-05-29 15:44:11 +0000
+++ b/storage/myisam/mi_rkey.c 2008-10-10 20:34:55 +0000
@@ -73,7 +73,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, i
goto err;
if (share->concurrent_insert)
- rw_rdlock(&share->key_root_lock[inx]);
+ MYSQL_RWLOCK_RDLOCK(&share->key_root_lock[inx]);
nextflag=myisam_read_vec[search_flag];
use_key_length=pack_key_length;
@@ -88,7 +88,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, i
mi_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
if (share->concurrent_insert)
- rw_unlock(&share->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[inx]);
goto err;
}
break;
@@ -152,7 +152,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, i
{
info->lastpos= HA_OFFSET_ERROR;
if (share->concurrent_insert)
- rw_unlock(&share->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[inx]);
DBUG_RETURN((my_errno= HA_ERR_KEY_NOT_FOUND));
}
/*
@@ -168,7 +168,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, i
}
}
if (share->concurrent_insert)
- rw_unlock(&share->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[inx]);
/* Calculate length of the found key; Used by mi_rnext_same */
if ((keyinfo->flag & HA_VAR_LENGTH_KEY) && last_used_keyseg &&
=== modified file 'storage/myisam/mi_rnext.c'
--- a/storage/myisam/mi_rnext.c 2007-06-27 17:48:00 +0000
+++ b/storage/myisam/mi_rnext.c 2008-10-10 20:34:55 +0000
@@ -40,7 +40,7 @@ int mi_rnext(MI_INFO *info, uchar *buf,
if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno);
if (info->s->concurrent_insert)
- rw_rdlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_RDLOCK(&info->s->key_root_lock[inx]);
changed=_mi_test_if_changed(info);
if (!flag)
{
@@ -100,14 +100,14 @@ int mi_rnext(MI_INFO *info, uchar *buf,
if (!error && res == 2)
{
if (info->s->concurrent_insert)
- rw_unlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&info->s->key_root_lock[inx]);
info->lastpos= HA_OFFSET_ERROR;
DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
}
}
if (info->s->concurrent_insert)
- rw_unlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&info->s->key_root_lock[inx]);
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
=== modified file 'storage/myisam/mi_rnext_same.c'
--- a/storage/myisam/mi_rnext_same.c 2007-06-27 17:48:00 +0000
+++ b/storage/myisam/mi_rnext_same.c 2008-10-10 20:34:55 +0000
@@ -38,7 +38,7 @@ int mi_rnext_same(MI_INFO *info, uchar *
DBUG_RETURN(my_errno);
if (info->s->concurrent_insert)
- rw_rdlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_RDLOCK(&info->s->key_root_lock[inx]);
switch (keyinfo->key_alg)
{
@@ -82,7 +82,7 @@ int mi_rnext_same(MI_INFO *info, uchar *
}
}
if (info->s->concurrent_insert)
- rw_unlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&info->s->key_root_lock[inx]);
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME;
=== modified file 'storage/myisam/mi_rprev.c'
--- a/storage/myisam/mi_rprev.c 2007-05-10 09:59:39 +0000
+++ b/storage/myisam/mi_rprev.c 2008-10-10 20:34:55 +0000
@@ -39,7 +39,7 @@ int mi_rprev(MI_INFO *info, uchar *buf,
DBUG_RETURN(my_errno);
changed=_mi_test_if_changed(info);
if (share->concurrent_insert)
- rw_rdlock(&share->key_root_lock[inx]);
+ MYSQL_RWLOCK_RDLOCK(&share->key_root_lock[inx]);
if (!flag)
error=_mi_search_last(info, share->keyinfo+inx,
share->state.key_root[inx]);
@@ -65,7 +65,7 @@ int mi_rprev(MI_INFO *info, uchar *buf,
break;
}
}
- rw_unlock(&share->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[inx]);
}
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_PREV_FOUND;
=== modified file 'storage/myisam/mi_rsame.c'
--- a/storage/myisam/mi_rsame.c 2008-04-09 00:56:49 +0000
+++ b/storage/myisam/mi_rsame.c 2008-10-10 20:34:55 +0000
@@ -49,12 +49,12 @@ int mi_rsame(MI_INFO *info, uchar *recor
info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
info->lastpos);
if (info->s->concurrent_insert)
- rw_rdlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_RDLOCK(&info->s->key_root_lock[inx]);
(void) _mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY,
SEARCH_SAME,
info->s->state.key_root[inx]);
if (info->s->concurrent_insert)
- rw_unlock(&info->s->key_root_lock[inx]);
+ MYSQL_RWLOCK_UNLOCK(&info->s->key_root_lock[inx]);
}
if (!(*info->read_record)(info,info->lastpos,record))
=== modified file 'storage/myisam/mi_write.c'
--- a/storage/myisam/mi_write.c 2008-07-09 07:12:43 +0000
+++ b/storage/myisam/mi_write.c 2008-10-10 20:34:55 +0000
@@ -107,7 +107,7 @@ int mi_write(MI_INFO *info, uchar *recor
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
{
- rw_wrlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_WRLOCK(&share->key_root_lock[i]);
share->keyinfo[i].version++;
}
if (share->keyinfo[i].flag & HA_FULLTEXT )
@@ -115,7 +115,7 @@ int mi_write(MI_INFO *info, uchar *recor
if (_mi_ft_add(info,i, buff, record, filepos))
{
if (local_lock_tree)
- rw_unlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
@@ -126,7 +126,7 @@ int mi_write(MI_INFO *info, uchar *recor
_mi_make_key(info,i,buff,record,filepos)))
{
if (local_lock_tree)
- rw_unlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
@@ -136,7 +136,7 @@ int mi_write(MI_INFO *info, uchar *recor
info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree)
- rw_unlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[i]);
}
}
if (share->calc_checksum)
@@ -198,13 +198,13 @@ err:
!(info->bulk_insert &&
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
- rw_wrlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_WRLOCK(&share->key_root_lock[i]);
if (share->keyinfo[i].flag & HA_FULLTEXT)
{
if (_mi_ft_del(info,i, buff,record,filepos))
{
if (local_lock_tree)
- rw_unlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[i]);
break;
}
}
@@ -214,12 +214,12 @@ err:
if (_mi_ck_delete(info,i,buff,key_length))
{
if (local_lock_tree)
- rw_unlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[i]);
break;
}
}
if (local_lock_tree)
- rw_unlock(&share->key_root_lock[i]);
+ MYSQL_RWLOCK_UNLOCK(&share->key_root_lock[i]);
}
}
}
@@ -935,7 +935,7 @@ static int keys_free(uchar *key, TREE_FR
case free_init:
if (param->info->s->concurrent_insert)
{
- rw_wrlock(¶m->info->s->key_root_lock[param->keynr]);
+ MYSQL_RWLOCK_WRLOCK(¶m->info->s->key_root_lock[param->keynr]);
param->info->s->keyinfo[param->keynr].version++;
}
return 0;
@@ -947,7 +947,7 @@ static int keys_free(uchar *key, TREE_FR
keylen - param->info->s->rec_reflength);
case free_end:
if (param->info->s->concurrent_insert)
- rw_unlock(¶m->info->s->key_root_lock[param->keynr]);
+ MYSQL_RWLOCK_UNLOCK(¶m->info->s->key_root_lock[param->keynr]);
return 0;
}
return -1;
=== modified file 'storage/myisam/myisam_backup_engine.cc'
--- a/storage/myisam/myisam_backup_engine.cc 2008-08-11 16:06:30 +0000
+++ b/storage/myisam/myisam_backup_engine.cc 2008-10-10 20:34:55 +0000
@@ -193,6 +193,9 @@ class Engine: public Backup_engine
class Object_backup;
+#ifdef HAVE_PSI_INTERFACE
+PSI_cond_key key_COND_lock_state;
+#endif
/**
Handles backup orders received from the backup kernel (implements the API).
@@ -249,7 +252,7 @@ private:
*/
THD *lock_thd;
bool cannot_delete_lock_thd;
- pthread_cond_t COND_lock_state; ///< for communication with locking thread
+ mysql_cond_t COND_lock_state; ///< for communication with locking thread
void kill_locking_thread();
static const size_t bytes_between_sleeps= 10*1024*1024;
/** After copying bytes_between_sleeps we sleep sleep_time */
@@ -377,7 +380,7 @@ Backup::Backup(const Table_list &tables)
Driver is not ready at this point, so state is ERROR.
This constructor cannot fail, otherwise begin() would have to detect it.
*/
- pthread_cond_init(&COND_lock_state, NULL);
+ MYSQL_COND_INIT(&COND_lock_state, key_COND_lock_state, NULL);
}
@@ -392,7 +395,7 @@ void Backup::kill_locking_thread()
(LOCK_ERROR).
*/
retry:
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_LOCK(&THR_LOCK_myisam);
/* If thread started and not already dead, kill it */
if ((lock_state != LOCK_NOT_STARTED) & (lock_state != LOCK_ERROR))
{
@@ -402,7 +405,7 @@ retry:
*/
if (unlikely(lock_thd == NULL))
{
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
DBUG_PRINT("info",("lock_thd not yet set"));
sleep(1);
goto retry;
@@ -423,25 +426,25 @@ retry:
So So we set a flag:
*/
cannot_delete_lock_thd= TRUE;
- pthread_mutex_unlock(&THR_LOCK_myisam);
+ MYSQL_MUTEX_UNLOCK(&THR_LOCK_myisam);
/*
So now lock_thd cannot be destroyed.
We kill the thread (which will in particular work if it is waiting for
some table locks).
*/
- 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);
+ MYSQL_MUTEX_UNLOCK(&lock_thd->LOCK_delete);
/* won't look at lock_thd anymore, allow its deletion */
- pthread_mutex_lock(&THR_LOCK_myisam);
+ MYSQL_MU