summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/event_queue.cc8
-rw-r--r--sql/event_scheduler.cc36
-rw-r--r--sql/ha_ndbcluster_binlog.cc8
-rw-r--r--sql/item_func.cc4
-rw-r--r--sql/lock.cc2
-rw-r--r--sql/log.cc4
-rw-r--r--sql/mysql_priv.h14
-rw-r--r--sql/mysqld.cc165
-rw-r--r--sql/repl_failsafe.cc8
-rw-r--r--sql/scheduler.cc4
-rw-r--r--sql/slave.cc20
-rw-r--r--sql/slave.h2
-rw-r--r--sql/sp_head.cc6
-rw-r--r--sql/sql_insert.cc18
-rw-r--r--sql/sql_parse.cc10
-rw-r--r--sql/sql_repl.cc32
-rw-r--r--sql/sql_show.cc14
17 files changed, 182 insertions, 173 deletions
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index 7d987db411a..cf63ba937e0 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -343,7 +343,7 @@ Event_queue::drop_matching_events(THD *thd, LEX_STRING pattern,
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
@@ -706,13 +706,13 @@ Event_queue::unlock_data(const char *func, uint line)
/*
- 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
*/
@@ -729,7 +729,7 @@ Event_queue::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
thd->enter_cond(&COND_queue_state, &LOCK_event_queue, msg);
- DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
+ DBUG_PRINT("info", ("mysql_cond_%swait", abstime? "timed":""));
if (!abstime)
mysql_cond_wait(&COND_queue_state, &LOCK_event_queue);
else
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 486b03fc58e..5d8455fa88b 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -129,11 +129,11 @@ post_init_event_thread(THD *thd)
return TRUE;
}
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
threads.append(thd);
thread_count++;
inc_thread_running();
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
return FALSE;
}
@@ -153,12 +153,12 @@ 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--;
dec_thread_running();
delete thd;
- pthread_cond_broadcast(&COND_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_cond_broadcast(&COND_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
}
@@ -190,9 +190,9 @@ pre_init_event_thread(THD* thd)
thd->slave_thread= 0;
thd->variables.option_bits|= 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
@@ -421,12 +421,12 @@ Event_scheduler::start()
new_thd->proc_info= "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--;
dec_thread_running();
delete new_thd;
- pthread_cond_broadcast(&COND_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_cond_broadcast(&COND_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
}
end:
UNLOCK_DATA();
@@ -555,12 +555,12 @@ error:
new_thd->proc_info= "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--;
dec_thread_running();
delete new_thd;
- pthread_cond_broadcast(&COND_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_cond_broadcast(&COND_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
}
delete event_name;
DBUG_RETURN(TRUE);
@@ -675,12 +675,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);
}
@@ -733,12 +733,12 @@ Event_scheduler::unlock_data(const char *func, uint line)
/*
- 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
@@ -756,7 +756,7 @@ Event_scheduler::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
if (thd)
thd->enter_cond(&COND_state, &LOCK_scheduler_state, msg);
- DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
+ DBUG_PRINT("info", ("mysql_cond_%swait", abstime? "timed":""));
if (!abstime)
mysql_cond_wait(&COND_state, &LOCK_scheduler_state);
else
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index 25f8474feae..f2e2e38a167 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -3659,9 +3659,9 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
/* 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);
mysql_thread_set_psi_id(thd->thread_id);
@@ -3697,9 +3697,9 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
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, "")) ||
diff --git a/sql/item_func.cc b/sql/item_func.cc
index d0af0d5f5e9..a7b2609470f 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3502,7 +3502,7 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
@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))
@@ -3822,7 +3822,7 @@ 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
diff --git a/sql/lock.cc b/sql/lock.cc
index 0235c4ae881..6106e20678a 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -1607,7 +1607,7 @@ bool make_global_read_lock_block_commit(THD *thd)
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.
diff --git a/sql/log.cc b/sql/log.cc
index 3680398f068..7776b6bfbdc 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -3075,7 +3075,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;
@@ -3168,7 +3168,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
err:
if (error == 1)
name= const_cast<char*>(save_name);
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
mysql_mutex_unlock(&LOCK_index);
mysql_mutex_unlock(&LOCK_log);
DBUG_RETURN(error);
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 36d35ec8877..53e91ce6552 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -2057,7 +2057,7 @@ extern mysql_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
LOCK_global_system_variables, LOCK_user_conn,
LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
-extern MYSQL_PLUGIN_IMPORT pthread_mutex_t LOCK_thread_count;
+extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count;
#ifdef HAVE_OPENSSL
extern mysql_mutex_t LOCK_des_key_file;
#endif
@@ -2066,7 +2066,7 @@ extern mysql_cond_t COND_server_started;
extern int mysqld_server_started;
extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
extern mysql_rwlock_t LOCK_system_variables_hash;
-extern pthread_cond_t COND_thread_count;
+extern mysql_cond_t COND_thread_count;
extern mysql_cond_t COND_refresh, COND_manager;
extern mysql_cond_t COND_global_read_lock;
extern pthread_attr_t connection_attrib;
@@ -2428,9 +2428,9 @@ inline const char *table_case_name(HA_CREATE_INFO *info, const char *name)
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;
}
@@ -2678,7 +2678,8 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_master_info_data_lock, key_master_info_run_lock,
key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
- key_structure_guard_mutex, key_TABLE_SHARE_mutex, key_LOCK_error_messages;
+ key_structure_guard_mutex, key_TABLE_SHARE_mutex, key_LOCK_error_messages,
+ key_LOCK_thread_count;
extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
@@ -2696,7 +2697,8 @@ extern PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
key_master_info_start_cond, key_master_info_stop_cond,
key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
- key_TABLE_SHARE_cond, key_user_level_lock_cond;
+ key_TABLE_SHARE_cond, key_user_level_lock_cond,
+ key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache;
extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
key_thread_handle_manager, key_thread_kill_server, key_thread_main,
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 28c299bdf91..e0ccab7872b 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -302,6 +302,7 @@ TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
#ifdef HAVE_PSI_INTERFACE
#if (defined(_WIN32) || defined(HAVE_SMEM)) && !defined(EMBEDDED_LIBRARY)
static PSI_thread_key key_thread_handle_con_namedpipes;
+static PSI_cond_key key_COND_handler_count;
#endif /* _WIN32 || HAVE_SMEM && !EMBEDDED_LIBRARY */
#if defined(HAVE_SMEM) && !defined(EMBEDDED_LIBRARY)
@@ -341,8 +342,7 @@ static bool binlog_format_used= false;
LEX_STRING opt_init_connect, opt_init_slave;
-/* Not instrumented because of LOCK_thread_count */
-static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
+static mysql_cond_t COND_thread_cache, COND_flush_thread_cache;
/* Global variables */
@@ -601,8 +601,7 @@ SHOW_COMP_OPTION have_profiling;
pthread_key(MEM_ROOT**,THR_MALLOC);
pthread_key(THD*, THR_THD);
-/* Not instrumented because of Bug#47396 */
-pthread_mutex_t LOCK_thread_count;
+mysql_mutex_t LOCK_thread_count;
mysql_mutex_t LOCK_mysql_create_db, LOCK_open,
LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
LOCK_error_log, LOCK_uuid_generator,
@@ -624,7 +623,7 @@ mysql_mutex_t LOCK_des_key_file;
#endif
mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
mysql_rwlock_t LOCK_system_variables_hash;
-pthread_cond_t COND_thread_count;
+mysql_cond_t COND_thread_count;
mysql_cond_t COND_refresh, COND_global_read_lock;
pthread_t signal_thread;
pthread_attr_t connection_attrib;
@@ -839,7 +838,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;
@@ -979,7 +978,7 @@ static void close_connections(void)
#if !defined(__WIN__) && !defined(__NETWARE__)
DBUG_PRINT("quit", ("waiting for select thread: 0x%lx",
(ulong) select_thread));
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
while (select_thread_in_use)
{
@@ -995,18 +994,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,
- &abstime);
+ error= mysql_cond_timedwait(&COND_thread_count, &LOCK_thread_count,
+ &abstime);
if (error != EINTR)
break;
}
#ifdef EXTRA_DEBUG
if (error != 0 && !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);
+ mysql_mutex_unlock(&LOCK_thread_count);
#endif /* __WIN__ */
@@ -1063,7 +1062,7 @@ static void close_connections(void)
*/
THD *tmp;
- (void) 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++))
@@ -1089,7 +1088,7 @@ static void close_connections(void)
mysql_mutex_unlock(&tmp->mysys_var->mutex);
}
}
- pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
+ mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list
Events::deinit();
end_slave();
@@ -1106,11 +1105,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
+ 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);
+ mysql_mutex_unlock(&LOCK_thread_count);
break;
}
#ifndef __bsdi__ // Bug in BSDI kernel
@@ -1125,17 +1124,17 @@ static void close_connections(void)
}
#endif
DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ 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);
+ mysql_mutex_lock(&LOCK_thread_count);
while (thread_count)
{
- (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
+ 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);
+ mysql_mutex_unlock(&LOCK_thread_count);
close_active_mi();
DBUG_PRINT("quit",("close_connections thread"));
@@ -1477,12 +1476,12 @@ void clean_up(bool print_message)
logger.cleanup_end();
my_atomic_rwlock_destroy(&global_query_id_lock);
my_atomic_rwlock_destroy(&thread_running_lock);
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ 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);
+ mysql_cond_broadcast(&COND_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
sys_var_end();
/*
@@ -1523,7 +1522,7 @@ static void clean_up_mutexes()
mysql_mutex_destroy(&LOCK_lock_db);
mysql_rwlock_destroy(&LOCK_grant);
mysql_mutex_destroy(&LOCK_open);
- pthread_mutex_destroy(&LOCK_thread_count);
+ mysql_mutex_destroy(&LOCK_thread_count);
mysql_mutex_destroy(&LOCK_mapped_file);
mysql_mutex_destroy(&LOCK_status);
mysql_mutex_destroy(&LOCK_delayed_insert);
@@ -1555,11 +1554,11 @@ static void clean_up_mutexes()
mysql_mutex_destroy(&LOCK_uuid_generator);
mysql_mutex_destroy(&LOCK_prepared_stmt_count);
mysql_mutex_destroy(&LOCK_error_messages);
- pthread_cond_destroy(&COND_thread_count);
+ mysql_cond_destroy(&COND_thread_count);
mysql_cond_destroy(&COND_refresh);
mysql_cond_destroy(&COND_global_read_lock);
- pthread_cond_destroy(&COND_thread_cache);
- pthread_cond_destroy(&COND_flush_thread_cache);
+ mysql_cond_destroy(&COND_thread_cache);
+ mysql_cond_destroy(&COND_flush_thread_cache);
mysql_cond_destroy(&COND_manager);
}
#endif /*EMBEDDED_LIBRARY*/
@@ -1968,7 +1967,7 @@ void close_connection(THD *thd, uint errcode, bool lock)
"(not connected)",
errcode ? ER_DEFAULT(errcode) : ""));
if (lock)
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
thd->killed= THD::KILL_CONNECTION;
if ((vio= thd->net.vio) != 0)
{
@@ -1978,7 +1977,7 @@ void close_connection(THD *thd, uint errcode, bool lock)
vio_close(vio); /* vio is freed in delete thd */
}
if (lock)
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
MYSQL_CONNECTION_DONE((int) errcode, thd->thread_id);
if (MYSQL_CONNECTION_DONE_ENABLED())
{
@@ -2025,7 +2024,7 @@ void unlink_thd(THD *thd)
--connection_count;
mysql_mutex_unlock(&LOCK_connection_count);
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
thread_count--;
delete thd;
DBUG_VOID_RETURN;
@@ -2050,7 +2049,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)
{
@@ -2058,10 +2057,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);
+ 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;
@@ -2109,14 +2108,14 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
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);
+ mysql_cond_broadcast(&COND_thread_count);
DBUG_LEAVE; // Must match DBUG_ENTER()
pthread_exit(0);
@@ -2126,15 +2125,15 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
void flush_thread_cache()
{
- pthread_mutex_lock(&LOCK_thread_count);
+ 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--;
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
}
@@ -2828,7 +2827,7 @@ static void start_signal_handler(void)
#endif
#endif
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
if ((error= mysql_thread_create(key_thread_signal_hand,
&signal_thread, &thr_attr, signal_hand, 0)))
{
@@ -2836,8 +2835,8 @@ static void start_signal_handler(void)
error,errno);
exit(1);
}
- (void) 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);
(void) pthread_attr_destroy(&thr_attr);
DBUG_VOID_RETURN;
@@ -2895,11 +2894,11 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
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.
*/
- pthread_mutex_lock(&LOCK_thread_count);
- pthread_mutex_unlock(&LOCK_thread_count);
- pthread_cond_broadcast(&COND_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
+ mysql_cond_broadcast(&COND_thread_count);
(void) pthread_sigmask(SIG_BLOCK,&set,NULL);
for (;;)
@@ -3692,7 +3691,7 @@ static int init_thread_environment()
&LOCK_mysql_create_db, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_lock_db, &LOCK_lock_db, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&LOCK_thread_count, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_mapped_file, &LOCK_mapped_file, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_delayed_insert,
@@ -3738,11 +3737,11 @@ static int init_thread_environment()
mysql_rwlock_init(key_rwlock_LOCK_sys_init_connect, &LOCK_sys_init_connect);
mysql_rwlock_init(key_rwlock_LOCK_sys_init_slave, &LOCK_sys_init_slave);
mysql_rwlock_init(key_rwlock_LOCK_grant, &LOCK_grant);
- pthread_cond_init(&COND_thread_count, NULL);
+ mysql_cond_init(key_COND_thread_count, &COND_thread_count, NULL);
mysql_cond_init(key_COND_refresh, &COND_refresh, NULL);
mysql_cond_init(key_COND_global_read_lock, &COND_global_read_lock, NULL);
- pthread_cond_init(&COND_thread_cache, NULL);
- pthread_cond_init(&COND_flush_thread_cache, NULL);
+ mysql_cond_init(key_COND_thread_cache, &COND_thread_cache, NULL);
+ mysql_cond_init(key_COND_flush_thread_cache, &COND_flush_thread_cache, NULL);
mysql_cond_init(key_COND_manager, &COND_manager, NULL);
#ifdef HAVE_REPLICATION
mysql_mutex_init(key_LOCK_rpl_status, &LOCK_rpl_status, MY_MUTEX_INIT_FAST);
@@ -4337,8 +4336,8 @@ static void handle_connections_methods()
unireg_abort(1); // Will not return
}
- pthread_mutex_lock(&LOCK_thread_count);
- (void) pthread_cond_init(&COND_handler_count,NULL);
+ mysql_mutex_lock(&LOCK_thread_count);
+ mysql_cond_init(key_COND_handler_count, &COND_handler_count, NULL);
handler_count=0;
if (hPipe != INVALID_HANDLE_VALUE)
{
@@ -4377,17 +4376,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
@@ -4834,21 +4833,21 @@ int mysqld_main(int argc, char **argv)
#ifdef EXTRA_DEBUG2
sql_print_error("Before Lock_thread_count");
#endif
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ 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);
+ mysql_mutex_unlock(&LOCK_thread_count);
+ 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);
+ 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);
+ mysql_mutex_unlock(&LOCK_thread_count);
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
if (Service.IsNT() && start_mode)
@@ -5122,13 +5121,13 @@ static void bootstrap(MYSQL_FILE *file)
DBUG_VOID_RETURN;
}
/* Wait for thread to die */
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
while (in_bootstrap)
{
- pthread_cond_wait(&COND_thread_count, &LOCK_thread_count);
+ mysql_cond_wait(&COND_thread_count, &LOCK_thread_count);
DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
#else
thd->mysql= 0;
do_handle_bootstrap(thd);
@@ -5166,10 +5165,10 @@ static bool read_init_file(char *file_name)
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);
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
thd->start_utime= my_micro_time();
do_handle_one_connection(thd);
}
@@ -5186,7 +5185,7 @@ void create_thread_to_handle_connection(THD *thd)
/* Get thread from cache */
thread_cache.append(thd);
wake_thread++;
- pthread_cond_signal(&COND_thread_cache);
+ mysql_cond_signal(&COND_thread_cache);
}
else
{
@@ -5208,7 +5207,7 @@ void create_thread_to_handle_connection(THD *thd)
error));
thread_count--;
thd->killed= THD::KILL_CONNECTION; // Safety
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
mysql_mutex_lock(&LOCK_connection_count);
--connection_count;
@@ -5219,15 +5218,15 @@ void create_thread_to_handle_connection(THD *thd)
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, NULL);
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
close_connection(thd,0,0);
delete thd;
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
return;
/* purecov: end */
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
DBUG_PRINT("info",("Thread created"));
}
@@ -5275,7 +5274,7 @@ static void create_new_thread(THD *thd)
/* 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
@@ -7851,9 +7850,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);
}
@@ -7899,7 +7898,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
key_structure_guard_mutex, key_TABLE_SHARE_mutex, key_LOCK_error_messages,
- key_LOG_INFO_lock;
+ key_LOG_INFO_lock, key_LOCK_thread_count;
static PSI_mutex_info all_server_mutexes[]=
{
@@ -7952,7 +7951,8 @@ static PSI_mutex_info all_server_mutexes[]=
{ &key_structure_guard_mutex, "Query_cache::structure_guard_mutex", 0},
{ &key_TABLE_SHARE_mutex, "TABLE_SHARE::mutex", 0},
{ &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_GLOBAL},
- { &key_LOG_INFO_lock, "LOG_INFO::lock", 0}
+ { &key_LOG_INFO_lock, "LOG_INFO::lock", 0},
+ { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL}
};
PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
@@ -7981,10 +7981,14 @@ PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
key_master_info_start_cond, key_master_info_stop_cond,
key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
- key_TABLE_SHARE_cond, key_user_level_lock_cond;
+ key_TABLE_SHARE_cond, key_user_level_lock_cond,
+ key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache;
static PSI_cond_info all_server_conds[]=
{
+#if (defined(_WIN32) || defined(HAVE_SMEM)) && !defined(EMBEDDED_LIBRARY)
+ { &key_COND_handler_count, "COND_handler_count", PSI_FLAG_GLOBAL},
+#endif /* _WIN32 || HAVE_SMEM && !EMBEDDED_LIBRARY */
#ifdef HAVE_MMAP
{ &key_PAGE_cond, "PAGE::cond", 0},
{ &key_COND_active, "TC_LOG_MMAP::COND_active", 0},
@@ -8009,7 +8013,10 @@ static PSI_cond_info all_server_conds[]=
{ &key_relay_log_info_start_cond, "Relay_log_info::start_cond", 0},
{ &key_relay_log_info_stop_cond, "Relay_log_info::stop_cond", 0},
{ &key_TABLE_SHARE_cond, "TABLE_SHARE::cond", 0},
- { &key_user_level_lock_cond, "User_level_lock::cond", 0}
+ { &key_user_level_lock_cond, "User_level_lock::cond", 0},
+ { &key_COND_thread_count, "COND_thread_count", PSI_FLAG_GLOBAL},
+ { &key_COND_thread_cache, "COND_thread_cache", PSI_FLAG_GLOBAL},
+ { &key_COND_flush_thread_cache, "COND_flush_thread_cache", PSI_FLAG_GLOBAL}
};
PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 5f206f194e4..e10288552a5 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -83,9 +83,9 @@ static int init_failsafe_rpl_thread(THD* 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())
{
@@ -413,9 +413,9 @@ mi_inited:
err:
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)
mysql_file_close(file, MYF(MY_WME));
if (last_file >= 0 && last_file != file)
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index b05bdf4756f..b308b84eb19 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007 MySQL AB
+/* Copyright (C) 2007 MySQL AB, 2008-2010 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,7 +54,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
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 654ccfe72b5..97f394bf19c 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1969,9 +1969,9 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
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););
@@ -2669,9 +2669,9 @@ pthread_handler_t handle_slave_io(void *arg)
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;
mysql_mutex_unlock(&mi->run_lock);
@@ -2968,10 +2968,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;
@@ -3086,9 +3086,9 @@ pthread_handler_t handle_slave_sql(void *arg)
thd->init_for_queries();
thd->temporary_tables = rli->save_temporary_tables; // restore temp tables
set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved 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
@@ -3332,10 +3332,10 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
THD_CHECK_SENTRY(thd);
rli->sql_thd= 0;
set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables
- 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
diff --git a/sql/slave.h b/sql/slave.h
index 421f838f188..f01eccf09f4 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -158,7 +158,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
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(
#ifdef HAVE_PSI_INTERFACE
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 6e69b2e39a4..dd761490753 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1,4 +1,4 @@
-/* Copyright 2002-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright 2002-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1767,9 +1767,9 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
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->variables.option_bits;
thd->variables.option_bits&= ~OPTION_BIN_LOG;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index c774cb4f3ad..748052b2985 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1808,11 +1808,11 @@ public:
mysql_mutex_init(key_delayed_insert_mutex, &mutex, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_delayed_insert_cond, &cond, NULL);
mysql_cond_init(key_delayed_insert_cond_client, &cond_client, NULL);
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
delayed_insert_threads++;
delayed_lock= global_system_variables.low_priority_updates ?
TL_WRITE_LOW_PRIORITY : TL_WRITE;
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
}
~Delayed_insert()
{
@@ -1822,7 +1822,7 @@ public:
delete row;
if (table)
close_thread_tables(&thd);
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
mysql_mutex_destroy(&mutex);
mysql_cond_destroy(&cond);
mysql_cond_destroy(&cond_client);
@@ -1831,8 +1831,8 @@ public:
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 */
@@ -1965,9 +1965,9 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
{
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, (uint) strlen(table_list->db));
di->thd.set_query(my_strdup(table_list->table_name,
MYF(MY_WME | ME_FATALERROR)), 0);
@@ -2345,12 +2345,12 @@ pthread_handler_t handle_delayed_insert(void *arg)
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);
mysql_thread_set_psi_id(thd->thread_id);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 49d18cbe5d7..d8e82c3e0d1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -556,11 +556,11 @@ end:
delete thd;
#ifndef EMBEDDED_LIBRARY
- (void) pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
thread_count--;
in_bootstrap= FALSE;
- (void) pthread_cond_broadcast(&COND_thread_count);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_cond_broadcast(&COND_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
my_thread_end();
pthread_exit(0);
#endif
@@ -7003,7 +7003,7 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query)
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++))
{
@@ -7015,7 +7015,7 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query)
break;
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
if (tmp)
{
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 960a0adab2e..51a8ba12358 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -214,7 +214,7 @@ void adjust_linfo_offsets(my_off_t purge_offset)
{
THD *tmp;
- pthread_mutex_lock(&LOCK_thread_count);
+ mysql_mutex_lock(&LOCK_thread_count);
I_List_iterator<THD> it(threads);
while ((tmp=it++))
@@ -235,7 +235,7 @@ void adjust_linfo_offsets(my_off_t purge_offset)
mysql_mutex_unlock(&linfo->lock);
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
}
@@ -245,7 +245,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++))
@@ -262,7 +262,7 @@ bool log_in_use(const char* log_name)
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
return result;
}
@@ -516,9 +516,9 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
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)
{
@@ -967,9 +967,9 @@ end:
RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags));
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:
@@ -983,9 +983,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)
mysql_file_close(file, MYF(MY_WME));
@@ -1296,7 +1296,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;
@@ -1309,7 +1309,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
break;
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
if (tmp)
{
/*
@@ -1724,9 +1724,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;
@@ -1812,9 +1812,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);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d562739f913..9e34c1f2d17 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1727,7 +1727,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
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);
@@ -1780,7 +1780,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
}
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ mysql_mutex_unlock(&LOCK_thread_count);
thread_info *thd_info;
time_t now= my_time(0);
@@ -1819,7 +1819,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
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)
{
@@ -1894,13 +1894,13 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
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);
}
@@ -2267,7 +2267,7 @@ void calc_sum_of_all_status(STATUS_VAR *to)
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;
@@ -2279,7 +2279,7 @@ void calc_sum_of_all_status(STATUS_VAR *to)
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;
}