WL#2360 Performance schema
Part III: mysys instrumentation
This commit is contained in:
parent
6fd3866c6c
commit
c082955f06
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2001-2006 MySQL AB
|
/* Copyright (C) 2001-2006 MySQL AB, 2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -87,3 +87,24 @@ enum options_client
|
|||||||
OPT_INIT_COMMAND,
|
OPT_INIT_COMMAND,
|
||||||
OPT_MAX_CLIENT_OPTION
|
OPT_MAX_CLIENT_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
First mysql version supporting the information schema.
|
||||||
|
*/
|
||||||
|
#define FIRST_INFORMATION_SCHEMA_VERSION 50003
|
||||||
|
|
||||||
|
/**
|
||||||
|
Name of the information schema database.
|
||||||
|
*/
|
||||||
|
#define INFORMATION_SCHEMA_DB_NAME "information_schema"
|
||||||
|
|
||||||
|
/**
|
||||||
|
First mysql version supporting the performance schema.
|
||||||
|
*/
|
||||||
|
#define FIRST_PERFORMANCE_SCHEMA_VERSION 50600
|
||||||
|
|
||||||
|
/**
|
||||||
|
Name of the performance schema database.
|
||||||
|
*/
|
||||||
|
#define PERFORMANCE_SCHEMA_DB_NAME "performance_schema"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -644,8 +644,11 @@ static int process_one_db(char *database)
|
|||||||
|
|
||||||
static int use_db(char *database)
|
static int use_db(char *database)
|
||||||
{
|
{
|
||||||
if (mysql_get_server_version(sock) >= 50003 &&
|
if (mysql_get_server_version(sock) >= FIRST_INFORMATION_SCHEMA_VERSION &&
|
||||||
!my_strcasecmp(&my_charset_latin1, database, "information_schema"))
|
!my_strcasecmp(&my_charset_latin1, database, INFORMATION_SCHEMA_DB_NAME))
|
||||||
|
return 1;
|
||||||
|
if (mysql_get_server_version(sock) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
|
||||||
|
!my_strcasecmp(&my_charset_latin1, database, PERFORMANCE_SCHEMA_DB_NAME))
|
||||||
return 1;
|
return 1;
|
||||||
if (mysql_select_db(sock, database))
|
if (mysql_select_db(sock, database))
|
||||||
{
|
{
|
||||||
|
@ -3836,8 +3836,12 @@ static int dump_all_databases()
|
|||||||
return 1;
|
return 1;
|
||||||
while ((row= mysql_fetch_row(tableres)))
|
while ((row= mysql_fetch_row(tableres)))
|
||||||
{
|
{
|
||||||
if (mysql_get_server_version(mysql) >= 50003 &&
|
if (mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
|
||||||
!my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
|
!my_strcasecmp(&my_charset_latin1, row[0], INFORMATION_SCHEMA_DB_NAME))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mysql_get_server_version(mysql) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
|
||||||
|
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (dump_all_tables_in_db(row[0]))
|
if (dump_all_tables_in_db(row[0]))
|
||||||
@ -3854,8 +3858,12 @@ static int dump_all_databases()
|
|||||||
}
|
}
|
||||||
while ((row= mysql_fetch_row(tableres)))
|
while ((row= mysql_fetch_row(tableres)))
|
||||||
{
|
{
|
||||||
if (mysql_get_server_version(mysql) >= 50003 &&
|
if (mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
|
||||||
!my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
|
!my_strcasecmp(&my_charset_latin1, row[0], INFORMATION_SCHEMA_DB_NAME))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mysql_get_server_version(mysql) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
|
||||||
|
!my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (dump_all_views_in_db(row[0]))
|
if (dump_all_views_in_db(row[0]))
|
||||||
@ -4256,10 +4264,12 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
|
|||||||
}
|
}
|
||||||
end= pos;
|
end= pos;
|
||||||
|
|
||||||
/* Can't LOCK TABLES in INFORMATION_SCHEMA, so don't try. */
|
/* Can't LOCK TABLES in I_S / P_S, so don't try. */
|
||||||
if (lock_tables &&
|
if (lock_tables &&
|
||||||
!(mysql_get_server_version(mysql) >= 50003 &&
|
!(mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
|
||||||
!my_strcasecmp(&my_charset_latin1, db, "information_schema")))
|
!my_strcasecmp(&my_charset_latin1, db, INFORMATION_SCHEMA_DB_NAME)) &&
|
||||||
|
!(mysql_get_server_version(mysql) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&
|
||||||
|
!my_strcasecmp(&my_charset_latin1, db, PERFORMANCE_SCHEMA_DB_NAME)))
|
||||||
{
|
{
|
||||||
if (mysql_real_query(mysql, lock_tables_query.str,
|
if (mysql_real_query(mysql, lock_tables_query.str,
|
||||||
lock_tables_query.length-1))
|
lock_tables_query.length-1))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003 MySQL AB
|
/* Copyright (C) 2003 MySQL AB, 2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -70,7 +70,7 @@ typedef struct st_key_cache
|
|||||||
uchar HUGE_PTR *block_mem; /* memory for block buffers */
|
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_last; /* ptr to the last block of the LRU chain */
|
||||||
BLOCK_LINK *used_ins; /* ptr to the insertion block in 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 */
|
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
|
||||||
/*
|
/*
|
||||||
Waiting for a zero resize count. Using a queue for symmetry though
|
Waiting for a zero resize count. Using a queue for symmetry though
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -34,7 +34,7 @@ typedef struct st_bitmap
|
|||||||
acquiring the mutex
|
acquiring the mutex
|
||||||
*/
|
*/
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_mutex_t *mutex;
|
mysql_mutex_t *mutex;
|
||||||
#endif
|
#endif
|
||||||
} MY_BITMAP;
|
} MY_BITMAP;
|
||||||
|
|
||||||
|
@ -607,6 +607,8 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr;
|
|||||||
typedef ulong my_thread_id;
|
typedef ulong my_thread_id;
|
||||||
|
|
||||||
extern my_bool my_thread_global_init(void);
|
extern my_bool my_thread_global_init(void);
|
||||||
|
extern my_bool my_thread_basic_global_init(void);
|
||||||
|
extern void my_thread_basic_global_reinit(void);
|
||||||
extern void my_thread_global_end(void);
|
extern void my_thread_global_end(void);
|
||||||
extern my_bool my_thread_init(void);
|
extern my_bool my_thread_init(void);
|
||||||
extern void my_thread_end(void);
|
extern void my_thread_end(void);
|
||||||
@ -637,10 +639,10 @@ extern int pthread_dummy(int);
|
|||||||
struct st_my_thread_var
|
struct st_my_thread_var
|
||||||
{
|
{
|
||||||
int thr_errno;
|
int thr_errno;
|
||||||
pthread_cond_t suspend;
|
mysql_cond_t suspend;
|
||||||
pthread_mutex_t mutex;
|
mysql_mutex_t mutex;
|
||||||
pthread_mutex_t * volatile current_mutex;
|
mysql_mutex_t * volatile current_mutex;
|
||||||
pthread_cond_t * volatile current_cond;
|
mysql_cond_t * volatile current_cond;
|
||||||
pthread_t pthread_self;
|
pthread_t pthread_self;
|
||||||
my_thread_id id;
|
my_thread_id id;
|
||||||
int cmp_length;
|
int cmp_length;
|
||||||
@ -692,16 +694,16 @@ extern uint thd_lib_detected;
|
|||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
#ifndef thread_safe_increment
|
#ifndef thread_safe_increment
|
||||||
#define thread_safe_increment(V,L) \
|
#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) \
|
#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
|
#endif
|
||||||
|
|
||||||
#ifndef thread_safe_add
|
#ifndef thread_safe_add
|
||||||
#define thread_safe_add(V,C,L) \
|
#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) \
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ struct st_my_file_info
|
|||||||
#endif
|
#endif
|
||||||
enum file_type type;
|
enum file_type type;
|
||||||
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
||||||
pthread_mutex_t mutex;
|
mysql_mutex_t mutex;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ typedef struct st_my_tmpdir
|
|||||||
char **list;
|
char **list;
|
||||||
uint cur, max;
|
uint cur, max;
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_mutex_t mutex;
|
mysql_mutex_t mutex;
|
||||||
#endif
|
#endif
|
||||||
} MY_TMPDIR;
|
} MY_TMPDIR;
|
||||||
|
|
||||||
@ -374,9 +374,9 @@ typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
|
|||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
typedef struct st_io_cache_share
|
typedef struct st_io_cache_share
|
||||||
{
|
{
|
||||||
pthread_mutex_t mutex; /* To sync on reads into buffer. */
|
mysql_mutex_t mutex; /* To sync on reads into buffer. */
|
||||||
pthread_cond_t cond; /* To wait for signals. */
|
mysql_cond_t cond; /* To wait for signals. */
|
||||||
pthread_cond_t cond_writer; /* For a synchronized writer. */
|
mysql_cond_t cond_writer; /* For a synchronized writer. */
|
||||||
/* Offset in file corresponding to the first byte of buffer. */
|
/* Offset in file corresponding to the first byte of buffer. */
|
||||||
my_off_t pos_in_file;
|
my_off_t pos_in_file;
|
||||||
/* If a synchronized write cache is the source of the data. */
|
/* If a synchronized write cache is the source of the data. */
|
||||||
@ -437,7 +437,7 @@ typedef struct st_io_cache /* Used when cacheing files */
|
|||||||
The lock is for append buffer used in SEQ_READ_APPEND cache
|
The lock is for append buffer used in SEQ_READ_APPEND cache
|
||||||
need mutex copying from append buffer to read buffer.
|
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
|
The following is used when several threads are reading the
|
||||||
same file in parallel. They are synchronized on disk
|
same file in parallel. They are synchronized on disk
|
||||||
@ -691,6 +691,7 @@ extern const char **my_error_unregister(int first, int last);
|
|||||||
extern void my_message(uint my_err, const char *str,myf MyFlags);
|
extern void my_message(uint my_err, const char *str,myf MyFlags);
|
||||||
extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
|
extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
|
||||||
extern void my_message_curses(uint my_err, const char *str,myf MyFlags);
|
extern void my_message_curses(uint my_err, const char *str,myf MyFlags);
|
||||||
|
extern my_bool my_basic_init(void);
|
||||||
extern my_bool my_init(void);
|
extern my_bool my_init(void);
|
||||||
extern void my_end(int infoflag);
|
extern void my_end(int infoflag);
|
||||||
extern int my_redel(const char *from, const char *to, int MyFlags);
|
extern int my_redel(const char *from, const char *to, int MyFlags);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -115,10 +115,11 @@ typedef struct st_thr_lock_data {
|
|||||||
THR_LOCK_OWNER *owner;
|
THR_LOCK_OWNER *owner;
|
||||||
struct st_thr_lock_data *next,**prev;
|
struct st_thr_lock_data *next,**prev;
|
||||||
struct st_thr_lock *lock;
|
struct st_thr_lock *lock;
|
||||||
pthread_cond_t *cond;
|
mysql_cond_t *cond;
|
||||||
enum thr_lock_type type;
|
enum thr_lock_type type;
|
||||||
void *status_param; /* Param to status functions */
|
void *status_param; /* Param to status functions */
|
||||||
void *debug_print_param;
|
void *debug_print_param;
|
||||||
|
struct PSI_table *m_psi;
|
||||||
} THR_LOCK_DATA;
|
} THR_LOCK_DATA;
|
||||||
|
|
||||||
struct st_lock_list {
|
struct st_lock_list {
|
||||||
@ -127,7 +128,7 @@ struct st_lock_list {
|
|||||||
|
|
||||||
typedef struct st_thr_lock {
|
typedef struct st_thr_lock {
|
||||||
LIST list;
|
LIST list;
|
||||||
pthread_mutex_t mutex;
|
mysql_mutex_t mutex;
|
||||||
struct st_lock_list read_wait;
|
struct st_lock_list read_wait;
|
||||||
struct st_lock_list read;
|
struct st_lock_list read;
|
||||||
struct st_lock_list write_wait;
|
struct st_lock_list write_wait;
|
||||||
@ -144,7 +145,7 @@ typedef struct st_thr_lock {
|
|||||||
|
|
||||||
|
|
||||||
extern LIST *thr_lock_thread_list;
|
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 */
|
my_bool init_thr_lock(void); /* Must be called once/thread */
|
||||||
#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)
|
#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -339,10 +339,10 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
|
|||||||
!(buf= (uchar*) my_malloc(len,myflags)))
|
!(buf= (uchar*) my_malloc(len,myflags)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if ((fd=my_open(filename,O_RDONLY,myflags)) < 0)
|
if ((fd= mysql_file_open(key_file_charset, filename, O_RDONLY, myflags)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
tmp_len=my_read(fd, buf, len, myflags);
|
tmp_len= mysql_file_read(fd, buf, len, myflags);
|
||||||
my_close(fd,myflags);
|
mysql_file_close(fd, myflags);
|
||||||
if (tmp_len != len)
|
if (tmp_len != len)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ static my_bool init_available_charsets(myf myflags)
|
|||||||
To make things thread safe we are not allowing other threads to interfere
|
To make things thread safe we are not allowing other threads to interfere
|
||||||
while we may changing the cs_info_table
|
while we may changing the cs_info_table
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&THR_LOCK_charset);
|
mysql_mutex_lock(&THR_LOCK_charset);
|
||||||
if (!charset_initialized)
|
if (!charset_initialized)
|
||||||
{
|
{
|
||||||
bzero(&all_charsets,sizeof(all_charsets));
|
bzero(&all_charsets,sizeof(all_charsets));
|
||||||
@ -444,7 +444,7 @@ static my_bool init_available_charsets(myf myflags)
|
|||||||
error= my_read_charset_file(fname,myflags);
|
error= my_read_charset_file(fname,myflags);
|
||||||
charset_initialized=1;
|
charset_initialized=1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_charset);
|
mysql_mutex_unlock(&THR_LOCK_charset);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
|
|||||||
To make things thread safe we are not allowing other threads to interfere
|
To make things thread safe we are not allowing other threads to interfere
|
||||||
while we may changing the cs_info_table
|
while we may changing the cs_info_table
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&THR_LOCK_charset);
|
mysql_mutex_lock(&THR_LOCK_charset);
|
||||||
|
|
||||||
if (!(cs->state & (MY_CS_COMPILED|MY_CS_LOADED))) /* if CS is not in memory */
|
if (!(cs->state & (MY_CS_COMPILED|MY_CS_LOADED))) /* if CS is not in memory */
|
||||||
{
|
{
|
||||||
@ -529,7 +529,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
|
|||||||
else
|
else
|
||||||
cs= NULL;
|
cs= NULL;
|
||||||
|
|
||||||
pthread_mutex_unlock(&THR_LOCK_charset);
|
mysql_mutex_unlock(&THR_LOCK_charset);
|
||||||
}
|
}
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -683,7 +683,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
|
|||||||
static const char includedir_keyword[]= "includedir";
|
static const char includedir_keyword[]= "includedir";
|
||||||
static const char include_keyword[]= "include";
|
static const char include_keyword[]= "include";
|
||||||
const int max_recursion_level= 10;
|
const int max_recursion_level= 10;
|
||||||
FILE *fp;
|
MYSQL_FILE *fp;
|
||||||
uint line=0;
|
uint line=0;
|
||||||
my_bool found_group=0;
|
my_bool found_group=0;
|
||||||
uint i;
|
uint i;
|
||||||
@ -723,10 +723,10 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!(fp= my_fopen(name, O_RDONLY, MYF(0))))
|
if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
|
||||||
return 1; /* Ignore wrong files */
|
return 1; /* Ignore wrong files */
|
||||||
|
|
||||||
while (fgets(buff, sizeof(buff) - 1, fp))
|
while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
|
||||||
{
|
{
|
||||||
line++;
|
line++;
|
||||||
/* Ignore comment and empty lines */
|
/* Ignore comment and empty lines */
|
||||||
@ -916,11 +916,11 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my_fclose(fp,MYF(0));
|
mysql_file_fclose(fp, MYF(0));
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
my_fclose(fp,MYF(0));
|
mysql_file_fclose(fp, MYF(0));
|
||||||
return -1; /* Fatal error */
|
return -1; /* Fatal error */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -58,9 +58,9 @@ static void my_aiowait(my_aio_result *result);
|
|||||||
|
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
#define lock_append_buffer(info) \
|
#define lock_append_buffer(info) \
|
||||||
pthread_mutex_lock(&(info)->append_buffer_lock)
|
mysql_mutex_lock(&(info)->append_buffer_lock)
|
||||||
#define unlock_append_buffer(info) \
|
#define unlock_append_buffer(info) \
|
||||||
pthread_mutex_unlock(&(info)->append_buffer_lock)
|
mysql_mutex_unlock(&(info)->append_buffer_lock)
|
||||||
#else
|
#else
|
||||||
#define lock_append_buffer(info)
|
#define lock_append_buffer(info)
|
||||||
#define unlock_append_buffer(info)
|
#define unlock_append_buffer(info)
|
||||||
@ -265,7 +265,8 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
|
|||||||
info->append_read_pos = info->write_pos = info->write_buffer;
|
info->append_read_pos = info->write_pos = info->write_buffer;
|
||||||
info->write_end = info->write_buffer + info->buffer_length;
|
info->write_end = info->write_buffer + info->buffer_length;
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_mutex_init(&info->append_buffer_lock,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_IO_CACHE_append_buffer_lock,
|
||||||
|
&info->append_buffer_lock, MY_MUTEX_INIT_FAST);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if defined(SAFE_MUTEX) && defined(THREAD)
|
#if defined(SAFE_MUTEX) && defined(THREAD)
|
||||||
@ -639,9 +640,10 @@ void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
|
|||||||
DBUG_ASSERT(read_cache->type == READ_CACHE);
|
DBUG_ASSERT(read_cache->type == READ_CACHE);
|
||||||
DBUG_ASSERT(!write_cache || (write_cache->type == WRITE_CACHE));
|
DBUG_ASSERT(!write_cache || (write_cache->type == WRITE_CACHE));
|
||||||
|
|
||||||
pthread_mutex_init(&cshare->mutex, MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_IO_CACHE_SHARE_mutex,
|
||||||
pthread_cond_init(&cshare->cond, 0);
|
&cshare->mutex, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&cshare->cond_writer, 0);
|
mysql_cond_init(key_IO_CACHE_SHARE_cond, &cshare->cond, 0);
|
||||||
|
mysql_cond_init(key_IO_CACHE_SHARE_cond_writer, &cshare->cond_writer, 0);
|
||||||
|
|
||||||
cshare->running_threads= num_threads;
|
cshare->running_threads= num_threads;
|
||||||
cshare->total_threads= num_threads;
|
cshare->total_threads= num_threads;
|
||||||
@ -692,7 +694,7 @@ void remove_io_thread(IO_CACHE *cache)
|
|||||||
if (cache == cshare->source_cache)
|
if (cache == cshare->source_cache)
|
||||||
flush_io_cache(cache);
|
flush_io_cache(cache);
|
||||||
|
|
||||||
pthread_mutex_lock(&cshare->mutex);
|
mysql_mutex_lock(&cshare->mutex);
|
||||||
DBUG_PRINT("io_cache_share", ("%s: 0x%lx",
|
DBUG_PRINT("io_cache_share", ("%s: 0x%lx",
|
||||||
(cache == cshare->source_cache) ?
|
(cache == cshare->source_cache) ?
|
||||||
"writer" : "reader", (long) cache));
|
"writer" : "reader", (long) cache));
|
||||||
@ -715,18 +717,18 @@ void remove_io_thread(IO_CACHE *cache)
|
|||||||
if (!--cshare->running_threads)
|
if (!--cshare->running_threads)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("io_cache_share", ("the last running thread leaves, wake all"));
|
DBUG_PRINT("io_cache_share", ("the last running thread leaves, wake all"));
|
||||||
pthread_cond_signal(&cshare->cond_writer);
|
mysql_cond_signal(&cshare->cond_writer);
|
||||||
pthread_cond_broadcast(&cshare->cond);
|
mysql_cond_broadcast(&cshare->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&cshare->mutex);
|
mysql_mutex_unlock(&cshare->mutex);
|
||||||
|
|
||||||
if (!total)
|
if (!total)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("io_cache_share", ("last thread removed, destroy share"));
|
DBUG_PRINT("io_cache_share", ("last thread removed, destroy share"));
|
||||||
pthread_cond_destroy (&cshare->cond_writer);
|
mysql_cond_destroy (&cshare->cond_writer);
|
||||||
pthread_cond_destroy (&cshare->cond);
|
mysql_cond_destroy (&cshare->cond);
|
||||||
pthread_mutex_destroy(&cshare->mutex);
|
mysql_mutex_destroy(&cshare->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
@ -767,7 +769,7 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
|
|||||||
DBUG_ENTER("lock_io_cache");
|
DBUG_ENTER("lock_io_cache");
|
||||||
|
|
||||||
/* Enter the lock. */
|
/* Enter the lock. */
|
||||||
pthread_mutex_lock(&cshare->mutex);
|
mysql_mutex_lock(&cshare->mutex);
|
||||||
cshare->running_threads--;
|
cshare->running_threads--;
|
||||||
DBUG_PRINT("io_cache_share", ("%s: 0x%lx pos: %lu running: %u",
|
DBUG_PRINT("io_cache_share", ("%s: 0x%lx pos: %lu running: %u",
|
||||||
(cache == cshare->source_cache) ?
|
(cache == cshare->source_cache) ?
|
||||||
@ -784,7 +786,7 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
|
|||||||
while (cshare->running_threads)
|
while (cshare->running_threads)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("io_cache_share", ("writer waits in lock"));
|
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"));
|
DBUG_PRINT("io_cache_share", ("writer awoke, going to copy"));
|
||||||
|
|
||||||
@ -796,7 +798,7 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
|
|||||||
if (!cshare->running_threads)
|
if (!cshare->running_threads)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("io_cache_share", ("waking writer"));
|
DBUG_PRINT("io_cache_share", ("waking writer"));
|
||||||
pthread_cond_signal(&cshare->cond_writer);
|
mysql_cond_signal(&cshare->cond_writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -808,7 +810,7 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
|
|||||||
cshare->source_cache)
|
cshare->source_cache)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("io_cache_share", ("reader waits in lock"));
|
DBUG_PRINT("io_cache_share", ("reader waits in lock"));
|
||||||
pthread_cond_wait(&cshare->cond, &cshare->mutex);
|
mysql_cond_wait(&cshare->cond, &cshare->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -850,7 +852,7 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
|
|||||||
cshare->running_threads)
|
cshare->running_threads)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("io_cache_share", ("reader waits in lock"));
|
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. */
|
/* If the block is not yet read, continue with a locked cache and read. */
|
||||||
@ -872,7 +874,7 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
|
|||||||
Leave the lock. Do not call unlock_io_cache() later. The thread that
|
Leave the lock. Do not call unlock_io_cache() later. The thread that
|
||||||
filled the buffer did this and marked all threads as running.
|
filled the buffer did this and marked all threads as running.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&cshare->mutex);
|
mysql_mutex_unlock(&cshare->mutex);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,8 +917,8 @@ static void unlock_io_cache(IO_CACHE *cache)
|
|||||||
cshare->total_threads));
|
cshare->total_threads));
|
||||||
|
|
||||||
cshare->running_threads= cshare->total_threads;
|
cshare->running_threads= cshare->total_threads;
|
||||||
pthread_cond_broadcast(&cshare->cond);
|
mysql_cond_broadcast(&cshare->cond);
|
||||||
pthread_mutex_unlock(&cshare->mutex);
|
mysql_mutex_unlock(&cshare->mutex);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1837,7 +1839,7 @@ int end_io_cache(IO_CACHE *info)
|
|||||||
/* Destroy allocated mutex */
|
/* Destroy allocated mutex */
|
||||||
info->type= TYPE_NOT_SET;
|
info->type= TYPE_NOT_SET;
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_mutex_destroy(&info->append_buffer_lock);
|
mysql_mutex_destroy(&info->append_buffer_lock);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -82,7 +82,7 @@ my_off_t my_b_append_tell(IO_CACHE* info)
|
|||||||
answer to the question.
|
answer to the question.
|
||||||
*/
|
*/
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_mutex_lock(&info->append_buffer_lock);
|
mysql_mutex_lock(&info->append_buffer_lock);
|
||||||
#endif
|
#endif
|
||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
/*
|
/*
|
||||||
@ -104,7 +104,7 @@ my_off_t my_b_append_tell(IO_CACHE* info)
|
|||||||
#endif
|
#endif
|
||||||
res = info->end_of_file + (info->write_pos-info->append_read_pos);
|
res = info->end_of_file + (info->write_pos-info->append_read_pos);
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_mutex_unlock(&info->append_buffer_lock);
|
mysql_mutex_unlock(&info->append_buffer_lock);
|
||||||
#endif
|
#endif
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -59,13 +59,13 @@
|
|||||||
time only.
|
time only.
|
||||||
|
|
||||||
Before starting to wait on its condition variable with
|
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
|
with link_into_queue() (double linked with '*next' + '**prev') or
|
||||||
wait_on_queue() (single linked with '*next').
|
wait_on_queue() (single linked with '*next').
|
||||||
|
|
||||||
Another thread, when releasing a resource, looks up the waiting thread
|
Another thread, when releasing a resource, looks up the waiting thread
|
||||||
in the related wait queue. It sends a signal with
|
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
|
NOTE: Depending on the particular wait situation, either the sending
|
||||||
thread removes the waiting thread from the wait queue with
|
thread removes the waiting thread from the wait queue with
|
||||||
@ -128,8 +128,8 @@
|
|||||||
accessing it;
|
accessing it;
|
||||||
to set this number equal to <N> add
|
to set this number equal to <N> add
|
||||||
#define MAX_THREADS <N>
|
#define MAX_THREADS <N>
|
||||||
- to substitute calls of pthread_cond_wait for calls of
|
- to substitute calls of mysql_cond_wait for calls of
|
||||||
pthread_cond_timedwait (wait with timeout set up);
|
mysql_cond_timedwait (wait with timeout set up);
|
||||||
this setting should be used only when you want to trap a deadlock
|
this setting should be used only when you want to trap a deadlock
|
||||||
situation, which theoretically should not happen;
|
situation, which theoretically should not happen;
|
||||||
to set timeout equal to <T> seconds add
|
to set timeout equal to <T> seconds add
|
||||||
@ -160,7 +160,7 @@
|
|||||||
#define COND_FOR_SAVED 1
|
#define COND_FOR_SAVED 1
|
||||||
#define COND_FOR_READERS 2
|
#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 */
|
/* descriptor of the page in the key cache block buffer */
|
||||||
struct st_keycache_page
|
struct st_keycache_page
|
||||||
@ -227,7 +227,7 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cache_var;
|
|||||||
static int flush_all_key_blocks(KEY_CACHE *keycache);
|
static int flush_all_key_blocks(KEY_CACHE *keycache);
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
static void wait_on_queue(KEYCACHE_WQUEUE *wqueue,
|
static void wait_on_queue(KEYCACHE_WQUEUE *wqueue,
|
||||||
pthread_mutex_t *mutex);
|
mysql_mutex_t *mutex);
|
||||||
static void release_whole_queue(KEYCACHE_WQUEUE *wqueue);
|
static void release_whole_queue(KEYCACHE_WQUEUE *wqueue);
|
||||||
#else
|
#else
|
||||||
#define wait_on_queue(wqueue, mutex) do {} while (0)
|
#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)))
|
((uint) (((char*)(h)-(char *) keycache->hash_link_root)/sizeof(HASH_LINK)))
|
||||||
|
|
||||||
#if (defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)) || defined(KEYCACHE_DEBUG)
|
#if (defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)) || defined(KEYCACHE_DEBUG)
|
||||||
static int keycache_pthread_cond_wait(pthread_cond_t *cond,
|
static int keycache_pthread_cond_wait(mysql_cond_t *cond,
|
||||||
pthread_mutex_t *mutex);
|
mysql_mutex_t *mutex);
|
||||||
#else
|
#else
|
||||||
#define keycache_pthread_cond_wait pthread_cond_wait
|
#define keycache_pthread_cond_wait(C, M) mysql_cond_wait(C, M)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(KEYCACHE_DEBUG)
|
#if defined(KEYCACHE_DEBUG)
|
||||||
static int keycache_pthread_mutex_lock(pthread_mutex_t *mutex);
|
static int keycache_pthread_mutex_lock(mysql_mutex_t *mutex);
|
||||||
static void keycache_pthread_mutex_unlock(pthread_mutex_t *mutex);
|
static void keycache_pthread_mutex_unlock(mysql_mutex_t *mutex);
|
||||||
static int keycache_pthread_cond_signal(pthread_cond_t *cond);
|
static int keycache_pthread_cond_signal(mysql_cond_t *cond);
|
||||||
#else
|
#else
|
||||||
#define keycache_pthread_mutex_lock pthread_mutex_lock
|
#define keycache_pthread_mutex_lock(M) mysql_mutex_lock(M)
|
||||||
#define keycache_pthread_mutex_unlock pthread_mutex_unlock
|
#define keycache_pthread_mutex_unlock(M) mysql_mutex_unlock(M)
|
||||||
#define keycache_pthread_cond_signal pthread_cond_signal
|
#define keycache_pthread_cond_signal(C) mysql_cond_signal(C)
|
||||||
#endif /* defined(KEYCACHE_DEBUG) */
|
#endif /* defined(KEYCACHE_DEBUG) */
|
||||||
|
|
||||||
#if !defined(DBUG_OFF)
|
#if !defined(DBUG_OFF)
|
||||||
@ -403,7 +403,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
|
|||||||
keycache->cnt_for_resize_op= 0;
|
keycache->cnt_for_resize_op= 0;
|
||||||
keycache->waiting_for_resize_cnt.last_thread= NULL;
|
keycache->waiting_for_resize_cnt.last_thread= NULL;
|
||||||
keycache->in_init= 0;
|
keycache->in_init= 0;
|
||||||
pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_KEY_CACHE_cache_lock,
|
||||||
|
&keycache->cache_lock, MY_MUTEX_INIT_FAST);
|
||||||
keycache->resize_queue.last_thread= NULL;
|
keycache->resize_queue.last_thread= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +774,7 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
|
|||||||
|
|
||||||
if (cleanup)
|
if (cleanup)
|
||||||
{
|
{
|
||||||
pthread_mutex_destroy(&keycache->cache_lock);
|
mysql_mutex_destroy(&keycache->cache_lock);
|
||||||
keycache->key_cache_inited= keycache->can_be_used= 0;
|
keycache->key_cache_inited= keycache->can_be_used= 0;
|
||||||
KEYCACHE_DEBUG_CLOSE;
|
KEYCACHE_DEBUG_CLOSE;
|
||||||
}
|
}
|
||||||
@ -888,7 +889,7 @@ static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void wait_on_queue(KEYCACHE_WQUEUE *wqueue,
|
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 *last;
|
||||||
struct st_my_thread_var *thread= my_thread_var;
|
struct st_my_thread_var *thread= my_thread_var;
|
||||||
@ -4166,7 +4167,7 @@ static int flush_all_key_blocks(KEY_CACHE *keycache)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
safe_mutex_assert_owner(&keycache->cache_lock);
|
mysql_mutex_assert_owner(&keycache->cache_lock);
|
||||||
total_found= 0;
|
total_found= 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4407,8 +4408,8 @@ static void keycache_dump(KEY_CACHE *keycache)
|
|||||||
#if defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)
|
#if defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)
|
||||||
|
|
||||||
|
|
||||||
static int keycache_pthread_cond_wait(pthread_cond_t *cond,
|
static int keycache_pthread_cond_wait(mysql_cond_t *cond,
|
||||||
pthread_mutex_t *mutex)
|
mysql_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct timeval now; /* time when we started waiting */
|
struct timeval now; /* time when we started waiting */
|
||||||
@ -4435,7 +4436,7 @@ static int keycache_pthread_cond_wait(pthread_cond_t *cond,
|
|||||||
fprintf(keycache_debug_log, "waiting...\n");
|
fprintf(keycache_debug_log, "waiting...\n");
|
||||||
fflush(keycache_debug_log);
|
fflush(keycache_debug_log);
|
||||||
#endif
|
#endif
|
||||||
rc= pthread_cond_timedwait(cond, mutex, &timeout);
|
rc= mysql_cond_timedwait(cond, mutex, &timeout);
|
||||||
KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
|
KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
|
||||||
if (rc == ETIMEDOUT || rc == ETIME)
|
if (rc == ETIMEDOUT || rc == ETIME)
|
||||||
{
|
{
|
||||||
@ -4456,12 +4457,12 @@ static int keycache_pthread_cond_wait(pthread_cond_t *cond,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if defined(KEYCACHE_DEBUG)
|
#if defined(KEYCACHE_DEBUG)
|
||||||
static int keycache_pthread_cond_wait(pthread_cond_t *cond,
|
static int keycache_pthread_cond_wait(mysql_cond_t *cond,
|
||||||
pthread_mutex_t *mutex)
|
mysql_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
KEYCACHE_THREAD_TRACE_END("started waiting");
|
KEYCACHE_THREAD_TRACE_END("started waiting");
|
||||||
rc= pthread_cond_wait(cond, mutex);
|
rc= mysql_cond_wait(cond, mutex);
|
||||||
KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
|
KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -4471,27 +4472,27 @@ static int keycache_pthread_cond_wait(pthread_cond_t *cond,
|
|||||||
#if defined(KEYCACHE_DEBUG)
|
#if defined(KEYCACHE_DEBUG)
|
||||||
|
|
||||||
|
|
||||||
static int keycache_pthread_mutex_lock(pthread_mutex_t *mutex)
|
static int keycache_pthread_mutex_lock(mysql_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
rc= pthread_mutex_lock(mutex);
|
rc= mysql_mutex_lock(mutex);
|
||||||
KEYCACHE_THREAD_TRACE_BEGIN("");
|
KEYCACHE_THREAD_TRACE_BEGIN("");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void keycache_pthread_mutex_unlock(pthread_mutex_t *mutex)
|
static void keycache_pthread_mutex_unlock(mysql_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
KEYCACHE_THREAD_TRACE_END("");
|
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_pthread_cond_signal(mysql_cond_t *cond)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
KEYCACHE_THREAD_TRACE("signal");
|
KEYCACHE_THREAD_TRACE("signal");
|
||||||
rc= pthread_cond_signal(cond);
|
rc= mysql_cond_signal(cond);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -29,7 +29,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
|
|||||||
DBUG_ENTER("init_tmpdir");
|
DBUG_ENTER("init_tmpdir");
|
||||||
DBUG_PRINT("enter", ("pathlist: %s", pathlist ? pathlist : "NULL"));
|
DBUG_PRINT("enter", ("pathlist: %s", pathlist ? pathlist : "NULL"));
|
||||||
|
|
||||||
pthread_mutex_init(&tmpdir->mutex, MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_TMPDIR_mutex, &tmpdir->mutex, MY_MUTEX_INIT_FAST);
|
||||||
if (my_init_dynamic_array(&tmpdir->full_list, sizeof(char*), 1, 5))
|
if (my_init_dynamic_array(&tmpdir->full_list, sizeof(char*), 1, 5))
|
||||||
goto err;
|
goto err;
|
||||||
if (!pathlist || !pathlist[0])
|
if (!pathlist || !pathlist[0])
|
||||||
@ -65,7 +65,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
delete_dynamic(&tmpdir->full_list); /* Safe to free */
|
delete_dynamic(&tmpdir->full_list); /* Safe to free */
|
||||||
pthread_mutex_destroy(&tmpdir->mutex);
|
mysql_mutex_destroy(&tmpdir->mutex);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +75,10 @@ char *my_tmpdir(MY_TMPDIR *tmpdir)
|
|||||||
char *dir;
|
char *dir;
|
||||||
if (!tmpdir->max)
|
if (!tmpdir->max)
|
||||||
return tmpdir->list[0];
|
return tmpdir->list[0];
|
||||||
pthread_mutex_lock(&tmpdir->mutex);
|
mysql_mutex_lock(&tmpdir->mutex);
|
||||||
dir=tmpdir->list[tmpdir->cur];
|
dir=tmpdir->list[tmpdir->cur];
|
||||||
tmpdir->cur= (tmpdir->cur == tmpdir->max) ? 0 : tmpdir->cur+1;
|
tmpdir->cur= (tmpdir->cur == tmpdir->max) ? 0 : tmpdir->cur+1;
|
||||||
pthread_mutex_unlock(&tmpdir->mutex);
|
mysql_mutex_unlock(&tmpdir->mutex);
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +90,6 @@ void free_tmpdir(MY_TMPDIR *tmpdir)
|
|||||||
for (i=0; i<=tmpdir->max; i++)
|
for (i=0; i<=tmpdir->max; i++)
|
||||||
my_free(tmpdir->list[i], MYF(0));
|
my_free(tmpdir->list[i], MYF(0));
|
||||||
delete_dynamic(&tmpdir->full_list);
|
delete_dynamic(&tmpdir->full_list);
|
||||||
pthread_mutex_destroy(&tmpdir->mutex);
|
mysql_mutex_destroy(&tmpdir->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -87,7 +87,7 @@ static inline void bitmap_lock(MY_BITMAP *map __attribute__((unused)))
|
|||||||
{
|
{
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
if (map->mutex)
|
if (map->mutex)
|
||||||
pthread_mutex_lock(map->mutex);
|
mysql_mutex_lock(map->mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ static inline void bitmap_unlock(MY_BITMAP *map __attribute__((unused)))
|
|||||||
{
|
{
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
if (map->mutex)
|
if (map->mutex)
|
||||||
pthread_mutex_unlock(map->mutex);
|
mysql_mutex_unlock(map->mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
|
|||||||
if (thread_safe)
|
if (thread_safe)
|
||||||
{
|
{
|
||||||
size_in_bytes= ALIGN_SIZE(size_in_bytes);
|
size_in_bytes= ALIGN_SIZE(size_in_bytes);
|
||||||
extra= sizeof(pthread_mutex_t);
|
extra= sizeof(mysql_mutex_t);
|
||||||
}
|
}
|
||||||
map->mutex= 0;
|
map->mutex= 0;
|
||||||
#endif
|
#endif
|
||||||
@ -121,8 +121,8 @@ my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
|
|||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
if (thread_safe)
|
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);
|
mysql_mutex_init(key_BITMAP_mutex, map->mutex, MY_MUTEX_INIT_FAST);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ void bitmap_free(MY_BITMAP *map)
|
|||||||
{
|
{
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
if (map->mutex)
|
if (map->mutex)
|
||||||
pthread_mutex_destroy(map->mutex);
|
mysql_mutex_destroy(map->mutex);
|
||||||
#endif
|
#endif
|
||||||
my_free((char*) map->bitmap, MYF(0));
|
my_free((char*) map->bitmap, MYF(0));
|
||||||
map->bitmap=0;
|
map->bitmap=0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -63,18 +63,18 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
|
|||||||
thread_safe_increment(my_stream_opened,&THR_LOCK_open);
|
thread_safe_increment(my_stream_opened,&THR_LOCK_open);
|
||||||
DBUG_RETURN(fd); /* safeguard */
|
DBUG_RETURN(fd); /* safeguard */
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
if ((my_file_info[filedesc].name= (char*)
|
if ((my_file_info[filedesc].name= (char*)
|
||||||
my_strdup(filename,MyFlags)))
|
my_strdup(filename,MyFlags)))
|
||||||
{
|
{
|
||||||
my_stream_opened++;
|
my_stream_opened++;
|
||||||
my_file_total_opened++;
|
my_file_total_opened++;
|
||||||
my_file_info[filedesc].type= STREAM_BY_FOPEN;
|
my_file_info[filedesc].type= STREAM_BY_FOPEN;
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
|
DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
|
||||||
DBUG_RETURN(fd);
|
DBUG_RETURN(fd);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
(void) my_fclose(fd,MyFlags);
|
(void) my_fclose(fd,MyFlags);
|
||||||
my_errno=ENOMEM;
|
my_errno=ENOMEM;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ int my_fclose(FILE *fd, myf MyFlags)
|
|||||||
DBUG_ENTER("my_fclose");
|
DBUG_ENTER("my_fclose");
|
||||||
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) fd, MyFlags));
|
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) fd, MyFlags));
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
file= my_fileno(fd);
|
file= my_fileno(fd);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
err= fclose(fd);
|
err= fclose(fd);
|
||||||
@ -119,7 +119,7 @@ int my_fclose(FILE *fd, myf MyFlags)
|
|||||||
my_file_info[file].type = UNOPEN;
|
my_file_info[file].type = UNOPEN;
|
||||||
my_free(my_file_info[file].name, MYF(MY_ALLOW_ZERO_PTR));
|
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);
|
DBUG_RETURN(err);
|
||||||
} /* my_fclose */
|
} /* my_fclose */
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
my_stream_opened++;
|
my_stream_opened++;
|
||||||
if ((uint) Filedes < (uint) my_file_limit)
|
if ((uint) Filedes < (uint) my_file_limit)
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
|
|||||||
}
|
}
|
||||||
my_file_info[Filedes].type = STREAM_BY_FDOPEN;
|
my_file_info[Filedes].type = STREAM_BY_FDOPEN;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
|
DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2002, 2004 MySQL AB
|
/* Copyright (C) 2002, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public
|
modify it under the terms of the GNU Library General Public
|
||||||
@ -79,7 +79,7 @@ struct hostent *my_gethostbyname_r(const char *name,
|
|||||||
#else /* !HAVE_GETHOSTBYNAME_R */
|
#else /* !HAVE_GETHOSTBYNAME_R */
|
||||||
|
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
extern pthread_mutex_t LOCK_gethostbyname_r;
|
extern mysql_mutex_t LOCK_gethostbyname_r;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -96,7 +96,7 @@ struct hostent *my_gethostbyname_r(const char *name,
|
|||||||
int buflen, int *h_errnop)
|
int buflen, int *h_errnop)
|
||||||
{
|
{
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
pthread_mutex_lock(&LOCK_gethostbyname_r);
|
mysql_mutex_lock(&LOCK_gethostbyname_r);
|
||||||
hp= gethostbyname(name);
|
hp= gethostbyname(name);
|
||||||
*h_errnop= h_errno;
|
*h_errnop= h_errno;
|
||||||
return hp;
|
return hp;
|
||||||
@ -104,7 +104,7 @@ struct hostent *my_gethostbyname_r(const char *name,
|
|||||||
|
|
||||||
void my_gethostbyname_r_free()
|
void my_gethostbyname_r_free()
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_gethostbyname_r);
|
mysql_mutex_unlock(&LOCK_gethostbyname_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !HAVE_GETHOSTBYNAME_R */
|
#endif /* !HAVE_GETHOSTBYNAME_R */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2002-2006 MySQL AB
|
/* Copyright (C) 2002-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -91,16 +91,6 @@ static void default_reporter(enum loglevel level,
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
function: handle_options
|
|
||||||
|
|
||||||
Sort options; put options first, until special end of options (--), or
|
|
||||||
until end of argv. Parse options; check that the given option matches with
|
|
||||||
one of the options in struct 'my_option', return error in case of ambiguous
|
|
||||||
or unknown option. Check that option was given an argument if it requires
|
|
||||||
one. Call function 'get_one_option()' once for each option.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *, int *);
|
static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *, int *);
|
||||||
|
|
||||||
void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint,
|
void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint,
|
||||||
@ -109,6 +99,22 @@ void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint,
|
|||||||
getopt_get_addr= func_addr;
|
getopt_get_addr= func_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handle command line options.
|
||||||
|
Sort options.
|
||||||
|
Put options first, until special end of options (--),
|
||||||
|
or until the end of argv. Parse options, check that the given option
|
||||||
|
matches with one of the options in struct 'my_option'.
|
||||||
|
Check that option was given an argument if it requires one
|
||||||
|
Call the optional 'get_one_option()' function once for each option.
|
||||||
|
@param [in, out] argc command line options (count)
|
||||||
|
@param [in, out] argv command line options (values)
|
||||||
|
@param [in] longopts descriptor of all valid options
|
||||||
|
@param [in] get_one_option optional callback function to process each option,
|
||||||
|
can be NULL.
|
||||||
|
@return error in case of ambiguous or unknown options,
|
||||||
|
0 on success.
|
||||||
|
*/
|
||||||
int handle_options(int *argc, char ***argv,
|
int handle_options(int *argc, char ***argv,
|
||||||
const struct my_option *longopts,
|
const struct my_option *longopts,
|
||||||
my_get_one_option get_one_option)
|
my_get_one_option get_one_option)
|
||||||
@ -427,9 +433,9 @@ invalid value '%s'",
|
|||||||
my_progname, optp->name, optend);
|
my_progname, optp->name, optend);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (get_one_option(optp->id, optp,
|
if (get_one_option && get_one_option(optp->id, optp,
|
||||||
*((my_bool*) value) ?
|
*((my_bool*) value) ?
|
||||||
(char*) "1" : disabled_my_option))
|
(char*) "1" : disabled_my_option))
|
||||||
return EXIT_ARGUMENT_INVALID;
|
return EXIT_ARGUMENT_INVALID;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -493,7 +499,7 @@ invalid value '%s'",
|
|||||||
optp->arg_type == NO_ARG)
|
optp->arg_type == NO_ARG)
|
||||||
{
|
{
|
||||||
*((my_bool*) optp->value)= (my_bool) 1;
|
*((my_bool*) optp->value)= (my_bool) 1;
|
||||||
if (get_one_option(optp->id, optp, argument))
|
if (get_one_option && get_one_option(optp->id, optp, argument))
|
||||||
return EXIT_UNSPECIFIED_ERROR;
|
return EXIT_UNSPECIFIED_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -513,7 +519,7 @@ invalid value '%s'",
|
|||||||
{
|
{
|
||||||
if (optp->var_type == GET_BOOL)
|
if (optp->var_type == GET_BOOL)
|
||||||
*((my_bool*) optp->value)= (my_bool) 1;
|
*((my_bool*) optp->value)= (my_bool) 1;
|
||||||
if (get_one_option(optp->id, optp, argument))
|
if (get_one_option && get_one_option(optp->id, optp, argument))
|
||||||
return EXIT_UNSPECIFIED_ERROR;
|
return EXIT_UNSPECIFIED_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -539,7 +545,7 @@ invalid value '%s'",
|
|||||||
my_progname, argument, optp->name);
|
my_progname, argument, optp->name);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (get_one_option(optp->id, optp, argument))
|
if (get_one_option && get_one_option(optp->id, optp, argument))
|
||||||
return EXIT_UNSPECIFIED_ERROR;
|
return EXIT_UNSPECIFIED_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -563,7 +569,7 @@ invalid value '%s'",
|
|||||||
my_progname, argument, optp->name);
|
my_progname, argument, optp->name);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (get_one_option(optp->id, optp, argument))
|
if (get_one_option && get_one_option(optp->id, optp, argument))
|
||||||
return EXIT_UNSPECIFIED_ERROR;
|
return EXIT_UNSPECIFIED_ERROR;
|
||||||
|
|
||||||
(*argc)--; /* option handled (short or long), decrease argument count */
|
(*argc)--; /* option handled (short or long), decrease argument count */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004 MySQL AB
|
/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -168,7 +168,7 @@ ulonglong my_micro_time_and_time(time_t *time_arg)
|
|||||||
static time_t cur_time= 0;
|
static time_t cur_time= 0;
|
||||||
hrtime_t cur_gethrtime;
|
hrtime_t cur_gethrtime;
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_time);
|
mysql_mutex_lock(&THR_LOCK_time);
|
||||||
cur_gethrtime= gethrtime();
|
cur_gethrtime= gethrtime();
|
||||||
if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)
|
if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)
|
||||||
{
|
{
|
||||||
@ -176,7 +176,7 @@ ulonglong my_micro_time_and_time(time_t *time_arg)
|
|||||||
prev_gethrtime= cur_gethrtime;
|
prev_gethrtime= cur_gethrtime;
|
||||||
}
|
}
|
||||||
*time_arg= cur_time;
|
*time_arg= cur_time;
|
||||||
pthread_mutex_unlock(&THR_LOCK_time);
|
mysql_mutex_unlock(&THR_LOCK_time);
|
||||||
return cur_gethrtime/1000;
|
return cur_gethrtime/1000;
|
||||||
#else
|
#else
|
||||||
ulonglong newtime;
|
ulonglong newtime;
|
||||||
|
194
mysys/my_init.c
194
mysys/my_init.c
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -43,6 +43,8 @@ static void netware_init();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
my_bool my_init_done= 0;
|
my_bool my_init_done= 0;
|
||||||
|
/** True if @c my_basic_init() has been called. */
|
||||||
|
my_bool my_basic_init_done= 0;
|
||||||
uint mysys_usage_id= 0; /* Incremented for each my_init() */
|
uint mysys_usage_id= 0; /* Incremented for each my_init() */
|
||||||
ulong my_thread_stack_size= 65536;
|
ulong my_thread_stack_size= 65536;
|
||||||
|
|
||||||
@ -57,6 +59,57 @@ static ulong atoi_octal(const char *str)
|
|||||||
return (ulong) tmp;
|
return (ulong) tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MYSQL_FILE *mysql_stdin= NULL;
|
||||||
|
static MYSQL_FILE instrumented_stdin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a limited initialisation of mysys.
|
||||||
|
This initialisation is sufficient to:
|
||||||
|
- allocate memory,
|
||||||
|
- read configuration files,
|
||||||
|
- parse command lines arguments.
|
||||||
|
To complete the mysys initialisation,
|
||||||
|
call my_init().
|
||||||
|
@return 0 on success
|
||||||
|
*/
|
||||||
|
my_bool my_basic_init(void)
|
||||||
|
{
|
||||||
|
if (my_basic_init_done)
|
||||||
|
return 0;
|
||||||
|
my_basic_init_done= 1;
|
||||||
|
|
||||||
|
mysys_usage_id++;
|
||||||
|
my_umask= 0660; /* Default umask for new files */
|
||||||
|
my_umask_dir= 0700; /* Default umask for new directories */
|
||||||
|
|
||||||
|
init_glob_errs();
|
||||||
|
|
||||||
|
instrumented_stdin.m_file= stdin;
|
||||||
|
instrumented_stdin.m_psi= NULL; /* not yet instrumented */
|
||||||
|
mysql_stdin= & instrumented_stdin;
|
||||||
|
|
||||||
|
#if defined(THREAD)
|
||||||
|
if (my_thread_global_init())
|
||||||
|
return 1;
|
||||||
|
# if defined(SAFE_MUTEX)
|
||||||
|
safe_mutex_global_init(); /* Must be called early */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
|
||||||
|
fastmutex_global_init(); /* Must be called early */
|
||||||
|
#endif
|
||||||
|
netware_init();
|
||||||
|
#ifdef THREAD
|
||||||
|
#if defined(HAVE_PTHREAD_INIT)
|
||||||
|
pthread_init(); /* Must be called before DBUG_ENTER */
|
||||||
|
#endif
|
||||||
|
if (my_thread_basic_global_init())
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Init my_sys functions and my_sys variabels
|
Init my_sys functions and my_sys variabels
|
||||||
@ -74,26 +127,14 @@ my_bool my_init(void)
|
|||||||
char * str;
|
char * str;
|
||||||
if (my_init_done)
|
if (my_init_done)
|
||||||
return 0;
|
return 0;
|
||||||
my_init_done=1;
|
my_init_done= 1;
|
||||||
mysys_usage_id++;
|
|
||||||
my_umask= 0660; /* Default umask for new files */
|
if (my_basic_init())
|
||||||
my_umask_dir= 0700; /* Default umask for new directories */
|
return 1;
|
||||||
init_glob_errs();
|
|
||||||
#if defined(THREAD)
|
#ifdef THREAD
|
||||||
if (my_thread_global_init())
|
if (my_thread_global_init())
|
||||||
return 1;
|
return 1;
|
||||||
# if defined(SAFE_MUTEX)
|
|
||||||
safe_mutex_global_init(); /* Must be called early */
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
|
|
||||||
fastmutex_global_init(); /* Must be called early */
|
|
||||||
#endif
|
|
||||||
netware_init();
|
|
||||||
#ifdef THREAD
|
|
||||||
#if defined(HAVE_PTHREAD_INIT)
|
|
||||||
pthread_init(); /* Must be called before DBUG_ENTER */
|
|
||||||
#endif
|
|
||||||
#if !defined( __WIN__) && !defined(__NETWARE__)
|
#if !defined( __WIN__) && !defined(__NETWARE__)
|
||||||
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
|
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
|
||||||
#endif
|
#endif
|
||||||
@ -239,6 +280,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
|
|||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif /* __WIN__ */
|
#endif /* __WIN__ */
|
||||||
my_init_done=0;
|
my_init_done=0;
|
||||||
|
my_basic_init_done= 0;
|
||||||
} /* my_end */
|
} /* my_end */
|
||||||
|
|
||||||
|
|
||||||
@ -538,3 +580,117 @@ static void netware_init()
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
#endif /* __NETWARE__ */
|
#endif /* __NETWARE__ */
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
|
||||||
|
#if !defined(HAVE_PREAD) && !defined(_WIN32)
|
||||||
|
PSI_mutex_key key_my_file_info_mutex;
|
||||||
|
#endif /* !defined(HAVE_PREAD) && !defined(_WIN32) */
|
||||||
|
|
||||||
|
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||||
|
PSI_mutex_key key_LOCK_localtime_r;
|
||||||
|
#endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
|
||||||
|
|
||||||
|
#ifndef HAVE_GETHOSTBYNAME_R
|
||||||
|
PSI_mutex_key key_LOCK_gethostbyname_r;
|
||||||
|
#endif /* HAVE_GETHOSTBYNAME_R */
|
||||||
|
|
||||||
|
PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
|
||||||
|
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
|
||||||
|
key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
|
||||||
|
key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
|
||||||
|
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
|
||||||
|
key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
|
||||||
|
key_TMPDIR_mutex;
|
||||||
|
|
||||||
|
static PSI_mutex_info all_mysys_mutexes[]=
|
||||||
|
{
|
||||||
|
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
||||||
|
{ &key_my_file_info_mutex, "st_my_file_info:mutex", 0},
|
||||||
|
#endif /* !defined(HAVE_PREAD) && !defined(_WIN32) */
|
||||||
|
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||||
|
{ &key_LOCK_localtime_r, "LOCK_localtime_r", PSI_FLAG_GLOBAL},
|
||||||
|
#endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
|
||||||
|
#ifndef HAVE_GETHOSTBYNAME_R
|
||||||
|
{ &key_LOCK_gethostbyname_r, "LOCK_gethostbyname_r", PSI_FLAG_GLOBAL},
|
||||||
|
#endif /* HAVE_GETHOSTBYNAME_R */
|
||||||
|
{ &key_BITMAP_mutex, "BITMAP::mutex", 0},
|
||||||
|
{ &key_IO_CACHE_append_buffer_lock, "IO_CACHE::append_buffer_lock", 0},
|
||||||
|
{ &key_IO_CACHE_SHARE_mutex, "IO_CACHE::SHARE_mutex", 0},
|
||||||
|
{ &key_KEY_CACHE_cache_lock, "KEY_CACHE::cache_lock", 0},
|
||||||
|
{ &key_LOCK_alarm, "LOCK_alarm", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_my_thread_var_mutex, "my_thread_var::mutex", 0},
|
||||||
|
{ &key_THR_LOCK_charset, "THR_LOCK_charset", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_heap, "THR_LOCK_heap", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_isam, "THR_LOCK_isam", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_lock, "THR_LOCK_lock", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_malloc, "THR_LOCK_malloc", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_mutex, "THR_LOCK::mutex", 0},
|
||||||
|
{ &key_THR_LOCK_myisam, "THR_LOCK_myisam", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_net, "THR_LOCK_net", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_open, "THR_LOCK_open", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_threads, "THR_LOCK_threads", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_THR_LOCK_time, "THR_LOCK_time", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_TMPDIR_mutex, "TMPDIR_mutex", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
|
||||||
|
PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,
|
||||||
|
key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,
|
||||||
|
key_THR_COND_threads;
|
||||||
|
|
||||||
|
static PSI_cond_info all_mysys_conds[]=
|
||||||
|
{
|
||||||
|
{ &key_COND_alarm, "COND_alarm", PSI_FLAG_GLOBAL},
|
||||||
|
{ &key_IO_CACHE_SHARE_cond, "IO_CACHE_SHARE::cond", 0},
|
||||||
|
{ &key_IO_CACHE_SHARE_cond_writer, "IO_CACHE_SHARE::cond_writer", 0},
|
||||||
|
{ &key_my_thread_var_suspend, "my_thread_var::suspend", 0},
|
||||||
|
{ &key_THR_COND_threads, "THR_COND_threads", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef USE_ALARM_THREAD
|
||||||
|
PSI_thread_key key_thread_alarm;
|
||||||
|
|
||||||
|
static PSI_thread_info all_mysys_threads[]=
|
||||||
|
{
|
||||||
|
{ &key_thread_alarm, "alarm", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
#endif /* USE_ALARM_THREAD */
|
||||||
|
|
||||||
|
#ifdef HUGETLB_USE_PROC_MEMINFO
|
||||||
|
PSI_file_key key_file_proc_meminfo;
|
||||||
|
#endif /* HUGETLB_USE_PROC_MEMINFO */
|
||||||
|
PSI_file_key key_file_charset, key_file_cnf;
|
||||||
|
|
||||||
|
static PSI_file_info all_mysys_files[]=
|
||||||
|
{
|
||||||
|
#ifdef HUGETLB_USE_PROC_MEMINFO
|
||||||
|
{ &key_file_proc_meminfo, "proc_meminfo", 0},
|
||||||
|
#endif /* HUGETLB_USE_PROC_MEMINFO */
|
||||||
|
{ &key_file_charset, "charset", 0},
|
||||||
|
{ &key_file_cnf, "cnf", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
void my_init_mysys_psi_keys()
|
||||||
|
{
|
||||||
|
const char* category= "mysys";
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (PSI_server == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count= sizeof(all_mysys_mutexes)/sizeof(all_mysys_mutexes[0]);
|
||||||
|
PSI_server->register_mutex(category, all_mysys_mutexes, count);
|
||||||
|
|
||||||
|
count= sizeof(all_mysys_conds)/sizeof(all_mysys_conds[0]);
|
||||||
|
PSI_server->register_cond(category, all_mysys_conds, count);
|
||||||
|
|
||||||
|
#ifdef USE_ALARM_THREAD
|
||||||
|
count= sizeof(all_mysys_threads)/sizeof(all_mysys_threads[0]);
|
||||||
|
PSI_server->register_thread(category, all_mysys_threads, count);
|
||||||
|
#endif /* USE_ALARM_THREAD */
|
||||||
|
|
||||||
|
count= sizeof(all_mysys_files)/sizeof(all_mysys_files[0]);
|
||||||
|
PSI_server->register_file(category, all_mysys_files, count);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PSI_INTERFACE */
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004 MySQL AB
|
/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -91,19 +91,20 @@ void my_large_free(uchar* ptr, myf my_flags __attribute__((unused)))
|
|||||||
|
|
||||||
uint my_get_large_page_size_int(void)
|
uint my_get_large_page_size_int(void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
MYSQL_FILE *f;
|
||||||
uint size = 0;
|
uint size = 0;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
DBUG_ENTER("my_get_large_page_size_int");
|
DBUG_ENTER("my_get_large_page_size_int");
|
||||||
|
|
||||||
if (!(f = my_fopen("/proc/meminfo", O_RDONLY, MYF(MY_WME))))
|
if (!(f= mysql_file_fopen(key_file_proc_meminfo, "/proc/meminfo",
|
||||||
|
O_RDONLY, MYF(MY_WME))))
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), f))
|
while (mysql_file_fgets(buf, sizeof(buf), f))
|
||||||
if (sscanf(buf, "Hugepagesize: %u kB", &size))
|
if (sscanf(buf, "Hugepagesize: %u kB", &size))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
my_fclose(f, MYF(MY_WME));
|
mysql_file_fclose(f, MYF(MY_WME));
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
DBUG_RETURN(size * 1024);
|
DBUG_RETURN(size * 1024);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -110,7 +110,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||||||
DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
|
DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
|
||||||
|
|
||||||
#if defined(THREAD) && !defined(HAVE_READDIR_R)
|
#if defined(THREAD) && !defined(HAVE_READDIR_R)
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dirp = opendir(directory_file_name(tmp_path,(char *) path));
|
dirp = opendir(directory_file_name(tmp_path,(char *) path));
|
||||||
@ -173,7 +173,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||||||
|
|
||||||
(void) closedir(dirp);
|
(void) closedir(dirp);
|
||||||
#if defined(THREAD) && !defined(HAVE_READDIR_R)
|
#if defined(THREAD) && !defined(HAVE_READDIR_R)
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
#endif
|
#endif
|
||||||
result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
|
result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
|
||||||
result->number_off_files= dir_entries_storage->elements;
|
result->number_off_files= dir_entries_storage->elements;
|
||||||
@ -185,7 +185,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
#if defined(THREAD) && !defined(HAVE_READDIR_R)
|
#if defined(THREAD) && !defined(HAVE_READDIR_R)
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
#endif
|
#endif
|
||||||
my_errno=errno;
|
my_errno=errno;
|
||||||
if (dirp)
|
if (dirp)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -206,8 +206,8 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
|
|||||||
else
|
else
|
||||||
timeout_sec= WIN_LOCK_INFINITE;
|
timeout_sec= WIN_LOCK_INFINITE;
|
||||||
|
|
||||||
if(win_lock(fd, locktype, start, length, timeout_sec) == 0)
|
if (win_lock(fd, locktype, start, length, timeout_sec) == 0)
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if defined(HAVE_FCNTL)
|
#if defined(HAVE_FCNTL)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -66,9 +66,9 @@ uchar *my_malloc_lock(uint size,myf MyFlags)
|
|||||||
element->list.data=(uchar*) element;
|
element->list.data=(uchar*) element;
|
||||||
element->page=ptr;
|
element->page=ptr;
|
||||||
element->size=size;
|
element->size=size;
|
||||||
pthread_mutex_lock(&THR_LOCK_malloc);
|
mysql_mutex_lock(&THR_LOCK_malloc);
|
||||||
mem_list=list_add(mem_list,&element->list);
|
mem_list=list_add(mem_list,&element->list);
|
||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(ptr);
|
DBUG_RETURN(ptr);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
|
|||||||
LIST *list;
|
LIST *list;
|
||||||
struct st_mem_list *element=0;
|
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)
|
for (list=mem_list ; list ; list=list->next)
|
||||||
{
|
{
|
||||||
element=(struct st_mem_list*) list->data;
|
element=(struct st_mem_list*) list->data;
|
||||||
@ -90,7 +90,7 @@ void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||||
if (element)
|
if (element)
|
||||||
my_free((uchar*) element,MYF(0));
|
my_free((uchar*) element,MYF(0));
|
||||||
free(ptr); /* Free even if not locked */
|
free(ptr); /* Free even if not locked */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -35,8 +35,8 @@
|
|||||||
void my_inet_ntoa(struct in_addr in, char *buf)
|
void my_inet_ntoa(struct in_addr in, char *buf)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
pthread_mutex_lock(&THR_LOCK_net);
|
mysql_mutex_lock(&THR_LOCK_net);
|
||||||
ptr=inet_ntoa(in);
|
ptr=inet_ntoa(in);
|
||||||
strmov(buf,ptr);
|
strmov(buf,ptr);
|
||||||
pthread_mutex_unlock(&THR_LOCK_net);
|
mysql_mutex_unlock(&THR_LOCK_net);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -70,7 +70,7 @@ int my_close(File fd, myf MyFlags)
|
|||||||
DBUG_ENTER("my_close");
|
DBUG_ENTER("my_close");
|
||||||
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
|
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -90,12 +90,12 @@ int my_close(File fd, myf MyFlags)
|
|||||||
{
|
{
|
||||||
my_free(my_file_info[fd].name, MYF(0));
|
my_free(my_file_info[fd].name, MYF(0));
|
||||||
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
||||||
pthread_mutex_destroy(&my_file_info[fd].mutex);
|
mysql_mutex_destroy(&my_file_info[fd].mutex);
|
||||||
#endif
|
#endif
|
||||||
my_file_info[fd].type = UNOPEN;
|
my_file_info[fd].type = UNOPEN;
|
||||||
}
|
}
|
||||||
my_file_opened--;
|
my_file_opened--;
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
DBUG_RETURN(err);
|
DBUG_RETURN(err);
|
||||||
} /* my_close */
|
} /* my_close */
|
||||||
|
|
||||||
@ -134,20 +134,21 @@ File my_register_filename(File fd, const char *FileName, enum file_type
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags)))
|
if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags)))
|
||||||
{
|
{
|
||||||
my_file_opened++;
|
my_file_opened++;
|
||||||
my_file_total_opened++;
|
my_file_total_opened++;
|
||||||
my_file_info[fd].type = type_of_file;
|
my_file_info[fd].type = type_of_file;
|
||||||
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
|
||||||
pthread_mutex_init(&my_file_info[fd].mutex,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_my_file_info_mutex, &my_file_info[fd].mutex,
|
||||||
|
MY_MUTEX_INIT_FAST);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
DBUG_PRINT("exit",("fd: %d",fd));
|
DBUG_PRINT("exit",("fd: %d",fd));
|
||||||
DBUG_RETURN(fd);
|
DBUG_RETURN(fd);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
my_errno= ENOMEM;
|
my_errno= ENOMEM;
|
||||||
}
|
}
|
||||||
(void) my_close(fd, MyFlags);
|
(void) my_close(fd, MyFlags);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -60,12 +60,12 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
|
|||||||
{
|
{
|
||||||
errno= 0; /* Linux, Windows don't reset this on EOF/success */
|
errno= 0; /* Linux, Windows don't reset this on EOF/success */
|
||||||
#if !defined (HAVE_PREAD) && !defined (_WIN32)
|
#if !defined (HAVE_PREAD) && !defined (_WIN32)
|
||||||
pthread_mutex_lock(&my_file_info[Filedes].mutex);
|
mysql_mutex_lock(&my_file_info[Filedes].mutex);
|
||||||
readbytes= (uint) -1;
|
readbytes= (uint) -1;
|
||||||
error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
|
error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
|
||||||
(readbytes= read(Filedes, Buffer, Count)) != Count);
|
(readbytes= read(Filedes, Buffer, Count)) != Count);
|
||||||
save_errno= errno;
|
save_errno= errno;
|
||||||
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
|
mysql_mutex_unlock(&my_file_info[Filedes].mutex);
|
||||||
if (error)
|
if (error)
|
||||||
errno= save_errno;
|
errno= save_errno;
|
||||||
#else
|
#else
|
||||||
@ -150,10 +150,10 @@ size_t my_pwrite(File Filedes, const uchar *Buffer, size_t Count,
|
|||||||
#if !defined (HAVE_PREAD) && !defined (_WIN32)
|
#if !defined (HAVE_PREAD) && !defined (_WIN32)
|
||||||
int error;
|
int error;
|
||||||
writtenbytes= (size_t) -1;
|
writtenbytes= (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 &&
|
error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 &&
|
||||||
(writtenbytes= write(Filedes, Buffer, Count)) == Count);
|
(writtenbytes= write(Filedes, Buffer, Count)) == Count);
|
||||||
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
|
mysql_mutex_unlock(&my_file_info[Filedes].mutex);
|
||||||
if (error)
|
if (error)
|
||||||
break;
|
break;
|
||||||
#elif defined (_WIN32)
|
#elif defined (_WIN32)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -96,7 +96,7 @@ int my_sigwait(const sigset_t *set,int *sig)
|
|||||||
|
|
||||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||||
|
|
||||||
extern pthread_mutex_t LOCK_localtime_r;
|
extern mysql_mutex_t LOCK_localtime_r;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -104,10 +104,10 @@ extern pthread_mutex_t LOCK_localtime_r;
|
|||||||
struct tm *localtime_r(const time_t *clock, struct tm *res)
|
struct tm *localtime_r(const time_t *clock, struct tm *res)
|
||||||
{
|
{
|
||||||
struct tm *tmp;
|
struct tm *tmp;
|
||||||
pthread_mutex_lock(&LOCK_localtime_r);
|
mysql_mutex_lock(&LOCK_localtime_r);
|
||||||
tmp=localtime(clock);
|
tmp=localtime(clock);
|
||||||
*res= *tmp;
|
*res= *tmp;
|
||||||
pthread_mutex_unlock(&LOCK_localtime_r);
|
mysql_mutex_unlock(&LOCK_localtime_r);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -121,10 +121,10 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
|
|||||||
struct tm *gmtime_r(const time_t *clock, struct tm *res)
|
struct tm *gmtime_r(const time_t *clock, struct tm *res)
|
||||||
{
|
{
|
||||||
struct tm *tmp;
|
struct tm *tmp;
|
||||||
pthread_mutex_lock(&LOCK_localtime_r);
|
mysql_mutex_lock(&LOCK_localtime_r);
|
||||||
tmp= gmtime(clock);
|
tmp= gmtime(clock);
|
||||||
*res= *tmp;
|
*res= *tmp;
|
||||||
pthread_mutex_unlock(&LOCK_localtime_r);
|
mysql_mutex_unlock(&LOCK_localtime_r);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -317,14 +317,14 @@ int sigwait(sigset_t *setp, int *sigp)
|
|||||||
pthread_t sigwait_thread_id;
|
pthread_t sigwait_thread_id;
|
||||||
inited=1;
|
inited=1;
|
||||||
sigemptyset(&pending_set);
|
sigemptyset(&pending_set);
|
||||||
pthread_mutex_init(&LOCK_sigwait,MY_MUTEX_INIT_FAST);
|
pthread_mutex_init(&LOCK_sigwait, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&COND_sigwait,NULL);
|
pthread_cond_init(&COND_sigwait, NULL);
|
||||||
|
|
||||||
pthread_attr_init(&thr_attr);
|
pthread_attr_init(&thr_attr);
|
||||||
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
|
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
|
||||||
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
||||||
pthread_attr_setstacksize(&thr_attr,8196);
|
pthread_attr_setstacksize(&thr_attr,8196);
|
||||||
pthread_create(&sigwait_thread_id,&thr_attr,sigwait_thread,setp);
|
pthread_create(&sigwait_thread_id, &thr_attr, sigwait_thread, setp);
|
||||||
pthread_attr_destroy(&thr_attr);
|
pthread_attr_destroy(&thr_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ int sigwait(sigset_t *setp, int *sigp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_cond_wait(&COND_sigwait,&LOCK_sigwait);
|
pthread_cond_wait(&COND_sigwait, &LOCK_sigwait);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -24,17 +24,17 @@
|
|||||||
|
|
||||||
#ifdef THREAD
|
#ifdef THREAD
|
||||||
pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
|
pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
|
||||||
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_myisam,THR_LOCK_heap,
|
THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_myisam, THR_LOCK_heap,
|
||||||
THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time;
|
THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time;
|
||||||
pthread_cond_t THR_COND_threads;
|
mysql_cond_t THR_COND_threads;
|
||||||
uint THR_thread_count= 0;
|
uint THR_thread_count= 0;
|
||||||
uint my_thread_end_wait_time= 5;
|
uint my_thread_end_wait_time= 5;
|
||||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||||
pthread_mutex_t LOCK_localtime_r;
|
mysql_mutex_t LOCK_localtime_r;
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_GETHOSTBYNAME_R
|
#ifndef HAVE_GETHOSTBYNAME_R
|
||||||
pthread_mutex_t LOCK_gethostbyname_r;
|
mysql_mutex_t LOCK_gethostbyname_r;
|
||||||
#endif
|
#endif
|
||||||
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
||||||
pthread_mutexattr_t my_fast_mutexattr;
|
pthread_mutexattr_t my_fast_mutexattr;
|
||||||
@ -65,6 +65,84 @@ nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
|
|||||||
|
|
||||||
static uint get_thread_lib(void);
|
static uint get_thread_lib(void);
|
||||||
|
|
||||||
|
/** True if @c my_thread_basic_global_init() has been called. */
|
||||||
|
static my_bool my_thread_basic_global_init_done= 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a minimal initialisation of mysys, when compiled with threads.
|
||||||
|
The initialisation performed is sufficient to:
|
||||||
|
- allocate memory
|
||||||
|
- perform file operations
|
||||||
|
- use charsets
|
||||||
|
- use my_errno
|
||||||
|
@sa my_basic_init
|
||||||
|
@sa my_thread_basic_global_reinit
|
||||||
|
*/
|
||||||
|
my_bool my_thread_basic_global_init(void)
|
||||||
|
{
|
||||||
|
int pth_ret;
|
||||||
|
|
||||||
|
if (my_thread_basic_global_init_done)
|
||||||
|
return 0;
|
||||||
|
my_thread_basic_global_init_done= 1;
|
||||||
|
|
||||||
|
mysql_mutex_init(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Can't initialize threads: error %d\n", pth_ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (my_thread_init())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Re-initialize components initialized early with @c my_thread_basic_global_init.
|
||||||
|
Some mutexes were initialized before the instrumentation.
|
||||||
|
Destroy + create them again, now that the instrumentation
|
||||||
|
is in place.
|
||||||
|
This is safe, since this function() is called before creating new threads,
|
||||||
|
so the mutexes are not in use.
|
||||||
|
*/
|
||||||
|
void my_thread_basic_global_reinit(void)
|
||||||
|
{
|
||||||
|
struct st_my_thread_var *tmp;
|
||||||
|
|
||||||
|
DBUG_ASSERT(my_thread_basic_global_init_done);
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
my_init_mysys_psi_keys();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mysql_mutex_destroy(&THR_LOCK_malloc);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
mysql_mutex_destroy(&THR_LOCK_open);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
mysql_mutex_destroy(&THR_LOCK_charset);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
mysql_mutex_destroy(&THR_LOCK_threads);
|
||||||
|
mysql_mutex_init(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
tmp= my_pthread_getspecific(struct st_my_thread_var*, THR_KEY_mysys);
|
||||||
|
DBUG_ASSERT(tmp);
|
||||||
|
|
||||||
|
mysql_mutex_destroy(&tmp->mutex);
|
||||||
|
mysql_mutex_init(key_my_thread_var_mutex, &tmp->mutex, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
mysql_cond_destroy(&tmp->suspend);
|
||||||
|
mysql_cond_init(key_my_thread_var_suspend, &tmp->suspend, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
initialize thread environment
|
initialize thread environment
|
||||||
|
|
||||||
@ -78,14 +156,10 @@ static uint get_thread_lib(void);
|
|||||||
|
|
||||||
my_bool my_thread_global_init(void)
|
my_bool my_thread_global_init(void)
|
||||||
{
|
{
|
||||||
int pth_ret;
|
if (my_thread_basic_global_init())
|
||||||
thd_lib_detected= get_thread_lib();
|
|
||||||
|
|
||||||
if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"Can't initialize threads: error %d\n", pth_ret);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
thd_lib_detected= get_thread_lib();
|
||||||
|
|
||||||
#ifdef TARGET_OS_LINUX
|
#ifdef TARGET_OS_LINUX
|
||||||
/*
|
/*
|
||||||
@ -137,23 +211,20 @@ my_bool my_thread_global_init(void)
|
|||||||
PTHREAD_MUTEX_ERRORCHECK);
|
PTHREAD_MUTEX_ERRORCHECK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pthread_mutex_init(&THR_LOCK_malloc,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_THR_LOCK_lock, &THR_LOCK_lock, MY_MUTEX_INIT_FAST);
|
||||||
pthread_mutex_init(&THR_LOCK_open,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_THR_LOCK_isam, &THR_LOCK_isam, MY_MUTEX_INIT_SLOW);
|
||||||
pthread_mutex_init(&THR_LOCK_lock,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW);
|
||||||
pthread_mutex_init(&THR_LOCK_isam,MY_MUTEX_INIT_SLOW);
|
mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST);
|
||||||
pthread_mutex_init(&THR_LOCK_myisam,MY_MUTEX_INIT_SLOW);
|
mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST);
|
||||||
pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_THR_LOCK_time, &THR_LOCK_time, MY_MUTEX_INIT_FAST);
|
||||||
pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST);
|
mysql_cond_init(key_THR_COND_threads, &THR_COND_threads, NULL);
|
||||||
pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST);
|
|
||||||
pthread_mutex_init(&THR_LOCK_threads,MY_MUTEX_INIT_FAST);
|
|
||||||
pthread_mutex_init(&THR_LOCK_time,MY_MUTEX_INIT_FAST);
|
|
||||||
pthread_cond_init(&THR_COND_threads, NULL);
|
|
||||||
|
|
||||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||||
pthread_mutex_init(&LOCK_localtime_r,MY_MUTEX_INIT_SLOW);
|
mysql_mutex_init(key_LOCK_localtime_r, &LOCK_localtime_r, MY_MUTEX_INIT_SLOW);
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_GETHOSTBYNAME_R
|
#ifndef HAVE_GETHOSTBYNAME_R
|
||||||
pthread_mutex_init(&LOCK_gethostbyname_r,MY_MUTEX_INIT_SLOW);
|
mysql_mutex_init(key_LOCK_gethostbyname_r,
|
||||||
|
&LOCK_gethostbyname_r, MY_MUTEX_INIT_SLOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -175,11 +246,11 @@ void my_thread_global_end(void)
|
|||||||
my_bool all_threads_killed= 1;
|
my_bool all_threads_killed= 1;
|
||||||
|
|
||||||
set_timespec(abstime, my_thread_end_wait_time);
|
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)
|
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);
|
&abstime);
|
||||||
if (error == ETIMEDOUT || error == ETIME)
|
if (error == ETIMEDOUT || error == ETIME)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PTHREAD_KILL
|
#ifdef HAVE_PTHREAD_KILL
|
||||||
@ -197,7 +268,7 @@ void my_thread_global_end(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_threads);
|
mysql_mutex_unlock(&THR_LOCK_threads);
|
||||||
|
|
||||||
pthread_key_delete(THR_KEY_mysys);
|
pthread_key_delete(THR_KEY_mysys);
|
||||||
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
||||||
@ -206,25 +277,25 @@ void my_thread_global_end(void)
|
|||||||
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||||
pthread_mutexattr_destroy(&my_errorcheck_mutexattr);
|
pthread_mutexattr_destroy(&my_errorcheck_mutexattr);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_destroy(&THR_LOCK_malloc);
|
mysql_mutex_destroy(&THR_LOCK_malloc);
|
||||||
pthread_mutex_destroy(&THR_LOCK_open);
|
mysql_mutex_destroy(&THR_LOCK_open);
|
||||||
pthread_mutex_destroy(&THR_LOCK_lock);
|
mysql_mutex_destroy(&THR_LOCK_lock);
|
||||||
pthread_mutex_destroy(&THR_LOCK_isam);
|
mysql_mutex_destroy(&THR_LOCK_isam);
|
||||||
pthread_mutex_destroy(&THR_LOCK_myisam);
|
mysql_mutex_destroy(&THR_LOCK_myisam);
|
||||||
pthread_mutex_destroy(&THR_LOCK_heap);
|
mysql_mutex_destroy(&THR_LOCK_heap);
|
||||||
pthread_mutex_destroy(&THR_LOCK_net);
|
mysql_mutex_destroy(&THR_LOCK_net);
|
||||||
pthread_mutex_destroy(&THR_LOCK_time);
|
mysql_mutex_destroy(&THR_LOCK_time);
|
||||||
pthread_mutex_destroy(&THR_LOCK_charset);
|
mysql_mutex_destroy(&THR_LOCK_charset);
|
||||||
if (all_threads_killed)
|
if (all_threads_killed)
|
||||||
{
|
{
|
||||||
pthread_mutex_destroy(&THR_LOCK_threads);
|
mysql_mutex_destroy(&THR_LOCK_threads);
|
||||||
pthread_cond_destroy(&THR_COND_threads);
|
mysql_cond_destroy(&THR_COND_threads);
|
||||||
}
|
}
|
||||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||||
pthread_mutex_destroy(&LOCK_localtime_r);
|
mysql_mutex_destroy(&LOCK_localtime_r);
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_GETHOSTBYNAME_R
|
#ifndef HAVE_GETHOSTBYNAME_R
|
||||||
pthread_mutex_destroy(&LOCK_gethostbyname_r);
|
mysql_mutex_destroy(&LOCK_gethostbyname_r);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,17 +351,17 @@ my_bool my_thread_init(void)
|
|||||||
}
|
}
|
||||||
pthread_setspecific(THR_KEY_mysys,tmp);
|
pthread_setspecific(THR_KEY_mysys,tmp);
|
||||||
tmp->pthread_self= pthread_self();
|
tmp->pthread_self= pthread_self();
|
||||||
pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_my_thread_var_mutex, &tmp->mutex, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&tmp->suspend, NULL);
|
mysql_cond_init(key_my_thread_var_suspend, &tmp->suspend, NULL);
|
||||||
tmp->init= 1;
|
|
||||||
|
|
||||||
tmp->stack_ends_here= (char*)&tmp +
|
tmp->stack_ends_here= (char*)&tmp +
|
||||||
STACK_DIRECTION * (long)my_thread_stack_size;
|
STACK_DIRECTION * (long)my_thread_stack_size;
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_threads);
|
mysql_mutex_lock(&THR_LOCK_threads);
|
||||||
tmp->id= ++thread_id;
|
tmp->id= ++thread_id;
|
||||||
++THR_thread_count;
|
++THR_thread_count;
|
||||||
pthread_mutex_unlock(&THR_LOCK_threads);
|
mysql_mutex_unlock(&THR_LOCK_threads);
|
||||||
|
tmp->init= 1;
|
||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
/* Generate unique name for thread */
|
/* Generate unique name for thread */
|
||||||
(void) my_thread_name();
|
(void) my_thread_name();
|
||||||
@ -322,6 +393,17 @@ void my_thread_end(void)
|
|||||||
fprintf(stderr,"my_thread_end(): tmp: 0x%lx pthread_self: 0x%lx thread_id: %ld\n",
|
fprintf(stderr,"my_thread_end(): tmp: 0x%lx pthread_self: 0x%lx thread_id: %ld\n",
|
||||||
(long) tmp, (long) pthread_self(), tmp ? (long) tmp->id : 0L);
|
(long) tmp, (long) pthread_self(), tmp ? (long) tmp->id : 0L);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
/*
|
||||||
|
Remove the instrumentation for this thread.
|
||||||
|
This must be done before trashing st_my_thread_var,
|
||||||
|
because the LF_HASH depends on it.
|
||||||
|
*/
|
||||||
|
if (PSI_server)
|
||||||
|
PSI_server->delete_current_thread();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tmp && tmp->init)
|
if (tmp && tmp->init)
|
||||||
{
|
{
|
||||||
#if !defined(DBUG_OFF)
|
#if !defined(DBUG_OFF)
|
||||||
@ -335,9 +417,9 @@ void my_thread_end(void)
|
|||||||
#endif
|
#endif
|
||||||
#if !defined(__bsdi__) && !defined(__OpenBSD__)
|
#if !defined(__bsdi__) && !defined(__OpenBSD__)
|
||||||
/* bsdi and openbsd 3.5 dumps core here */
|
/* bsdi and openbsd 3.5 dumps core here */
|
||||||
pthread_cond_destroy(&tmp->suspend);
|
mysql_cond_destroy(&tmp->suspend);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_destroy(&tmp->mutex);
|
mysql_mutex_destroy(&tmp->mutex);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -346,11 +428,11 @@ void my_thread_end(void)
|
|||||||
my_thread_end and thus freed all memory they have allocated in
|
my_thread_end and thus freed all memory they have allocated in
|
||||||
my_thread_init() and DBUG_xxxx
|
my_thread_init() and DBUG_xxxx
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&THR_LOCK_threads);
|
mysql_mutex_lock(&THR_LOCK_threads);
|
||||||
DBUG_ASSERT(THR_thread_count != 0);
|
DBUG_ASSERT(THR_thread_count != 0);
|
||||||
if (--THR_thread_count == 0)
|
if (--THR_thread_count == 0)
|
||||||
pthread_cond_signal(&THR_COND_threads);
|
mysql_cond_signal(&THR_COND_threads);
|
||||||
pthread_mutex_unlock(&THR_LOCK_threads);
|
mysql_mutex_unlock(&THR_LOCK_threads);
|
||||||
}
|
}
|
||||||
pthread_setspecific(THR_KEY_mysys,0);
|
pthread_setspecific(THR_KEY_mysys,0);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2008 MySQL AB
|
/* Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -57,7 +57,7 @@ File my_open_osfhandle(HANDLE handle, int oflag)
|
|||||||
uint i;
|
uint i;
|
||||||
DBUG_ENTER("my_open_osfhandle");
|
DBUG_ENTER("my_open_osfhandle");
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_open);
|
mysql_mutex_lock(&THR_LOCK_open);
|
||||||
for(i= MY_FILE_MIN; i < my_file_limit;i++)
|
for(i= MY_FILE_MIN; i < my_file_limit;i++)
|
||||||
{
|
{
|
||||||
if(my_file_info[i].fhandle == 0)
|
if(my_file_info[i].fhandle == 0)
|
||||||
@ -70,7 +70,7 @@ File my_open_osfhandle(HANDLE handle, int oflag)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&THR_LOCK_open);
|
mysql_mutex_unlock(&THR_LOCK_open);
|
||||||
if(offset == -1)
|
if(offset == -1)
|
||||||
errno= EMFILE; /* to many file handles open */
|
errno= EMFILE; /* to many file handles open */
|
||||||
DBUG_RETURN(offset);
|
DBUG_RETURN(offset);
|
||||||
|
@ -59,9 +59,9 @@ extern PSI_thread_key key_thread_alarm;
|
|||||||
|
|
||||||
#endif /* HAVE_PSI_INTERFACE */
|
#endif /* HAVE_PSI_INTERFACE */
|
||||||
|
|
||||||
extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
|
extern mysql_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 mysql_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_charset, THR_LOCK_time;
|
||||||
#else /* THREAD */
|
#else /* THREAD */
|
||||||
#include <my_no_pthread.h>
|
#include <my_no_pthread.h>
|
||||||
#endif /* THREAD */
|
#endif /* THREAD */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -178,7 +178,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
|
|||||||
irem->prev= NULL;
|
irem->prev= NULL;
|
||||||
|
|
||||||
/* Add this remember structure to the linked list */
|
/* 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))
|
if ((irem->next= sf_malloc_root))
|
||||||
sf_malloc_root->prev= irem;
|
sf_malloc_root->prev= irem;
|
||||||
sf_malloc_root= irem;
|
sf_malloc_root= irem;
|
||||||
@ -188,7 +188,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
|
|||||||
if (sf_malloc_cur_memory > sf_malloc_max_memory)
|
if (sf_malloc_cur_memory > sf_malloc_max_memory)
|
||||||
sf_malloc_max_memory= sf_malloc_cur_memory;
|
sf_malloc_max_memory= sf_malloc_cur_memory;
|
||||||
sf_malloc_count++;
|
sf_malloc_count++;
|
||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||||
|
|
||||||
/* Set the memory to the aribtrary wierd value */
|
/* Set the memory to the aribtrary wierd value */
|
||||||
if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
|
if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
|
||||||
@ -291,7 +291,7 @@ void _myfree(void *ptr, const char *filename, uint lineno, myf myflags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove this structure from the linked list */
|
/* Remove this structure from the linked list */
|
||||||
pthread_mutex_lock(&THR_LOCK_malloc);
|
mysql_mutex_lock(&THR_LOCK_malloc);
|
||||||
if (irem->prev)
|
if (irem->prev)
|
||||||
irem->prev->next= irem->next;
|
irem->prev->next= irem->next;
|
||||||
else
|
else
|
||||||
@ -302,7 +302,7 @@ void _myfree(void *ptr, const char *filename, uint lineno, myf myflags)
|
|||||||
/* Handle the statistics */
|
/* Handle the statistics */
|
||||||
sf_malloc_cur_memory-= irem->datasize;
|
sf_malloc_cur_memory-= irem->datasize;
|
||||||
sf_malloc_count--;
|
sf_malloc_count--;
|
||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||||
|
|
||||||
#ifndef HAVE_purify
|
#ifndef HAVE_purify
|
||||||
/* Mark this data as free'ed */
|
/* Mark this data as free'ed */
|
||||||
@ -365,7 +365,7 @@ void TERMINATE(FILE *file, uint flag)
|
|||||||
{
|
{
|
||||||
struct st_irem *irem;
|
struct st_irem *irem;
|
||||||
DBUG_ENTER("TERMINATE");
|
DBUG_ENTER("TERMINATE");
|
||||||
pthread_mutex_lock(&THR_LOCK_malloc);
|
mysql_mutex_lock(&THR_LOCK_malloc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Report the difference between number of calls to
|
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)",
|
DBUG_PRINT("safe",("Maximum memory usage: %lu bytes (%luk)",
|
||||||
(ulong) sf_malloc_max_memory,
|
(ulong) sf_malloc_max_memory,
|
||||||
(ulong) (sf_malloc_max_memory + 1023L) /1024L));
|
(ulong) (sf_malloc_max_memory + 1023L) /1024L));
|
||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ int _sanity(const char *filename, uint lineno)
|
|||||||
reg2 int flag=0;
|
reg2 int flag=0;
|
||||||
uint count=0;
|
uint count=0;
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_malloc);
|
mysql_mutex_lock(&THR_LOCK_malloc);
|
||||||
#ifndef PEDANTIC_SAFEMALLOC
|
#ifndef PEDANTIC_SAFEMALLOC
|
||||||
if (sf_malloc_tampered && (int) sf_malloc_count < 0)
|
if (sf_malloc_tampered && (int) sf_malloc_count < 0)
|
||||||
sf_malloc_count=0;
|
sf_malloc_count=0;
|
||||||
@ -513,7 +513,7 @@ int _sanity(const char *filename, uint lineno)
|
|||||||
count=sf_malloc_count;
|
count=sf_malloc_count;
|
||||||
for (irem= sf_malloc_root; irem != NULL && count-- ; irem= irem->next)
|
for (irem= sf_malloc_root; irem != NULL && count-- ; irem= irem->next)
|
||||||
flag+= _checkchunk (irem, filename, lineno);
|
flag+= _checkchunk (irem, filename, lineno);
|
||||||
pthread_mutex_unlock(&THR_LOCK_malloc);
|
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||||
if (count || irem)
|
if (count || irem)
|
||||||
{
|
{
|
||||||
const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'";
|
const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
/* To avoid problems with alarms in debug code, we disable DBUG here */
|
/* To avoid problems with alarms in debug code, we disable DBUG here */
|
||||||
#define FORCE_DBUG_OFF
|
#define FORCE_DBUG_OFF
|
||||||
|
#include "mysys_priv.h"
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
|
|
||||||
#if defined(THREAD) && !defined(DONT_USE_THR_ALARM)
|
#if defined(THREAD) && !defined(DONT_USE_THR_ALARM)
|
||||||
@ -43,8 +44,8 @@ static sig_handler process_alarm_part2(int sig);
|
|||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(__WIN__)
|
||||||
|
|
||||||
static pthread_mutex_t LOCK_alarm;
|
static mysql_mutex_t LOCK_alarm;
|
||||||
static pthread_cond_t COND_alarm;
|
static mysql_cond_t COND_alarm;
|
||||||
static sigset_t full_signal_set;
|
static sigset_t full_signal_set;
|
||||||
static QUEUE alarm_queue;
|
static QUEUE alarm_queue;
|
||||||
static uint max_used_alarms=0;
|
static uint max_used_alarms=0;
|
||||||
@ -52,7 +53,7 @@ pthread_t alarm_thread;
|
|||||||
|
|
||||||
#ifdef USE_ALARM_THREAD
|
#ifdef USE_ALARM_THREAD
|
||||||
static void *alarm_handler(void *arg);
|
static void *alarm_handler(void *arg);
|
||||||
#define reschedule_alarms() pthread_cond_signal(&COND_alarm)
|
#define reschedule_alarms() mysql_cond_signal(&COND_alarm)
|
||||||
#else
|
#else
|
||||||
#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
|
#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
|
||||||
#endif
|
#endif
|
||||||
@ -75,8 +76,8 @@ void init_thr_alarm(uint max_alarms)
|
|||||||
init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
|
init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
|
||||||
compare_ulong,NullS);
|
compare_ulong,NullS);
|
||||||
sigfillset(&full_signal_set); /* Neaded to block signals */
|
sigfillset(&full_signal_set); /* Neaded to block signals */
|
||||||
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_LOCK_alarm, &LOCK_alarm, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&COND_alarm,NULL);
|
mysql_cond_init(key_COND_alarm, &COND_alarm, NULL);
|
||||||
if (thd_lib_detected == THD_LIB_LT)
|
if (thd_lib_detected == THD_LIB_LT)
|
||||||
thr_client_alarm= SIGALRM;
|
thr_client_alarm= SIGALRM;
|
||||||
else
|
else
|
||||||
@ -97,7 +98,8 @@ void init_thr_alarm(uint max_alarms)
|
|||||||
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
|
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
|
||||||
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
||||||
pthread_attr_setstacksize(&thr_attr,8196);
|
pthread_attr_setstacksize(&thr_attr,8196);
|
||||||
pthread_create(&alarm_thread,&thr_attr,alarm_handler,NULL);
|
mysql_thread_create(key_thread_alarm,
|
||||||
|
&alarm_thread, &thr_attr, alarm_handler, NULL);
|
||||||
pthread_attr_destroy(&thr_attr);
|
pthread_attr_destroy(&thr_attr);
|
||||||
}
|
}
|
||||||
#elif defined(USE_ONE_SIGNAL_HAND)
|
#elif defined(USE_ONE_SIGNAL_HAND)
|
||||||
@ -117,14 +119,14 @@ void init_thr_alarm(uint max_alarms)
|
|||||||
|
|
||||||
void resize_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
|
It's ok not to shrink the queue as there may be more pending alarms than
|
||||||
than max_alarms
|
than max_alarms
|
||||||
*/
|
*/
|
||||||
if (alarm_queue.elements < max_alarms)
|
if (alarm_queue.elements < max_alarms)
|
||||||
resize_queue(&alarm_queue,max_alarms+1);
|
resize_queue(&alarm_queue,max_alarms+1);
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,12 +164,12 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
|
|||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
|
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */
|
mysql_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */
|
||||||
if (alarm_aborted > 0)
|
if (alarm_aborted > 0)
|
||||||
{ /* No signal thread */
|
{ /* No signal thread */
|
||||||
DBUG_PRINT("info", ("alarm aborted"));
|
DBUG_PRINT("info", ("alarm aborted"));
|
||||||
*alrm= 0; /* No alarm */
|
*alrm= 0; /* No alarm */
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -183,7 +185,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
|
|||||||
DBUG_PRINT("info", ("alarm queue full"));
|
DBUG_PRINT("info", ("alarm queue full"));
|
||||||
fprintf(stderr,"Warning: thr_alarm queue is full\n");
|
fprintf(stderr,"Warning: thr_alarm queue is full\n");
|
||||||
*alrm= 0; /* No alarm */
|
*alrm= 0; /* No alarm */
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -198,7 +200,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
|
|||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("failed my_malloc()"));
|
DBUG_PRINT("info", ("failed my_malloc()"));
|
||||||
*alrm= 0; /* No alarm */
|
*alrm= 0; /* No alarm */
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -226,7 +228,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
|
|||||||
else
|
else
|
||||||
reschedule_alarms(); /* Reschedule alarms */
|
reschedule_alarms(); /* Reschedule alarms */
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -251,7 +253,7 @@ void thr_end_alarm(thr_alarm_t *alarmed)
|
|||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
|
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_lock(&LOCK_alarm);
|
mysql_mutex_lock(&LOCK_alarm);
|
||||||
|
|
||||||
alarm_data= (ALARM*) ((uchar*) *alarmed - offsetof(ALARM,alarmed));
|
alarm_data= (ALARM*) ((uchar*) *alarmed - offsetof(ALARM,alarmed));
|
||||||
for (i=0 ; i < alarm_queue.elements ; i++)
|
for (i=0 ; i < alarm_queue.elements ; i++)
|
||||||
@ -276,7 +278,7 @@ void thr_end_alarm(thr_alarm_t *alarmed)
|
|||||||
DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
|
DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
|
||||||
(long) *alarmed));
|
(long) *alarmed));
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
#ifndef USE_ONE_SIGNAL_HAND
|
#ifndef USE_ONE_SIGNAL_HAND
|
||||||
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -319,14 +321,14 @@ sig_handler process_alarm(int sig __attribute__((unused)))
|
|||||||
|
|
||||||
#ifndef USE_ALARM_THREAD
|
#ifndef USE_ALARM_THREAD
|
||||||
pthread_sigmask(SIG_SETMASK,&full_signal_set,&old_mask);
|
pthread_sigmask(SIG_SETMASK,&full_signal_set,&old_mask);
|
||||||
pthread_mutex_lock(&LOCK_alarm);
|
mysql_mutex_lock(&LOCK_alarm);
|
||||||
#endif
|
#endif
|
||||||
process_alarm_part2(sig);
|
process_alarm_part2(sig);
|
||||||
#ifndef USE_ALARM_THREAD
|
#ifndef USE_ALARM_THREAD
|
||||||
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
|
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
|
||||||
my_sigset(THR_SERVER_ALARM,process_alarm);
|
my_sigset(THR_SERVER_ALARM,process_alarm);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
@ -434,7 +436,7 @@ void end_thr_alarm(my_bool free_structures)
|
|||||||
DBUG_ENTER("end_thr_alarm");
|
DBUG_ENTER("end_thr_alarm");
|
||||||
if (alarm_aborted != 1) /* If memory not freed */
|
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));
|
DBUG_PRINT("info",("Resheduling %d waiting alarms",alarm_queue.elements));
|
||||||
alarm_aborted= -1; /* mark aborted */
|
alarm_aborted= -1; /* mark aborted */
|
||||||
if (alarm_queue.elements || (alarm_thread_running && free_structures))
|
if (alarm_queue.elements || (alarm_thread_running && free_structures))
|
||||||
@ -454,21 +456,21 @@ void end_thr_alarm(my_bool free_structures)
|
|||||||
set_timespec(abstime, 10); /* Wait up to 10 seconds */
|
set_timespec(abstime, 10); /* Wait up to 10 seconds */
|
||||||
while (alarm_thread_running)
|
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)
|
if (error == ETIME || error == ETIMEDOUT)
|
||||||
break; /* Don't wait forever */
|
break; /* Don't wait forever */
|
||||||
}
|
}
|
||||||
delete_queue(&alarm_queue);
|
delete_queue(&alarm_queue);
|
||||||
alarm_aborted= 1;
|
alarm_aborted= 1;
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
if (!alarm_thread_running) /* Safety */
|
if (!alarm_thread_running) /* Safety */
|
||||||
{
|
{
|
||||||
pthread_mutex_destroy(&LOCK_alarm);
|
mysql_mutex_destroy(&LOCK_alarm);
|
||||||
pthread_cond_destroy(&COND_alarm);
|
mysql_cond_destroy(&COND_alarm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
@ -483,7 +485,7 @@ void thr_alarm_kill(my_thread_id thread_id)
|
|||||||
uint i;
|
uint i;
|
||||||
if (alarm_aborted)
|
if (alarm_aborted)
|
||||||
return;
|
return;
|
||||||
pthread_mutex_lock(&LOCK_alarm);
|
mysql_mutex_lock(&LOCK_alarm);
|
||||||
for (i=0 ; i < alarm_queue.elements ; i++)
|
for (i=0 ; i < alarm_queue.elements ; i++)
|
||||||
{
|
{
|
||||||
if (((ALARM*) queue_element(&alarm_queue,i))->thread_id == thread_id)
|
if (((ALARM*) queue_element(&alarm_queue,i))->thread_id == thread_id)
|
||||||
@ -495,13 +497,13 @@ void thr_alarm_kill(my_thread_id thread_id)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void thr_alarm_info(ALARM_INFO *info)
|
void thr_alarm_info(ALARM_INFO *info)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_alarm);
|
mysql_mutex_lock(&LOCK_alarm);
|
||||||
info->next_alarm_time= 0;
|
info->next_alarm_time= 0;
|
||||||
info->max_used_alarms= max_used_alarms;
|
info->max_used_alarms= max_used_alarms;
|
||||||
if ((info->active_alarms= alarm_queue.elements))
|
if ((info->active_alarms= alarm_queue.elements))
|
||||||
@ -512,7 +514,7 @@ void thr_alarm_info(ALARM_INFO *info)
|
|||||||
time_diff= (long) (alarm_data->expire_time - now);
|
time_diff= (long) (alarm_data->expire_time - now);
|
||||||
info->next_alarm_time= (ulong) (time_diff < 0 ? 0 : time_diff);
|
info->next_alarm_time= (ulong) (time_diff < 0 ? 0 : time_diff);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -549,7 +551,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
|
|||||||
#endif
|
#endif
|
||||||
my_thread_init();
|
my_thread_init();
|
||||||
alarm_thread_running= 1;
|
alarm_thread_running= 1;
|
||||||
pthread_mutex_lock(&LOCK_alarm);
|
mysql_mutex_lock(&LOCK_alarm);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (alarm_queue.elements)
|
if (alarm_queue.elements)
|
||||||
@ -564,7 +566,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
|
|||||||
abstime.tv_sec=sleep_time;
|
abstime.tv_sec=sleep_time;
|
||||||
abstime.tv_nsec=0;
|
abstime.tv_nsec=0;
|
||||||
next_alarm_expire_time= sleep_time;
|
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)
|
error != ETIME && error != ETIMEDOUT)
|
||||||
{
|
{
|
||||||
#ifdef MAIN
|
#ifdef MAIN
|
||||||
@ -579,7 +581,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
next_alarm_expire_time= ~ (time_t) 0;
|
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
|
#ifdef MAIN
|
||||||
printf("Got error: %d from ptread_cond_wait (errno: %d)\n",
|
printf("Got error: %d from ptread_cond_wait (errno: %d)\n",
|
||||||
@ -591,8 +593,8 @@ static void *alarm_handler(void *arg __attribute__((unused)))
|
|||||||
}
|
}
|
||||||
bzero((char*) &alarm_thread,sizeof(alarm_thread)); /* For easy debugging */
|
bzero((char*) &alarm_thread,sizeof(alarm_thread)); /* For easy debugging */
|
||||||
alarm_thread_running= 0;
|
alarm_thread_running= 0;
|
||||||
pthread_cond_signal(&COND_alarm);
|
mysql_cond_signal(&COND_alarm);
|
||||||
pthread_mutex_unlock(&LOCK_alarm);
|
mysql_mutex_unlock(&LOCK_alarm);
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
return 0; /* Impossible */
|
return 0; /* Impossible */
|
||||||
}
|
}
|
||||||
@ -694,8 +696,8 @@ void resize_thr_alarm(uint max_alarms)
|
|||||||
#ifdef MAIN
|
#ifdef MAIN
|
||||||
#if defined(THREAD) && !defined(DONT_USE_THR_ALARM)
|
#if defined(THREAD) && !defined(DONT_USE_THR_ALARM)
|
||||||
|
|
||||||
static pthread_cond_t COND_thread_count;
|
static mysql_cond_t COND_thread_count;
|
||||||
static pthread_mutex_t LOCK_thread_count;
|
static mysql_mutex_t LOCK_thread_count;
|
||||||
static uint thread_count;
|
static uint thread_count;
|
||||||
|
|
||||||
#ifdef HPUX10
|
#ifdef HPUX10
|
||||||
@ -782,10 +784,10 @@ static void *test_thread(void *arg)
|
|||||||
thr_end_alarm(&got_alarm);
|
thr_end_alarm(&got_alarm);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_thread_count);
|
mysql_mutex_lock(&LOCK_thread_count);
|
||||||
thread_count--;
|
thread_count--;
|
||||||
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
mysql_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
free((uchar*) arg);
|
free((uchar*) arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -812,9 +814,9 @@ static void *signal_hand(void *arg __attribute__((unused)))
|
|||||||
my_thread_init();
|
my_thread_init();
|
||||||
pthread_detach_this_thread();
|
pthread_detach_this_thread();
|
||||||
init_thr_alarm(10); /* Setup alarm handler */
|
init_thr_alarm(10); /* Setup alarm handler */
|
||||||
pthread_mutex_lock(&LOCK_thread_count); /* Required by bsdi */
|
mysql_mutex_lock(&LOCK_thread_count); /* Required by bsdi */
|
||||||
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
mysql_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
|
|
||||||
sigemptyset(&set); /* Catch all signals */
|
sigemptyset(&set); /* Catch all signals */
|
||||||
sigaddset(&set,SIGINT);
|
sigaddset(&set,SIGINT);
|
||||||
@ -885,8 +887,8 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||||||
{
|
{
|
||||||
DBUG_PUSH(argv[1]+2);
|
DBUG_PUSH(argv[1]+2);
|
||||||
}
|
}
|
||||||
pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(0, &LOCK_thread_count, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&COND_thread_count,NULL);
|
mysql_cond_init(0, &COND_thread_count, NULL);
|
||||||
|
|
||||||
/* Start a alarm handling thread */
|
/* Start a alarm handling thread */
|
||||||
sigemptyset(&set);
|
sigemptyset(&set);
|
||||||
@ -913,10 +915,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||||||
pthread_attr_setstacksize(&thr_attr,65536L);
|
pthread_attr_setstacksize(&thr_attr,65536L);
|
||||||
|
|
||||||
/* Start signal thread and wait for it to start */
|
/* 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);
|
mysql_thread_create(0,
|
||||||
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
|
&tid, &thr_attr, signal_hand, NULL);
|
||||||
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"));
|
DBUG_PRINT("info",("signal thread created"));
|
||||||
|
|
||||||
thr_setconcurrency(3);
|
thr_setconcurrency(3);
|
||||||
@ -926,32 +929,34 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||||||
{
|
{
|
||||||
param=(int*) malloc(sizeof(int));
|
param=(int*) malloc(sizeof(int));
|
||||||
*param= i;
|
*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)))
|
if ((error= mysql_thread_create(0,
|
||||||
|
&tid, &thr_attr, test_thread,
|
||||||
|
(void*) param)))
|
||||||
{
|
{
|
||||||
printf("Can't create thread %d, error: %d\n",i,error);
|
printf("Can't create thread %d, error: %d\n",i,error);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
thread_count++;
|
thread_count++;
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thr_attr);
|
pthread_attr_destroy(&thr_attr);
|
||||||
pthread_mutex_lock(&LOCK_thread_count);
|
mysql_mutex_lock(&LOCK_thread_count);
|
||||||
thr_alarm_info(&alarm_info);
|
thr_alarm_info(&alarm_info);
|
||||||
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
|
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
|
||||||
alarm_info.active_alarms, alarm_info.max_used_alarms,
|
alarm_info.active_alarms, alarm_info.max_used_alarms,
|
||||||
alarm_info.next_alarm_time);
|
alarm_info.next_alarm_time);
|
||||||
while (thread_count)
|
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)
|
if (thread_count == 1)
|
||||||
{
|
{
|
||||||
printf("Calling end_thr_alarm. This should cancel the last thread\n");
|
printf("Calling end_thr_alarm. This should cancel the last thread\n");
|
||||||
end_thr_alarm(0);
|
end_thr_alarm(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
thr_alarm_info(&alarm_info);
|
thr_alarm_info(&alarm_info);
|
||||||
end_thr_alarm(1);
|
end_thr_alarm(1);
|
||||||
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
|
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
|
||||||
|
150
mysys/thr_lock.c
150
mysys/thr_lock.c
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB
|
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -94,7 +94,7 @@ enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE;
|
|||||||
LIST *thr_lock_thread_list; /* List of threads in use */
|
LIST *thr_lock_thread_list; /* List of threads in use */
|
||||||
ulong max_write_lock_count= ~(ulong) 0L;
|
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;
|
return &my_thread_var->suspend;
|
||||||
}
|
}
|
||||||
@ -316,16 +316,16 @@ void thr_lock_init(THR_LOCK *lock)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("thr_lock_init");
|
DBUG_ENTER("thr_lock_init");
|
||||||
bzero((char*) lock,sizeof(*lock));
|
bzero((char*) lock,sizeof(*lock));
|
||||||
pthread_mutex_init(&lock->mutex,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_THR_LOCK_mutex, &lock->mutex, MY_MUTEX_INIT_FAST);
|
||||||
lock->read.last= &lock->read.data;
|
lock->read.last= &lock->read.data;
|
||||||
lock->read_wait.last= &lock->read_wait.data;
|
lock->read_wait.last= &lock->read_wait.data;
|
||||||
lock->write_wait.last= &lock->write_wait.data;
|
lock->write_wait.last= &lock->write_wait.data;
|
||||||
lock->write.last= &lock->write.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;
|
lock->list.data=(void*) lock;
|
||||||
thr_lock_thread_list=list_add(thr_lock_thread_list,&lock->list);
|
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;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,10 +333,10 @@ void thr_lock_init(THR_LOCK *lock)
|
|||||||
void thr_lock_delete(THR_LOCK *lock)
|
void thr_lock_delete(THR_LOCK *lock)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("thr_lock_delete");
|
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);
|
thr_lock_thread_list=list_delete(thr_lock_thread_list,&lock->list);
|
||||||
pthread_mutex_unlock(&THR_LOCK_lock);
|
mysql_mutex_unlock(&THR_LOCK_lock);
|
||||||
pthread_mutex_destroy(&lock->mutex);
|
mysql_mutex_destroy(&lock->mutex);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
|
|||||||
my_bool in_wait_list)
|
my_bool in_wait_list)
|
||||||
{
|
{
|
||||||
struct st_my_thread_var *thread_var= my_thread_var;
|
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;
|
struct timespec wait_timeout;
|
||||||
enum enum_thr_lock_result result= THR_LOCK_ABORTED;
|
enum enum_thr_lock_result result= THR_LOCK_ABORTED;
|
||||||
my_bool can_deadlock= test(data->owner->info->n_cursors);
|
my_bool can_deadlock= test(data->owner->info->n_cursors);
|
||||||
@ -439,9 +439,9 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
|
|||||||
while (!thread_var->abort || in_wait_list)
|
while (!thread_var->abort || in_wait_list)
|
||||||
{
|
{
|
||||||
int rc= (can_deadlock ?
|
int rc= (can_deadlock ?
|
||||||
pthread_cond_timedwait(cond, &data->lock->mutex,
|
mysql_cond_timedwait(cond, &data->lock->mutex,
|
||||||
&wait_timeout) :
|
&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:
|
We must break the wait if one of the following occurs:
|
||||||
- the connection has been aborted (!thread_var->abort), but
|
- the connection has been aborted (!thread_var->abort), but
|
||||||
@ -497,13 +497,13 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
|
|||||||
(*data->lock->get_status)(data->status_param, 0);
|
(*data->lock->get_status)(data->status_param, 0);
|
||||||
check_locks(data->lock,"got wait_for_lock",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 */
|
/* 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_mutex= 0;
|
||||||
thread_var->current_cond= 0;
|
thread_var->current_cond= 0;
|
||||||
pthread_mutex_unlock(&thread_var->mutex);
|
mysql_mutex_unlock(&thread_var->mutex);
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
|
|||||||
data->cond=0; /* safety */
|
data->cond=0; /* safety */
|
||||||
data->type=lock_type;
|
data->type=lock_type;
|
||||||
data->owner= owner; /* Must be reset ! */
|
data->owner= owner; /* Must be reset ! */
|
||||||
pthread_mutex_lock(&lock->mutex);
|
mysql_mutex_lock(&lock->mutex);
|
||||||
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d",
|
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d",
|
||||||
(long) data, data->owner->info->thread_id,
|
(long) data, data->owner->info->thread_id,
|
||||||
(long) lock, (int) lock_type));
|
(long) lock, (int) lock_type));
|
||||||
@ -747,7 +747,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
|
|||||||
/* Can't get lock yet; Wait for it */
|
/* Can't get lock yet; Wait for it */
|
||||||
DBUG_RETURN(wait_for_lock(wait_queue, data, 0));
|
DBUG_RETURN(wait_for_lock(wait_queue, data, 0));
|
||||||
end:
|
end:
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,7 +769,7 @@ static inline void free_all_read_locks(THR_LOCK *lock,
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
pthread_cond_t *cond=data->cond;
|
mysql_cond_t *cond= data->cond;
|
||||||
if ((int) data->type == (int) TL_READ_NO_INSERT)
|
if ((int) data->type == (int) TL_READ_NO_INSERT)
|
||||||
{
|
{
|
||||||
if (using_concurrent_insert)
|
if (using_concurrent_insert)
|
||||||
@ -794,7 +794,7 @@ static inline void free_all_read_locks(THR_LOCK *lock,
|
|||||||
data->owner->info->thread_id));
|
data->owner->info->thread_id));
|
||||||
/* purecov: end */
|
/* purecov: end */
|
||||||
data->cond=0; /* Mark thread free */
|
data->cond=0; /* Mark thread free */
|
||||||
pthread_cond_signal(cond);
|
mysql_cond_signal(cond);
|
||||||
} while ((data=data->next));
|
} while ((data=data->next));
|
||||||
*lock->read_wait.last=0;
|
*lock->read_wait.last=0;
|
||||||
if (!lock->read_wait.data)
|
if (!lock->read_wait.data)
|
||||||
@ -811,7 +811,7 @@ void thr_unlock(THR_LOCK_DATA *data)
|
|||||||
DBUG_ENTER("thr_unlock");
|
DBUG_ENTER("thr_unlock");
|
||||||
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx",
|
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx",
|
||||||
(long) data, data->owner->info->thread_id, (long) lock));
|
(long) data, data->owner->info->thread_id, (long) lock));
|
||||||
pthread_mutex_lock(&lock->mutex);
|
mysql_mutex_lock(&lock->mutex);
|
||||||
check_locks(lock,"start of release lock",0);
|
check_locks(lock,"start of release lock",0);
|
||||||
|
|
||||||
if (((*data->prev)=data->next)) /* remove from lock-list */
|
if (((*data->prev)=data->next)) /* remove from lock-list */
|
||||||
@ -843,7 +843,7 @@ void thr_unlock(THR_LOCK_DATA *data)
|
|||||||
data->type=TL_UNLOCK; /* Mark unlocked */
|
data->type=TL_UNLOCK; /* Mark unlocked */
|
||||||
check_locks(lock,"after releasing lock",1);
|
check_locks(lock,"after releasing lock",1);
|
||||||
wake_up_waiters(lock);
|
wake_up_waiters(lock);
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,9 +902,9 @@ static void wake_up_waiters(THR_LOCK *lock)
|
|||||||
data->type, data->owner->info->thread_id));
|
data->type, data->owner->info->thread_id));
|
||||||
/* purecov: end */
|
/* purecov: end */
|
||||||
{
|
{
|
||||||
pthread_cond_t *cond=data->cond;
|
mysql_cond_t *cond= data->cond;
|
||||||
data->cond=0; /* Mark thread free */
|
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 ||
|
if (data->type != TL_WRITE_ALLOW_WRITE ||
|
||||||
!lock->write_wait.data ||
|
!lock->write_wait.data ||
|
||||||
@ -945,7 +945,7 @@ static void wake_up_waiters(THR_LOCK *lock)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
pthread_cond_t *cond=data->cond;
|
mysql_cond_t *cond= data->cond;
|
||||||
if (((*data->prev)=data->next)) /* remove from wait-list */
|
if (((*data->prev)=data->next)) /* remove from wait-list */
|
||||||
data->next->prev= data->prev;
|
data->next->prev= data->prev;
|
||||||
else
|
else
|
||||||
@ -955,7 +955,7 @@ static void wake_up_waiters(THR_LOCK *lock)
|
|||||||
lock->write.last= &data->next;
|
lock->write.last= &data->next;
|
||||||
data->next=0; /* Only one write lock */
|
data->next=0; /* Only one write lock */
|
||||||
data->cond=0; /* Mark thread free */
|
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 &&
|
} while (lock_type == TL_WRITE_ALLOW_WRITE &&
|
||||||
(data=lock->write_wait.data) &&
|
(data=lock->write_wait.data) &&
|
||||||
data->type == TL_WRITE_ALLOW_WRITE);
|
data->type == TL_WRITE_ALLOW_WRITE);
|
||||||
@ -1112,19 +1112,19 @@ void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock)
|
|||||||
{
|
{
|
||||||
THR_LOCK_DATA *data;
|
THR_LOCK_DATA *data;
|
||||||
DBUG_ENTER("thr_abort_locks");
|
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)
|
for (data=lock->read_wait.data; data ; data=data->next)
|
||||||
{
|
{
|
||||||
data->type=TL_UNLOCK; /* Mark killed */
|
data->type=TL_UNLOCK; /* Mark killed */
|
||||||
/* It's safe to signal the cond first: we're still holding the mutex. */
|
/* 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 */
|
data->cond=0; /* Removed from list */
|
||||||
}
|
}
|
||||||
for (data=lock->write_wait.data; data ; data=data->next)
|
for (data=lock->write_wait.data; data ; data=data->next)
|
||||||
{
|
{
|
||||||
data->type=TL_UNLOCK;
|
data->type=TL_UNLOCK;
|
||||||
pthread_cond_signal(data->cond);
|
mysql_cond_signal(data->cond);
|
||||||
data->cond=0;
|
data->cond=0;
|
||||||
}
|
}
|
||||||
lock->read_wait.last= &lock->read_wait.data;
|
lock->read_wait.last= &lock->read_wait.data;
|
||||||
@ -1132,7 +1132,7 @@ void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock)
|
|||||||
lock->read_wait.data=lock->write_wait.data=0;
|
lock->read_wait.data=lock->write_wait.data=0;
|
||||||
if (upgrade_lock && lock->write.data)
|
if (upgrade_lock && lock->write.data)
|
||||||
lock->write.data->type=TL_WRITE_ONLY;
|
lock->write.data->type=TL_WRITE_ONLY;
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,7 +1149,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
|
|||||||
my_bool found= FALSE;
|
my_bool found= FALSE;
|
||||||
DBUG_ENTER("thr_abort_locks_for_thread");
|
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)
|
for (data= lock->read_wait.data; data ; data= data->next)
|
||||||
{
|
{
|
||||||
if (data->owner->info->thread_id == thread_id) /* purecov: tested */
|
if (data->owner->info->thread_id == thread_id) /* purecov: tested */
|
||||||
@ -1158,7 +1158,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
|
|||||||
data->type= TL_UNLOCK; /* Mark killed */
|
data->type= TL_UNLOCK; /* Mark killed */
|
||||||
/* It's safe to signal the cond first: we're still holding the mutex. */
|
/* It's safe to signal the cond first: we're still holding the mutex. */
|
||||||
found= TRUE;
|
found= TRUE;
|
||||||
pthread_cond_signal(data->cond);
|
mysql_cond_signal(data->cond);
|
||||||
data->cond= 0; /* Removed from list */
|
data->cond= 0; /* Removed from list */
|
||||||
|
|
||||||
if (((*data->prev)= data->next))
|
if (((*data->prev)= data->next))
|
||||||
@ -1174,7 +1174,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
|
|||||||
DBUG_PRINT("info",("Aborting write-wait lock"));
|
DBUG_PRINT("info",("Aborting write-wait lock"));
|
||||||
data->type= TL_UNLOCK;
|
data->type= TL_UNLOCK;
|
||||||
found= TRUE;
|
found= TRUE;
|
||||||
pthread_cond_signal(data->cond);
|
mysql_cond_signal(data->cond);
|
||||||
data->cond= 0;
|
data->cond= 0;
|
||||||
|
|
||||||
if (((*data->prev)= data->next))
|
if (((*data->prev)= data->next))
|
||||||
@ -1184,7 +1184,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wake_up_waiters(lock);
|
wake_up_waiters(lock);
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_RETURN(found);
|
DBUG_RETURN(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,7 +1233,7 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
|
|||||||
#endif
|
#endif
|
||||||
DBUG_ENTER("thr_downgrade_write_only_lock");
|
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 == TL_WRITE_ONLY);
|
||||||
DBUG_ASSERT(old_lock_type > new_lock_type);
|
DBUG_ASSERT(old_lock_type > new_lock_type);
|
||||||
in_data->type= new_lock_type;
|
in_data->type= new_lock_type;
|
||||||
@ -1325,7 +1325,7 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
|
|||||||
next= data->next;
|
next= data->next;
|
||||||
if (start_writers && data->type == new_lock_type)
|
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.
|
It is ok to start this waiter.
|
||||||
Move from being first in wait queue to be last in write queue.
|
Move from being first in wait queue to be last in write queue.
|
||||||
@ -1339,7 +1339,7 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
|
|||||||
data->next= 0;
|
data->next= 0;
|
||||||
check_locks(lock, "Started write lock after downgrade",0);
|
check_locks(lock, "Started write lock after downgrade",0);
|
||||||
data->cond= 0;
|
data->cond= 0;
|
||||||
pthread_cond_signal(cond);
|
mysql_cond_signal(cond);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1379,7 +1379,7 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
|
|||||||
if (new_lock_type != TL_WRITE_ALLOW_READ ||
|
if (new_lock_type != TL_WRITE_ALLOW_READ ||
|
||||||
data->type != TL_READ_NO_INSERT)
|
data->type != TL_READ_NO_INSERT)
|
||||||
{
|
{
|
||||||
pthread_cond_t *cond= data->cond;
|
mysql_cond_t *cond= data->cond;
|
||||||
if (((*data->prev)= data->next))
|
if (((*data->prev)= data->next))
|
||||||
data->next->prev= data->prev;
|
data->next->prev= data->prev;
|
||||||
else
|
else
|
||||||
@ -1392,13 +1392,13 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
|
|||||||
lock->read_no_write_count++;
|
lock->read_no_write_count++;
|
||||||
check_locks(lock, "Started read lock after downgrade",0);
|
check_locks(lock, "Started read lock after downgrade",0);
|
||||||
data->cond= 0;
|
data->cond= 0;
|
||||||
pthread_cond_signal(cond);
|
mysql_cond_signal(cond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check_locks(lock,"after starting waiters after downgrading lock",0);
|
check_locks(lock,"after starting waiters after downgrading lock",0);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1410,10 +1410,10 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
|
|||||||
THR_LOCK *lock=data->lock;
|
THR_LOCK *lock=data->lock;
|
||||||
DBUG_ENTER("thr_upgrade_write_delay_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)
|
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 */
|
DBUG_RETURN(data->type == TL_UNLOCK); /* Test if Aborted */
|
||||||
}
|
}
|
||||||
check_locks(lock,"before upgrading lock",0);
|
check_locks(lock,"before upgrading lock",0);
|
||||||
@ -1427,7 +1427,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
|
|||||||
{ /* We have the lock */
|
{ /* We have the lock */
|
||||||
if (data->lock->get_status)
|
if (data->lock->get_status)
|
||||||
(*data->lock->get_status)(data->status_param, 0);
|
(*data->lock->get_status)(data->status_param, 0);
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1460,10 +1460,10 @@ my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
|
|||||||
enum thr_lock_type write_lock_type;
|
enum thr_lock_type write_lock_type;
|
||||||
DBUG_ENTER("thr_reschedule_write_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 */
|
if (!lock->read_wait.data) /* No waiting read locks */
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1485,7 +1485,7 @@ my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
|
|||||||
lock->write_wait.data=data;
|
lock->write_wait.data=data;
|
||||||
free_all_read_locks(lock,0);
|
free_all_read_locks(lock,0);
|
||||||
|
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
DBUG_RETURN(thr_upgrade_write_delay_lock(data, write_lock_type));
|
DBUG_RETURN(thr_upgrade_write_delay_lock(data, write_lock_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1520,13 +1520,13 @@ void thr_print_locks(void)
|
|||||||
LIST *list;
|
LIST *list;
|
||||||
uint count=0;
|
uint count=0;
|
||||||
|
|
||||||
pthread_mutex_lock(&THR_LOCK_lock);
|
mysql_mutex_lock(&THR_LOCK_lock);
|
||||||
puts("Current locks:");
|
puts("Current locks:");
|
||||||
for (list= thr_lock_thread_list; list && count++ < MAX_THREADS;
|
for (list= thr_lock_thread_list; list && count++ < MAX_THREADS;
|
||||||
list= list_rest(list))
|
list= list_rest(list))
|
||||||
{
|
{
|
||||||
THR_LOCK *lock=(THR_LOCK*) list->data;
|
THR_LOCK *lock=(THR_LOCK*) list->data;
|
||||||
pthread_mutex_lock(&lock->mutex);
|
mysql_mutex_lock(&lock->mutex);
|
||||||
printf("lock: 0x%lx:",(ulong) lock);
|
printf("lock: 0x%lx:",(ulong) lock);
|
||||||
if ((lock->write_wait.data || lock->read_wait.data) &&
|
if ((lock->write_wait.data || lock->read_wait.data) &&
|
||||||
(! lock->read.data && ! lock->write.data))
|
(! lock->read.data && ! lock->write.data))
|
||||||
@ -1544,11 +1544,11 @@ void thr_print_locks(void)
|
|||||||
thr_print_lock("write_wait",&lock->write_wait);
|
thr_print_lock("write_wait",&lock->write_wait);
|
||||||
thr_print_lock("read",&lock->read);
|
thr_print_lock("read",&lock->read);
|
||||||
thr_print_lock("read_wait",&lock->read_wait);
|
thr_print_lock("read_wait",&lock->read_wait);
|
||||||
pthread_mutex_unlock(&lock->mutex);
|
mysql_mutex_unlock(&lock->mutex);
|
||||||
puts("");
|
puts("");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
pthread_mutex_unlock(&THR_LOCK_lock);
|
mysql_mutex_unlock(&THR_LOCK_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* THREAD */
|
#endif /* THREAD */
|
||||||
@ -1609,8 +1609,8 @@ int lock_counts[]= {sizeof(test_0)/sizeof(struct st_test),
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static pthread_cond_t COND_thread_count;
|
static mysql_cond_t COND_thread_count;
|
||||||
static pthread_mutex_t LOCK_thread_count;
|
static mysql_mutex_t LOCK_thread_count;
|
||||||
static uint thread_count;
|
static uint thread_count;
|
||||||
static ulong sum=0;
|
static ulong sum=0;
|
||||||
|
|
||||||
@ -1662,7 +1662,7 @@ static void *test_thread(void *arg)
|
|||||||
data[i].type= tests[param][i].lock_type;
|
data[i].type= tests[param][i].lock_type;
|
||||||
}
|
}
|
||||||
thr_multi_lock(multi_locks, lock_counts[param], &owner);
|
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 */
|
int tmp=rand() & 7; /* Do something from 0-2 sec */
|
||||||
if (tmp == 0)
|
if (tmp == 0)
|
||||||
@ -1676,16 +1676,16 @@ static void *test_thread(void *arg)
|
|||||||
sum+=k;
|
sum+=k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
thr_multi_unlock(multi_locks,lock_counts[param]);
|
thr_multi_unlock(multi_locks,lock_counts[param]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Thread %s (%d) ended\n",my_thread_name(),param); fflush(stdout);
|
printf("Thread %s (%d) ended\n",my_thread_name(),param); fflush(stdout);
|
||||||
thr_print_locks();
|
thr_print_locks();
|
||||||
pthread_mutex_lock(&LOCK_thread_count);
|
mysql_mutex_lock(&LOCK_thread_count);
|
||||||
thread_count--;
|
thread_count--;
|
||||||
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
mysql_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
free((uchar*) arg);
|
free((uchar*) arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1702,15 +1702,15 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||||||
|
|
||||||
printf("Main thread: %s\n",my_thread_name());
|
printf("Main thread: %s\n",my_thread_name());
|
||||||
|
|
||||||
if ((error=pthread_cond_init(&COND_thread_count,NULL)))
|
if ((error= mysql_cond_init(0, &COND_thread_count, NULL)))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Got error: %d from pthread_cond_init (errno: %d)",
|
fprintf(stderr, "Got error: %d from mysql_cond_init (errno: %d)",
|
||||||
error,errno);
|
error,errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ((error=pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST)))
|
if ((error= mysql_mutex_init(0, &LOCK_thread_count, MY_MUTEX_INIT_FAST)))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Got error: %d from pthread_cond_init (errno: %d)",
|
fprintf(stderr, "Got error: %d from mysql_cond_init (errno: %d)",
|
||||||
error,errno);
|
error,errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -1752,33 +1752,35 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||||||
param=(int*) malloc(sizeof(int));
|
param=(int*) malloc(sizeof(int));
|
||||||
*param=i;
|
*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);
|
error, errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ((error=pthread_create(&tid,&thr_attr,test_thread,(void*) param)))
|
if ((error= mysql_thread_create(0,
|
||||||
|
&tid, &thr_attr, test_thread,
|
||||||
|
(void*) param)))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Got error: %d from pthread_create (errno: %d)\n",
|
fprintf(stderr, "Got error: %d from mysql_thread_create (errno: %d)\n",
|
||||||
error,errno);
|
error, errno);
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
thread_count++;
|
thread_count++;
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thr_attr);
|
pthread_attr_destroy(&thr_attr);
|
||||||
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\n",error);
|
fprintf(stderr, "Got error: %d from mysql_mutex_lock\n", error);
|
||||||
while (thread_count)
|
while (thread_count)
|
||||||
{
|
{
|
||||||
if ((error=pthread_cond_wait(&COND_thread_count,&LOCK_thread_count)))
|
if ((error= mysql_cond_wait(&COND_thread_count, &LOCK_thread_count)))
|
||||||
fprintf(stderr,"Got error: %d from pthread_cond_wait\n",error);
|
fprintf(stderr, "Got error: %d from mysql_cond_wait\n", error);
|
||||||
}
|
}
|
||||||
if ((error=pthread_mutex_unlock(&LOCK_thread_count)))
|
if ((error= mysql_mutex_unlock(&LOCK_thread_count)))
|
||||||
fprintf(stderr,"Got error: %d from pthread_mutex_unlock\n",error);
|
fprintf(stderr, "Got error: %d from mysql_mutex_unlock\n", error);
|
||||||
for (i=0 ; i < (int) array_elements(locks) ; i++)
|
for (i=0 ; i < (int) array_elements(locks) ; i++)
|
||||||
thr_lock_delete(locks+i);
|
thr_lock_delete(locks+i);
|
||||||
#ifdef EXTRA_DEBUG
|
#ifdef EXTRA_DEBUG
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -39,6 +39,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif /* DO_NOT_REMOVE_THREAD_WRAPPERS */
|
#endif /* DO_NOT_REMOVE_THREAD_WRAPPERS */
|
||||||
|
|
||||||
|
/* Not instrumented */
|
||||||
static pthread_mutex_t THR_LOCK_mutex;
|
static pthread_mutex_t THR_LOCK_mutex;
|
||||||
static ulong safe_mutex_count= 0; /* Number of mutexes created */
|
static ulong safe_mutex_count= 0; /* Number of mutexes created */
|
||||||
#ifdef SAFE_MUTEX_DETECT_DESTROY
|
#ifdef SAFE_MUTEX_DETECT_DESTROY
|
||||||
@ -85,7 +86,9 @@ int safe_mutex_init(safe_mutex_t *mp,
|
|||||||
pthread_mutex_unlock(&THR_LOCK_mutex);
|
pthread_mutex_unlock(&THR_LOCK_mutex);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
thread_safe_increment(safe_mutex_count, &THR_LOCK_mutex);
|
pthread_mutex_lock(&THR_LOCK_mutex);
|
||||||
|
safe_mutex_count++;
|
||||||
|
pthread_mutex_unlock(&THR_LOCK_mutex);
|
||||||
#endif /* SAFE_MUTEX_DETECT_DESTROY */
|
#endif /* SAFE_MUTEX_DETECT_DESTROY */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -344,7 +347,9 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
|
|||||||
mp->info= NULL; /* Get crash if double free */
|
mp->info= NULL; /* Get crash if double free */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
thread_safe_sub(safe_mutex_count, 1, &THR_LOCK_mutex);
|
pthread_mutex_lock(&THR_LOCK_mutex);
|
||||||
|
safe_mutex_count--;
|
||||||
|
pthread_mutex_unlock(&THR_LOCK_mutex);
|
||||||
#endif /* SAFE_MUTEX_DETECT_DESTROY */
|
#endif /* SAFE_MUTEX_DETECT_DESTROY */
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (C) 2007 Google Inc.
|
/* Copyright (C) 2007 Google Inc.
|
||||||
Copyright (C) 2008 MySQL AB
|
Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -64,7 +64,7 @@ static int gettimeofday(struct timeval *tv, void *tz)
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
ActiveTranx::ActiveTranx(int max_connections,
|
ActiveTranx::ActiveTranx(int max_connections,
|
||||||
pthread_mutex_t *lock,
|
mysql_mutex_t *lock,
|
||||||
unsigned long trace_level)
|
unsigned long trace_level)
|
||||||
: Trace(trace_level), num_transactions_(max_connections),
|
: Trace(trace_level), num_transactions_(max_connections),
|
||||||
num_entries_(max_connections << 1),
|
num_entries_(max_connections << 1),
|
||||||
@ -416,8 +416,10 @@ int ReplSemiSyncMaster::initObject()
|
|||||||
max_transactions_ = (int)max_connections;
|
max_transactions_ = (int)max_connections;
|
||||||
|
|
||||||
/* Mutex initialization can only be done after MY_INIT(). */
|
/* Mutex initialization can only be done after MY_INIT(). */
|
||||||
pthread_mutex_init(&LOCK_binlog_, MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_ss_mutex_LOCK_binlog_,
|
||||||
pthread_cond_init(&COND_binlog_send_, NULL);
|
&LOCK_binlog_, MY_MUTEX_INIT_FAST);
|
||||||
|
mysql_cond_init(key_ss_cond_COND_binlog_send_,
|
||||||
|
&COND_binlog_send_, NULL);
|
||||||
|
|
||||||
if (rpl_semi_sync_master_enabled)
|
if (rpl_semi_sync_master_enabled)
|
||||||
result = enableMaster();
|
result = enableMaster();
|
||||||
@ -494,8 +496,8 @@ ReplSemiSyncMaster::~ReplSemiSyncMaster()
|
|||||||
{
|
{
|
||||||
if (init_done_)
|
if (init_done_)
|
||||||
{
|
{
|
||||||
pthread_mutex_destroy(&LOCK_binlog_);
|
mysql_mutex_destroy(&LOCK_binlog_);
|
||||||
pthread_cond_destroy(&COND_binlog_send_);
|
mysql_cond_destroy(&COND_binlog_send_);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete active_tranxs_;
|
delete active_tranxs_;
|
||||||
@ -503,17 +505,17 @@ ReplSemiSyncMaster::~ReplSemiSyncMaster()
|
|||||||
|
|
||||||
void ReplSemiSyncMaster::lock()
|
void ReplSemiSyncMaster::lock()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_binlog_);
|
mysql_mutex_lock(&LOCK_binlog_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplSemiSyncMaster::unlock()
|
void ReplSemiSyncMaster::unlock()
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_binlog_);
|
mysql_mutex_unlock(&LOCK_binlog_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplSemiSyncMaster::cond_broadcast()
|
void ReplSemiSyncMaster::cond_broadcast()
|
||||||
{
|
{
|
||||||
pthread_cond_broadcast(&COND_binlog_send_);
|
mysql_cond_broadcast(&COND_binlog_send_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time)
|
int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time)
|
||||||
@ -522,8 +524,8 @@ int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time)
|
|||||||
int wait_res;
|
int wait_res;
|
||||||
|
|
||||||
function_enter(kWho);
|
function_enter(kWho);
|
||||||
wait_res = pthread_cond_timedwait(&COND_binlog_send_,
|
wait_res= mysql_cond_timedwait(&COND_binlog_send_,
|
||||||
&LOCK_binlog_, wait_time);
|
&LOCK_binlog_, wait_time);
|
||||||
return function_exit(kWho, wait_res);
|
return function_exit(kWho, wait_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* Copyright (C) 2007 Google Inc.
|
/* Copyright (C) 2007 Google Inc.
|
||||||
Copyright (C) 2008 MySQL AB
|
Copyright (C) 2008 MySQL AB
|
||||||
|
Copyright (C) 2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -20,6 +21,11 @@
|
|||||||
|
|
||||||
#include "semisync.h"
|
#include "semisync.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
extern PSI_mutex_key key_ss_mutex_LOCK_binlog_;
|
||||||
|
extern PSI_cond_key key_ss_cond_COND_binlog_send_;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class manages memory for active transaction list.
|
This class manages memory for active transaction list.
|
||||||
|
|
||||||
@ -49,7 +55,7 @@ private:
|
|||||||
|
|
||||||
int num_transactions_; /* maximum transactions */
|
int num_transactions_; /* maximum transactions */
|
||||||
int num_entries_; /* maximum hash table entries */
|
int num_entries_; /* maximum hash table entries */
|
||||||
pthread_mutex_t *lock_; /* mutex lock */
|
mysql_mutex_t *lock_; /* mutex lock */
|
||||||
|
|
||||||
inline void assert_lock_owner();
|
inline void assert_lock_owner();
|
||||||
|
|
||||||
@ -74,7 +80,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActiveTranx(int max_connections, pthread_mutex_t *lock,
|
ActiveTranx(int max_connections, mysql_mutex_t *lock,
|
||||||
unsigned long trace_level);
|
unsigned long trace_level);
|
||||||
~ActiveTranx();
|
~ActiveTranx();
|
||||||
|
|
||||||
@ -124,14 +130,14 @@ class ReplSemiSyncMaster
|
|||||||
/* This cond variable is signaled when enough binlog has been sent to slave,
|
/* This cond variable is signaled when enough binlog has been sent to slave,
|
||||||
* so that a waiting trx can return the 'ok' to the client for a commit.
|
* so that a waiting trx can return the 'ok' to the client for a commit.
|
||||||
*/
|
*/
|
||||||
pthread_cond_t COND_binlog_send_;
|
mysql_cond_t COND_binlog_send_;
|
||||||
|
|
||||||
/* Mutex that protects the following state variables and the active
|
/* Mutex that protects the following state variables and the active
|
||||||
* transaction list.
|
* transaction list.
|
||||||
* Under no cirumstances we can acquire mysql_bin_log.LOCK_log if we are
|
* Under no cirumstances we can acquire mysql_bin_log.LOCK_log if we are
|
||||||
* already holding LOCK_binlog_ because it can cause deadlocks.
|
* already holding LOCK_binlog_ because it can cause deadlocks.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_t LOCK_binlog_;
|
mysql_mutex_t LOCK_binlog_;
|
||||||
|
|
||||||
/* This is set to true when reply_file_name_ contains meaningful data. */
|
/* This is set to true when reply_file_name_ contains meaningful data. */
|
||||||
bool reply_file_name_inited_;
|
bool reply_file_name_inited_;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (C) 2007 Google Inc.
|
/* Copyright (C) 2007 Google Inc.
|
||||||
Copyright (C) 2008 MySQL AB
|
Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -334,9 +334,43 @@ static SHOW_VAR semi_sync_master_status_vars[]= {
|
|||||||
{NULL, NULL, SHOW_LONG},
|
{NULL, NULL, SHOW_LONG},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
PSI_mutex_key key_ss_mutex_LOCK_binlog_;
|
||||||
|
|
||||||
|
static PSI_mutex_info all_semisync_mutexes[]=
|
||||||
|
{
|
||||||
|
{ &key_ss_mutex_LOCK_binlog_, "LOCK_binlog_", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
PSI_cond_key key_ss_cond_COND_binlog_send_;
|
||||||
|
|
||||||
|
static PSI_cond_info all_semisync_conds[]=
|
||||||
|
{
|
||||||
|
{ &key_ss_cond_COND_binlog_send_, "COND_binlog_send_", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void init_semisync_psi_keys(void)
|
||||||
|
{
|
||||||
|
const char* category= "semisync";
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (PSI_server == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count= array_elements(all_semisync_mutexes);
|
||||||
|
PSI_server->register_mutex(category, all_semisync_mutexes, count);
|
||||||
|
|
||||||
|
count= array_elements(all_semisync_conds);
|
||||||
|
PSI_server->register_cond(category, all_semisync_conds, count);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PSI_INTERFACE */
|
||||||
|
|
||||||
static int semi_sync_master_plugin_init(void *p)
|
static int semi_sync_master_plugin_init(void *p)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
init_semisync_psi_keys();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (repl_semisync.initObject())
|
if (repl_semisync.initObject())
|
||||||
return 1;
|
return 1;
|
||||||
if (register_trans_observer(&trans_observer, p))
|
if (register_trans_observer(&trans_observer, p))
|
||||||
|
@ -221,14 +221,14 @@
|
|||||||
There are quite a few places in MySQL, where we use a synchronization
|
There are quite a few places in MySQL, where we use a synchronization
|
||||||
pattern like this:
|
pattern like this:
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
thd->enter_cond(&condition_variable, &mutex, new_message);
|
thd->enter_cond(&condition_variable, &mutex, new_message);
|
||||||
#if defined(ENABLE_DEBUG_SYNC)
|
#if defined(ENABLE_DEBUG_SYNC)
|
||||||
if (!thd->killed && !end_of_wait_condition)
|
if (!thd->killed && !end_of_wait_condition)
|
||||||
DEBUG_SYNC(thd, "sync_point_name");
|
DEBUG_SYNC(thd, "sync_point_name");
|
||||||
#endif
|
#endif
|
||||||
while (!thd->killed && !end_of_wait_condition)
|
while (!thd->killed && !end_of_wait_condition)
|
||||||
pthread_cond_wait(&condition_variable, &mutex);
|
mysql_cond_wait(&condition_variable, &mutex);
|
||||||
thd->exit_cond(old_message);
|
thd->exit_cond(old_message);
|
||||||
|
|
||||||
Here some explanations:
|
Here some explanations:
|
||||||
@ -264,12 +264,12 @@
|
|||||||
|
|
||||||
while (!thd->killed && !end_of_wait_condition)
|
while (!thd->killed && !end_of_wait_condition)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
thd->enter_cond(&condition_variable, &mutex, new_message);
|
thd->enter_cond(&condition_variable, &mutex, new_message);
|
||||||
if (!thd->killed [&& !end_of_wait_condition])
|
if (!thd->killed [&& !end_of_wait_condition])
|
||||||
{
|
{
|
||||||
[DEBUG_SYNC(thd, "sync_point_name");]
|
[DEBUG_SYNC(thd, "sync_point_name");]
|
||||||
pthread_cond_wait(&condition_variable, &mutex);
|
mysql_cond_wait(&condition_variable, &mutex);
|
||||||
}
|
}
|
||||||
thd->exit_cond(old_message);
|
thd->exit_cond(old_message);
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@
|
|||||||
before sleeping, we hold the mutex, which is registered in mysys_var.
|
before sleeping, we hold the mutex, which is registered in mysys_var.
|
||||||
The killing thread would try to acquire the mutex before signaling
|
The killing thread would try to acquire the mutex before signaling
|
||||||
the condition variable. Since the mutex is only released implicitly in
|
the condition variable. Since the mutex is only released implicitly in
|
||||||
pthread_cond_wait(), the signaling happens at the right place. We
|
mysql_cond_wait(), the signaling happens at the right place. We
|
||||||
have a safe synchronization.
|
have a safe synchronization.
|
||||||
|
|
||||||
=== Co-work with the DBUG facility ===
|
=== Co-work with the DBUG facility ===
|
||||||
@ -373,8 +373,8 @@ struct st_debug_sync_control
|
|||||||
struct st_debug_sync_globals
|
struct st_debug_sync_globals
|
||||||
{
|
{
|
||||||
String ds_signal; /* signal variable */
|
String ds_signal; /* signal variable */
|
||||||
pthread_cond_t ds_cond; /* condition variable */
|
mysql_cond_t ds_cond; /* condition variable */
|
||||||
pthread_mutex_t ds_mutex; /* mutex variable */
|
mysql_mutex_t ds_mutex; /* mutex variable */
|
||||||
ulonglong dsp_hits; /* statistics */
|
ulonglong dsp_hits; /* statistics */
|
||||||
ulonglong dsp_executed; /* statistics */
|
ulonglong dsp_executed; /* statistics */
|
||||||
ulonglong dsp_max_active; /* statistics */
|
ulonglong dsp_max_active; /* statistics */
|
||||||
@ -425,6 +425,37 @@ static void debug_sync_C_callback(const char *sync_point_name,
|
|||||||
debug_sync(current_thd, sync_point_name, name_len);
|
debug_sync(current_thd, sync_point_name, name_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
static PSI_mutex_key key_debug_sync_globals_ds_mutex;
|
||||||
|
|
||||||
|
static PSI_mutex_info all_debug_sync_mutexes[]=
|
||||||
|
{
|
||||||
|
{ &key_debug_sync_globals_ds_mutex, "DEBUG_SYNC::mutex", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static PSI_cond_key key_debug_sync_globals_ds_cond;
|
||||||
|
|
||||||
|
static PSI_cond_info all_debug_sync_conds[]=
|
||||||
|
{
|
||||||
|
{ &key_debug_sync_globals_ds_cond, "DEBUG_SYNC::cond", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void init_debug_sync_psi_keys(void)
|
||||||
|
{
|
||||||
|
const char* category= "sql";
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (PSI_server == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count= array_elements(all_debug_sync_mutexes);
|
||||||
|
PSI_server->register_mutex(category, all_debug_sync_mutexes, count);
|
||||||
|
|
||||||
|
count= array_elements(all_debug_sync_conds);
|
||||||
|
PSI_server->register_cond(category, all_debug_sync_conds, count);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PSI_INTERFACE */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the debug sync facility at server start.
|
Initialize the debug sync facility at server start.
|
||||||
@ -438,15 +469,21 @@ int debug_sync_init(void)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("debug_sync_init");
|
DBUG_ENTER("debug_sync_init");
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
init_debug_sync_psi_keys();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (opt_debug_sync_timeout)
|
if (opt_debug_sync_timeout)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Initialize the global variables. */
|
/* Initialize the global variables. */
|
||||||
debug_sync_global.ds_signal.length(0);
|
debug_sync_global.ds_signal.length(0);
|
||||||
if ((rc= pthread_cond_init(&debug_sync_global.ds_cond, NULL)) ||
|
if ((rc= mysql_cond_init(key_debug_sync_globals_ds_cond,
|
||||||
(rc= pthread_mutex_init(&debug_sync_global.ds_mutex,
|
&debug_sync_global.ds_cond, NULL)) ||
|
||||||
MY_MUTEX_INIT_FAST)))
|
(rc= mysql_mutex_init(key_debug_sync_globals_ds_mutex,
|
||||||
|
&debug_sync_global.ds_mutex,
|
||||||
|
MY_MUTEX_INIT_FAST)))
|
||||||
DBUG_RETURN(rc); /* purecov: inspected */
|
DBUG_RETURN(rc); /* purecov: inspected */
|
||||||
|
|
||||||
/* Set the call back pointer in C files. */
|
/* Set the call back pointer in C files. */
|
||||||
@ -476,8 +513,8 @@ void debug_sync_end(void)
|
|||||||
|
|
||||||
/* Destroy the global variables. */
|
/* Destroy the global variables. */
|
||||||
debug_sync_global.ds_signal.free();
|
debug_sync_global.ds_signal.free();
|
||||||
(void) pthread_cond_destroy(&debug_sync_global.ds_cond);
|
mysql_cond_destroy(&debug_sync_global.ds_cond);
|
||||||
(void) pthread_mutex_destroy(&debug_sync_global.ds_mutex);
|
mysql_mutex_destroy(&debug_sync_global.ds_mutex);
|
||||||
|
|
||||||
/* Print statistics. */
|
/* Print statistics. */
|
||||||
{
|
{
|
||||||
@ -585,12 +622,12 @@ void debug_sync_end_thread(THD *thd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Statistics. */
|
/* 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_hits+= ds_control->dsp_hits;
|
||||||
debug_sync_global.dsp_executed+= ds_control->dsp_executed;
|
debug_sync_global.dsp_executed+= ds_control->dsp_executed;
|
||||||
if (debug_sync_global.dsp_max_active < ds_control->dsp_max_active)
|
if (debug_sync_global.dsp_max_active < ds_control->dsp_max_active)
|
||||||
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));
|
my_free(ds_control, MYF(0));
|
||||||
thd->debug_sync_control= NULL;
|
thd->debug_sync_control= NULL;
|
||||||
@ -824,9 +861,9 @@ static void debug_sync_reset(THD *thd)
|
|||||||
ds_control->ds_active= 0;
|
ds_control->ds_active= 0;
|
||||||
|
|
||||||
/* Clear the global signal. */
|
/* 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);
|
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;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
@ -1659,7 +1696,7 @@ uchar *sys_var_debug_sync::value_ptr(THD *thd,
|
|||||||
static char on[]= "ON - current signal: '";
|
static char on[]= "ON - current signal: '";
|
||||||
|
|
||||||
// Ensure exclusive access to debug_sync_global.ds_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' */ +
|
size_t lgt= (sizeof(on) /* includes '\0' */ +
|
||||||
debug_sync_global.ds_signal.length() + 1 /* for '\'' */);
|
debug_sync_global.ds_signal.length() + 1 /* for '\'' */);
|
||||||
@ -1676,7 +1713,7 @@ uchar *sys_var_debug_sync::value_ptr(THD *thd,
|
|||||||
*(vptr++)= '\'';
|
*(vptr++)= '\'';
|
||||||
*vptr= '\0'; /* We have one byte reserved for the worst case. */
|
*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
|
else
|
||||||
{
|
{
|
||||||
@ -1744,7 +1781,7 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
|
|||||||
read access too, to create a memory barrier in order to avoid that
|
read access too, to create a memory barrier in order to avoid that
|
||||||
threads just reads an old cached version of the signal.
|
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())
|
if (action->signal.length())
|
||||||
{
|
{
|
||||||
@ -1758,15 +1795,15 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
|
|||||||
debug_sync_emergency_disable(); /* purecov: tested */
|
debug_sync_emergency_disable(); /* purecov: tested */
|
||||||
}
|
}
|
||||||
/* Wake threads waiting in a sync point. */
|
/* 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'",
|
DBUG_PRINT("debug_sync_exec", ("signal '%s' at: '%s'",
|
||||||
sig_emit, dsp_name));
|
sig_emit, dsp_name));
|
||||||
} /* end if (action->signal.length()) */
|
} /* end if (action->signal.length()) */
|
||||||
|
|
||||||
if (action->wait_for.length())
|
if (action->wait_for.length())
|
||||||
{
|
{
|
||||||
pthread_mutex_t *old_mutex;
|
mysql_mutex_t *old_mutex;
|
||||||
pthread_cond_t *old_cond;
|
mysql_cond_t *old_cond;
|
||||||
int error= 0;
|
int error= 0;
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
|
|
||||||
@ -1797,9 +1834,9 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
|
|||||||
while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for) &&
|
while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for) &&
|
||||||
!thd->killed && opt_debug_sync_timeout)
|
!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,
|
&debug_sync_global.ds_mutex,
|
||||||
&abstime);
|
&abstime);
|
||||||
DBUG_EXECUTE("debug_sync", {
|
DBUG_EXECUTE("debug_sync", {
|
||||||
/* Functions as DBUG_PRINT args can change keyword and line nr. */
|
/* Functions as DBUG_PRINT args can change keyword and line nr. */
|
||||||
const char *sig_glob= debug_sync_global.ds_signal.c_ptr();
|
const char *sig_glob= debug_sync_global.ds_signal.c_ptr();
|
||||||
@ -1832,18 +1869,17 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
|
|||||||
protected mutex must always unlocked _before_ mysys_var->mutex
|
protected mutex must always unlocked _before_ mysys_var->mutex
|
||||||
is locked. (See comment in THD::exit_cond().)
|
is locked. (See comment in THD::exit_cond().)
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&debug_sync_global.ds_mutex);
|
mysql_mutex_unlock(&debug_sync_global.ds_mutex);
|
||||||
pthread_mutex_lock(&thd->mysys_var->mutex);
|
mysql_mutex_lock(&thd->mysys_var->mutex);
|
||||||
thd->mysys_var->current_mutex= old_mutex;
|
thd->mysys_var->current_mutex= old_mutex;
|
||||||
thd->mysys_var->current_cond= old_cond;
|
thd->mysys_var->current_cond= old_cond;
|
||||||
thd_proc_info(thd, old_proc_info);
|
thd_proc_info(thd, old_proc_info);
|
||||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
mysql_mutex_unlock(&thd->mysys_var->mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* In case we don't wait, we just release the mutex. */
|
/* In case we don't wait, we just release the mutex. */
|
||||||
pthread_mutex_unlock(&debug_sync_global.ds_mutex);
|
mysql_mutex_unlock(&debug_sync_global.ds_mutex);
|
||||||
} /* end if (action->wait_for.length()) */
|
} /* end if (action->wait_for.length()) */
|
||||||
|
|
||||||
} /* end if (action->execute) */
|
} /* end if (action->execute) */
|
||||||
|
@ -6904,7 +6904,7 @@ int ndbcluster_drop_database_impl(const char *path)
|
|||||||
while ((tabname=it++))
|
while ((tabname=it++))
|
||||||
{
|
{
|
||||||
tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1);
|
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(0, ndb, full_path, dbname, tabname))
|
if (ha_ndbcluster::delete_table(0, ndb, full_path, dbname, tabname))
|
||||||
{
|
{
|
||||||
const NdbError err= dict->getNdbError();
|
const NdbError err= dict->getNdbError();
|
||||||
@ -6914,7 +6914,7 @@ int ndbcluster_drop_database_impl(const char *path)
|
|||||||
ret= ndb_to_mysql_error(&err);
|
ret= ndb_to_mysql_error(&err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(ret);
|
DBUG_RETURN(ret);
|
||||||
}
|
}
|
||||||
@ -7067,7 +7067,7 @@ int ndbcluster_find_all_files(THD *thd)
|
|||||||
my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
|
my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
|
||||||
my_free((char*) pack_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)
|
if (discover)
|
||||||
{
|
{
|
||||||
/* ToDo 4.1 database needs to be created if missing */
|
/* ToDo 4.1 database needs to be created if missing */
|
||||||
@ -7085,7 +7085,7 @@ int ndbcluster_find_all_files(THD *thd)
|
|||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (unhandled && retries);
|
while (unhandled && retries);
|
||||||
@ -7178,19 +7178,19 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
file_name->str, reg_ext, 0);
|
file_name->str, reg_ext, 0);
|
||||||
if (my_access(name, F_OK))
|
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",
|
DBUG_PRINT("info", ("Table %s listed and need discovery",
|
||||||
file_name->str));
|
file_name->str));
|
||||||
if (ndb_create_table_from_engine(thd, db, 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(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
ER_TABLE_EXISTS_ERROR,
|
ER_TABLE_EXISTS_ERROR,
|
||||||
"Discover of table %s.%s failed",
|
"Discover of table %s.%s failed",
|
||||||
db, file_name->str);
|
db, file_name->str);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str));
|
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str));
|
||||||
file_on_disk= TRUE;
|
file_on_disk= TRUE;
|
||||||
@ -7247,10 +7247,10 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
file_name_str= (char*)my_hash_element(&ok_tables, i);
|
file_name_str= (char*)my_hash_element(&ok_tables, i);
|
||||||
end= end1 +
|
end= end1 +
|
||||||
tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name));
|
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(ndb, name, end-name,
|
ndbcluster_create_binlog_setup(ndb, name, end-name,
|
||||||
db, file_name_str, TRUE);
|
db, file_name_str, TRUE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -7299,7 +7299,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
// Create new files
|
// Create new files
|
||||||
List_iterator_fast<char> it2(create_list);
|
List_iterator_fast<char> it2(create_list);
|
||||||
while ((file_name_str=it2++))
|
while ((file_name_str=it2++))
|
||||||
@ -7314,7 +7314,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
my_hash_free(&ok_tables);
|
my_hash_free(&ok_tables);
|
||||||
my_hash_free(&ndb_tables);
|
my_hash_free(&ndb_tables);
|
||||||
@ -8214,7 +8214,7 @@ int handle_trailing_share(NDB_SHARE *share)
|
|||||||
bzero((char*) &table_list,sizeof(table_list));
|
bzero((char*) &table_list,sizeof(table_list));
|
||||||
table_list.db= share->db;
|
table_list.db= share->db;
|
||||||
table_list.alias= table_list.table_name= share->table_name;
|
table_list.alias= table_list.table_name= share->table_name;
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
close_cached_tables(thd, &table_list, TRUE, FALSE, FALSE);
|
close_cached_tables(thd, &table_list, TRUE, FALSE, FALSE);
|
||||||
|
|
||||||
pthread_mutex_lock(&ndbcluster_mutex);
|
pthread_mutex_lock(&ndbcluster_mutex);
|
||||||
|
@ -343,7 +343,7 @@ ndbcluster_binlog_open_table(THD *thd, NDB_SHARE *share,
|
|||||||
int error;
|
int error;
|
||||||
DBUG_ENTER("ndbcluster_binlog_open_table");
|
DBUG_ENTER("ndbcluster_binlog_open_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,
|
init_tmp_table_share(thd, table_share, share->db, 0, share->table_name,
|
||||||
share->key);
|
share->key);
|
||||||
if ((error= open_table_def(thd, table_share, 0)))
|
if ((error= open_table_def(thd, table_share, 0)))
|
||||||
@ -891,9 +891,9 @@ int ndbcluster_setup_binlog_table_shares(THD *thd)
|
|||||||
if (!ndb_schema_share &&
|
if (!ndb_schema_share &&
|
||||||
ndbcluster_check_ndb_schema_share() == 0)
|
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);
|
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)
|
if (!ndb_schema_share)
|
||||||
{
|
{
|
||||||
ndbcluster_create_schema_table(thd);
|
ndbcluster_create_schema_table(thd);
|
||||||
@ -905,9 +905,9 @@ int ndbcluster_setup_binlog_table_shares(THD *thd)
|
|||||||
if (!ndb_apply_status_share &&
|
if (!ndb_apply_status_share &&
|
||||||
ndbcluster_check_ndb_apply_status_share() == 0)
|
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);
|
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)
|
if (!ndb_apply_status_share)
|
||||||
{
|
{
|
||||||
ndbcluster_create_ndb_apply_status_table(thd);
|
ndbcluster_create_ndb_apply_status_table(thd);
|
||||||
@ -917,12 +917,12 @@ int ndbcluster_setup_binlog_table_shares(THD *thd)
|
|||||||
}
|
}
|
||||||
if (!ndbcluster_find_all_files(thd))
|
if (!ndbcluster_find_all_files(thd))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
ndb_binlog_tables_inited= TRUE;
|
ndb_binlog_tables_inited= TRUE;
|
||||||
if (ndb_extra_logging)
|
if (ndb_extra_logging)
|
||||||
sql_print_information("NDB Binlog: ndb tables writable");
|
sql_print_information("NDB Binlog: ndb tables writable");
|
||||||
close_cached_tables(NULL, NULL, TRUE, FALSE, FALSE);
|
close_cached_tables(NULL, NULL, TRUE, FALSE, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
/* Signal injector thread that all is setup */
|
/* Signal injector thread that all is setup */
|
||||||
pthread_cond_signal(&injector_cond);
|
pthread_cond_signal(&injector_cond);
|
||||||
}
|
}
|
||||||
@ -1565,8 +1565,8 @@ end:
|
|||||||
(void) pthread_mutex_lock(&ndb_schema_object->mutex);
|
(void) pthread_mutex_lock(&ndb_schema_object->mutex);
|
||||||
if (have_lock_open)
|
if (have_lock_open)
|
||||||
{
|
{
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
(void) pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -1625,7 +1625,7 @@ end:
|
|||||||
}
|
}
|
||||||
if (have_lock_open)
|
if (have_lock_open)
|
||||||
{
|
{
|
||||||
(void) pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
}
|
}
|
||||||
(void) pthread_mutex_unlock(&ndb_schema_object->mutex);
|
(void) pthread_mutex_unlock(&ndb_schema_object->mutex);
|
||||||
}
|
}
|
||||||
@ -1709,7 +1709,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
|
|||||||
{
|
{
|
||||||
DBUG_DUMP("frm", (uchar*) altered_table->getFrmData(),
|
DBUG_DUMP("frm", (uchar*) altered_table->getFrmData(),
|
||||||
altered_table->getFrmLength());
|
altered_table->getFrmLength());
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
Ndb_table_guard ndbtab_g(dict, tabname);
|
Ndb_table_guard ndbtab_g(dict, tabname);
|
||||||
const NDBTAB *old= ndbtab_g.get_table();
|
const NDBTAB *old= ndbtab_g.get_table();
|
||||||
if (!old &&
|
if (!old &&
|
||||||
@ -1747,7 +1747,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
|
|||||||
dbname= table_share->db.str;
|
dbname= table_share->db.str;
|
||||||
tabname= table_share->table_name.str;
|
tabname= table_share->table_name.str;
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
||||||
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
||||||
@ -1974,7 +1974,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
|
|||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
case SOT_CREATE_TABLE:
|
case SOT_CREATE_TABLE:
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (ndbcluster_check_if_local_table(schema->db, schema->name))
|
if (ndbcluster_check_if_local_table(schema->db, schema->name))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
|
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
|
||||||
@ -1988,7 +1988,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
|
|||||||
{
|
{
|
||||||
print_could_not_discover_error(thd, schema);
|
print_could_not_discover_error(thd, schema);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
log_query= 1;
|
log_query= 1;
|
||||||
break;
|
break;
|
||||||
case SOT_DROP_DB:
|
case SOT_DROP_DB:
|
||||||
@ -2257,7 +2257,7 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd,
|
|||||||
free_share(&share);
|
free_share(&share);
|
||||||
share= 0;
|
share= 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (ndbcluster_check_if_local_table(schema->db, schema->name))
|
if (ndbcluster_check_if_local_table(schema->db, schema->name))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
|
DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
|
||||||
@ -2271,7 +2271,7 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd,
|
|||||||
{
|
{
|
||||||
print_could_not_discover_error(thd, schema);
|
print_could_not_discover_error(thd, schema);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -3155,8 +3155,8 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name,
|
|||||||
#ifdef SYNC_DROP_
|
#ifdef SYNC_DROP_
|
||||||
thd->proc_info= "Syncing ndb table schema operation and binlog";
|
thd->proc_info= "Syncing ndb table schema operation and binlog";
|
||||||
(void) pthread_mutex_lock(&share->mutex);
|
(void) pthread_mutex_lock(&share->mutex);
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
(void) pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
int max_timeout= opt_ndb_sync_timeout;
|
int max_timeout= opt_ndb_sync_timeout;
|
||||||
while (share->op)
|
while (share->op)
|
||||||
{
|
{
|
||||||
@ -3182,7 +3182,7 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name,
|
|||||||
type_str, share->key);
|
type_str, share->key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
(void) pthread_mutex_unlock(&share->mutex);
|
(void) pthread_mutex_unlock(&share->mutex);
|
||||||
#else
|
#else
|
||||||
(void) pthread_mutex_lock(&share->mutex);
|
(void) pthread_mutex_lock(&share->mutex);
|
||||||
|
104
sql/item_func.cc
104
sql/item_func.cc
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -3287,7 +3287,7 @@ bool udf_handler::get_arguments() { return 0; }
|
|||||||
** User level locks
|
** User level locks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pthread_mutex_t LOCK_user_locks;
|
mysql_mutex_t LOCK_user_locks;
|
||||||
static HASH hash_user_locks;
|
static HASH hash_user_locks;
|
||||||
|
|
||||||
class User_level_lock
|
class User_level_lock
|
||||||
@ -3298,7 +3298,7 @@ class User_level_lock
|
|||||||
public:
|
public:
|
||||||
int count;
|
int count;
|
||||||
bool locked;
|
bool locked;
|
||||||
pthread_cond_t cond;
|
mysql_cond_t cond;
|
||||||
my_thread_id thread_id;
|
my_thread_id thread_id;
|
||||||
void set_thread(THD *thd) { thread_id= thd->thread_id; }
|
void set_thread(THD *thd) { thread_id= thd->thread_id; }
|
||||||
|
|
||||||
@ -3306,7 +3306,7 @@ public:
|
|||||||
:key_length(length),count(1),locked(1), thread_id(id)
|
:key_length(length),count(1),locked(1), thread_id(id)
|
||||||
{
|
{
|
||||||
key= (uchar*) my_memdup(key_arg,length,MYF(0));
|
key= (uchar*) my_memdup(key_arg,length,MYF(0));
|
||||||
pthread_cond_init(&cond,NULL);
|
mysql_cond_init(key_user_level_lock_cond, &cond, NULL);
|
||||||
if (key)
|
if (key)
|
||||||
{
|
{
|
||||||
if (my_hash_insert(&hash_user_locks,(uchar*) this))
|
if (my_hash_insert(&hash_user_locks,(uchar*) this))
|
||||||
@ -3323,7 +3323,7 @@ public:
|
|||||||
my_hash_delete(&hash_user_locks,(uchar*) this);
|
my_hash_delete(&hash_user_locks,(uchar*) this);
|
||||||
my_free(key, MYF(0));
|
my_free(key, MYF(0));
|
||||||
}
|
}
|
||||||
pthread_cond_destroy(&cond);
|
mysql_cond_destroy(&cond);
|
||||||
}
|
}
|
||||||
inline bool initialized() { return key != 0; }
|
inline bool initialized() { return key != 0; }
|
||||||
friend void item_user_lock_release(User_level_lock *ull);
|
friend void item_user_lock_release(User_level_lock *ull);
|
||||||
@ -3338,12 +3338,36 @@ uchar *ull_get_key(const User_level_lock *ull, size_t *length,
|
|||||||
return ull->key;
|
return ull->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
static PSI_mutex_key key_LOCK_user_locks;
|
||||||
|
|
||||||
|
static PSI_mutex_info all_user_mutexes[]=
|
||||||
|
{
|
||||||
|
{ &key_LOCK_user_locks, "LOCK_user_locks", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void init_user_lock_psi_keys(void)
|
||||||
|
{
|
||||||
|
const char* category= "sql";
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (PSI_server == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count= array_elements(all_user_mutexes);
|
||||||
|
PSI_server->register_mutex(category, all_user_mutexes, count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool item_user_lock_inited= 0;
|
static bool item_user_lock_inited= 0;
|
||||||
|
|
||||||
void item_user_lock_init(void)
|
void item_user_lock_init(void)
|
||||||
{
|
{
|
||||||
pthread_mutex_init(&LOCK_user_locks,MY_MUTEX_INIT_SLOW);
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
init_user_lock_psi_keys();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mysql_mutex_init(key_LOCK_user_locks, &LOCK_user_locks, MY_MUTEX_INIT_SLOW);
|
||||||
my_hash_init(&hash_user_locks,system_charset_info,
|
my_hash_init(&hash_user_locks,system_charset_info,
|
||||||
16,0,0,(my_hash_get_key) ull_get_key,NULL,0);
|
16,0,0,(my_hash_get_key) ull_get_key,NULL,0);
|
||||||
item_user_lock_inited= 1;
|
item_user_lock_inited= 1;
|
||||||
@ -3355,7 +3379,7 @@ void item_user_lock_free(void)
|
|||||||
{
|
{
|
||||||
item_user_lock_inited= 0;
|
item_user_lock_inited= 0;
|
||||||
my_hash_free(&hash_user_locks);
|
my_hash_free(&hash_user_locks);
|
||||||
pthread_mutex_destroy(&LOCK_user_locks);
|
mysql_mutex_destroy(&LOCK_user_locks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3364,7 +3388,7 @@ void item_user_lock_release(User_level_lock *ull)
|
|||||||
ull->locked=0;
|
ull->locked=0;
|
||||||
ull->thread_id= 0;
|
ull->thread_id= 0;
|
||||||
if (--ull->count)
|
if (--ull->count)
|
||||||
pthread_cond_signal(&ull->cond);
|
mysql_cond_signal(&ull->cond);
|
||||||
else
|
else
|
||||||
delete ull;
|
delete ull;
|
||||||
}
|
}
|
||||||
@ -3407,7 +3431,7 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
|
|||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
size_t lock_name_len;
|
size_t lock_name_len;
|
||||||
lock_name_len= strlen(lock_name);
|
lock_name_len= strlen(lock_name);
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
|
|
||||||
if (thd->ull)
|
if (thd->ull)
|
||||||
{
|
{
|
||||||
@ -3425,7 +3449,7 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
|
|||||||
(uchar*) lock_name,
|
(uchar*) lock_name,
|
||||||
lock_name_len))))
|
lock_name_len))))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ull->count++;
|
ull->count++;
|
||||||
@ -3441,7 +3465,7 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
|
|||||||
set_timespec(abstime,lock_timeout);
|
set_timespec(abstime,lock_timeout);
|
||||||
while (ull->locked && !thd->killed)
|
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)
|
if (error == ETIMEDOUT || error == ETIME)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3457,19 +3481,19 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
|
|||||||
ull->set_thread(thd);
|
ull->set_thread(thd);
|
||||||
thd->ull=ull;
|
thd->ull=ull;
|
||||||
}
|
}
|
||||||
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_proc_info(thd, 0);
|
||||||
thd->mysys_var->current_mutex= 0;
|
thd->mysys_var->current_mutex= 0;
|
||||||
thd->mysys_var->current_cond= 0;
|
thd->mysys_var->current_cond= 0;
|
||||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
mysql_mutex_unlock(&thd->mysys_var->mutex);
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
if (thd->ull)
|
if (thd->ull)
|
||||||
{
|
{
|
||||||
item_user_lock_release(thd->ull);
|
item_user_lock_release(thd->ull);
|
||||||
thd->ull=0;
|
thd->ull=0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -3487,8 +3511,8 @@ void debug_sync_point(const char* lock_name, uint lock_timeout)
|
|||||||
|
|
||||||
#define INTERRUPT_INTERVAL (5 * ULL(1000000000))
|
#define INTERRUPT_INTERVAL (5 * ULL(1000000000))
|
||||||
|
|
||||||
static int interruptible_wait(THD *thd, pthread_cond_t *cond,
|
static int interruptible_wait(THD *thd, mysql_cond_t *cond,
|
||||||
pthread_mutex_t *lock, double time)
|
mysql_mutex_t *lock, double time)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
@ -3504,7 +3528,7 @@ static int interruptible_wait(THD *thd, pthread_cond_t *cond,
|
|||||||
|
|
||||||
timeout-= slice;
|
timeout-= slice;
|
||||||
set_timespec_nsec(abstime, 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)
|
if (error == ETIMEDOUT || error == ETIME)
|
||||||
{
|
{
|
||||||
/* Return error if timed out or connection is broken. */
|
/* Return error if timed out or connection is broken. */
|
||||||
@ -3547,11 +3571,11 @@ longlong Item_func_get_lock::val_int()
|
|||||||
if (thd->slave_thread)
|
if (thd->slave_thread)
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
|
|
||||||
if (!res || !res->length())
|
if (!res || !res->length())
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
null_value=1;
|
null_value=1;
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
@ -3574,13 +3598,13 @@ longlong Item_func_get_lock::val_int()
|
|||||||
if (!ull || !ull->initialized())
|
if (!ull || !ull->initialized())
|
||||||
{
|
{
|
||||||
delete ull;
|
delete ull;
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
null_value=1; // Probably out of memory
|
null_value=1; // Probably out of memory
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
ull->set_thread(thd);
|
ull->set_thread(thd);
|
||||||
thd->ull=ull;
|
thd->ull=ull;
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
DBUG_PRINT("info", ("made new lock"));
|
DBUG_PRINT("info", ("made new lock"));
|
||||||
DBUG_RETURN(1); // Got new lock
|
DBUG_RETURN(1); // Got new lock
|
||||||
}
|
}
|
||||||
@ -3630,13 +3654,13 @@ longlong Item_func_get_lock::val_int()
|
|||||||
error=0;
|
error=0;
|
||||||
DBUG_PRINT("info", ("got the lock"));
|
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_proc_info(thd, 0);
|
||||||
thd->mysys_var->current_mutex= 0;
|
thd->mysys_var->current_mutex= 0;
|
||||||
thd->mysys_var->current_cond= 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);
|
DBUG_RETURN(!error ? 1 : 0);
|
||||||
}
|
}
|
||||||
@ -3667,7 +3691,7 @@ longlong Item_func_release_lock::val_int()
|
|||||||
null_value=0;
|
null_value=0;
|
||||||
|
|
||||||
result=0;
|
result=0;
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
if (!(ull= ((User_level_lock*) my_hash_search(&hash_user_locks,
|
if (!(ull= ((User_level_lock*) my_hash_search(&hash_user_locks,
|
||||||
(const uchar*) res->ptr(),
|
(const uchar*) res->ptr(),
|
||||||
(size_t) res->length()))))
|
(size_t) res->length()))))
|
||||||
@ -3688,7 +3712,7 @@ longlong Item_func_release_lock::val_int()
|
|||||||
thd->ull=0;
|
thd->ull=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3794,7 +3818,7 @@ void Item_func_benchmark::print(String *str, enum_query_type query_type)
|
|||||||
longlong Item_func_sleep::val_int()
|
longlong Item_func_sleep::val_int()
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
THD *thd= current_thd;
|
||||||
pthread_cond_t cond;
|
mysql_cond_t cond;
|
||||||
double timeout;
|
double timeout;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
@ -3808,13 +3832,13 @@ longlong Item_func_sleep::val_int()
|
|||||||
When given a very short timeout (< 10 mcs) just return
|
When given a very short timeout (< 10 mcs) just return
|
||||||
immediately.
|
immediately.
|
||||||
We assume that the lines between this test and the call
|
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)
|
if (timeout < 0.00001)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pthread_cond_init(&cond, NULL);
|
mysql_cond_init(key_item_func_sleep_cond, &cond, NULL);
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
|
|
||||||
thd_proc_info(thd, "User sleep");
|
thd_proc_info(thd, "User sleep");
|
||||||
thd->mysys_var->current_mutex= &LOCK_user_locks;
|
thd->mysys_var->current_mutex= &LOCK_user_locks;
|
||||||
@ -3829,13 +3853,13 @@ longlong Item_func_sleep::val_int()
|
|||||||
error= 0;
|
error= 0;
|
||||||
}
|
}
|
||||||
thd_proc_info(thd, 0);
|
thd_proc_info(thd, 0);
|
||||||
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->mysys_var->current_mutex= 0;
|
thd->mysys_var->current_mutex= 0;
|
||||||
thd->mysys_var->current_cond= 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
|
return test(!error); // Return 1 killed
|
||||||
}
|
}
|
||||||
@ -5763,10 +5787,10 @@ longlong Item_func_is_free_lock::val_int()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
|
ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
|
||||||
(size_t) res->length());
|
(size_t) res->length());
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
if (!ull || !ull->locked)
|
if (!ull || !ull->locked)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -5782,10 +5806,10 @@ longlong Item_func_is_used_lock::val_int()
|
|||||||
if (!res || !res->length())
|
if (!res || !res->length())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
|
ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
|
||||||
(size_t) res->length());
|
(size_t) res->length());
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
if (!ull || !ull->locked)
|
if (!ull || !ull->locked)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
12
sql/lock.cc
12
sql/lock.cc
@ -978,7 +978,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
|
|||||||
|
|
||||||
if (wait_if_global_read_lock(thd, 0, 1))
|
if (wait_if_global_read_lock(thd, 0, 1))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if ((lock_retcode = lock_table_name(thd, table_list, TRUE)) < 0)
|
if ((lock_retcode = lock_table_name(thd, table_list, TRUE)) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if (lock_retcode && wait_for_locked_table_names(thd, table_list))
|
if (lock_retcode && wait_for_locked_table_names(thd, table_list))
|
||||||
@ -989,7 +989,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
|
|||||||
error=0;
|
error=0;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@ -1118,7 +1118,7 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list)
|
|||||||
bool result=0;
|
bool result=0;
|
||||||
DBUG_ENTER("wait_for_locked_table_names");
|
DBUG_ENTER("wait_for_locked_table_names");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
while (locked_named_table(thd,table_list))
|
while (locked_named_table(thd,table_list))
|
||||||
{
|
{
|
||||||
@ -1128,7 +1128,7 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wait_for_condition(thd, &LOCK_open, &COND_refresh);
|
wait_for_condition(thd, &LOCK_open, &COND_refresh);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
@ -1508,7 +1508,7 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
|
|||||||
threads could not close their tables. This would make a pretty
|
threads could not close their tables. This would make a pretty
|
||||||
deadlock.
|
deadlock.
|
||||||
*/
|
*/
|
||||||
safe_mutex_assert_not_owner(&LOCK_open);
|
mysql_mutex_assert_not_owner(&LOCK_open);
|
||||||
|
|
||||||
(void) pthread_mutex_lock(&LOCK_global_read_lock);
|
(void) pthread_mutex_lock(&LOCK_global_read_lock);
|
||||||
if ((need_exit_cond= must_wait))
|
if ((need_exit_cond= must_wait))
|
||||||
@ -1622,7 +1622,7 @@ bool make_global_read_lock_block_commit(THD *thd)
|
|||||||
|
|
||||||
void broadcast_refresh(void)
|
void broadcast_refresh(void)
|
||||||
{
|
{
|
||||||
pthread_cond_broadcast(&COND_refresh);
|
mysql_cond_broadcast(&COND_refresh);
|
||||||
pthread_cond_broadcast(&COND_global_read_lock);
|
pthread_cond_broadcast(&COND_global_read_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1496,8 +1496,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
|||||||
COND **conds);
|
COND **conds);
|
||||||
int setup_ftfuncs(SELECT_LEX* select);
|
int setup_ftfuncs(SELECT_LEX* select);
|
||||||
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
|
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
|
||||||
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
|
void wait_for_condition(THD *thd, mysql_mutex_t *mutex,
|
||||||
pthread_cond_t *cond);
|
mysql_cond_t *cond);
|
||||||
int open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags);
|
int open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags);
|
||||||
/* open_and_lock_tables with optional derived handling */
|
/* open_and_lock_tables with optional derived handling */
|
||||||
int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived);
|
int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived);
|
||||||
@ -1986,13 +1986,15 @@ extern FILE *bootstrap_file;
|
|||||||
extern int bootstrap_error;
|
extern int bootstrap_error;
|
||||||
extern FILE *stderror_file;
|
extern FILE *stderror_file;
|
||||||
extern pthread_key(MEM_ROOT**,THR_MALLOC);
|
extern pthread_key(MEM_ROOT**,THR_MALLOC);
|
||||||
extern pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
|
extern pthread_mutex_t LOCK_mapped_file,
|
||||||
LOCK_mapped_file,LOCK_user_locks, LOCK_status,
|
LOCK_error_log, LOCK_uuid_generator,
|
||||||
LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
|
LOCK_crypt, LOCK_timezone,
|
||||||
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
|
|
||||||
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
|
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
|
||||||
LOCK_global_system_variables, LOCK_user_conn,
|
LOCK_global_system_variables, LOCK_user_conn,
|
||||||
LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
|
LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
|
||||||
|
extern mysql_mutex_t LOCK_mysql_create_db, LOCK_lock_db, LOCK_open,
|
||||||
|
LOCK_user_locks, LOCK_status, LOCK_delayed_status, LOCK_delayed_insert,
|
||||||
|
LOCK_delayed_create;
|
||||||
extern MYSQL_PLUGIN_IMPORT pthread_mutex_t LOCK_thread_count;
|
extern MYSQL_PLUGIN_IMPORT pthread_mutex_t LOCK_thread_count;
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
extern pthread_mutex_t LOCK_des_key_file;
|
extern pthread_mutex_t LOCK_des_key_file;
|
||||||
@ -2002,7 +2004,8 @@ extern pthread_cond_t COND_server_started;
|
|||||||
extern int mysqld_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_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
|
||||||
extern rw_lock_t LOCK_system_variables_hash;
|
extern rw_lock_t LOCK_system_variables_hash;
|
||||||
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
|
extern mysql_cond_t COND_refresh;
|
||||||
|
extern pthread_cond_t COND_thread_count, COND_manager;
|
||||||
extern pthread_cond_t COND_global_read_lock;
|
extern pthread_cond_t COND_global_read_lock;
|
||||||
extern pthread_attr_t connection_attrib;
|
extern pthread_attr_t connection_attrib;
|
||||||
extern I_List<THD> threads;
|
extern I_List<THD> threads;
|
||||||
|
@ -647,14 +647,16 @@ SHOW_COMP_OPTION have_profiling;
|
|||||||
|
|
||||||
pthread_key(MEM_ROOT**,THR_MALLOC);
|
pthread_key(MEM_ROOT**,THR_MALLOC);
|
||||||
pthread_key(THD*, THR_THD);
|
pthread_key(THD*, THR_THD);
|
||||||
pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
|
pthread_mutex_t LOCK_thread_count,
|
||||||
LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
|
LOCK_mapped_file, LOCK_global_read_lock,
|
||||||
LOCK_error_log, LOCK_uuid_generator,
|
LOCK_error_log, LOCK_uuid_generator,
|
||||||
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
|
|
||||||
LOCK_crypt,
|
LOCK_crypt,
|
||||||
LOCK_global_system_variables,
|
LOCK_global_system_variables,
|
||||||
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
|
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
|
||||||
LOCK_connection_count, LOCK_error_messages;
|
LOCK_connection_count, LOCK_error_messages;
|
||||||
|
mysql_mutex_t LOCK_open, LOCK_mysql_create_db, LOCK_status, LOCK_delayed_status,
|
||||||
|
LOCK_delayed_insert, LOCK_delayed_create;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The below lock protects access to two global server variables:
|
The below lock protects access to two global server variables:
|
||||||
max_prepared_stmt_count and prepared_stmt_count. These variables
|
max_prepared_stmt_count and prepared_stmt_count. These variables
|
||||||
@ -668,7 +670,8 @@ pthread_mutex_t LOCK_des_key_file;
|
|||||||
#endif
|
#endif
|
||||||
rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
|
rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
|
||||||
rw_lock_t LOCK_system_variables_hash;
|
rw_lock_t LOCK_system_variables_hash;
|
||||||
pthread_cond_t COND_refresh, COND_thread_count, COND_global_read_lock;
|
mysql_cond_t COND_refresh;
|
||||||
|
pthread_cond_t COND_thread_count, COND_global_read_lock;
|
||||||
pthread_t signal_thread;
|
pthread_t signal_thread;
|
||||||
pthread_attr_t connection_attrib;
|
pthread_attr_t connection_attrib;
|
||||||
pthread_mutex_t LOCK_server_started;
|
pthread_mutex_t LOCK_server_started;
|
||||||
@ -958,14 +961,14 @@ static void close_connections(void)
|
|||||||
if (tmp->mysys_var)
|
if (tmp->mysys_var)
|
||||||
{
|
{
|
||||||
tmp->mysys_var->abort=1;
|
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)
|
if (tmp->mysys_var->current_cond)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(tmp->mysys_var->current_mutex);
|
mysql_mutex_lock(tmp->mysys_var->current_mutex);
|
||||||
pthread_cond_broadcast(tmp->mysys_var->current_cond);
|
mysql_cond_broadcast(tmp->mysys_var->current_cond);
|
||||||
pthread_mutex_unlock(tmp->mysys_var->current_mutex);
|
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) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
|
||||||
@ -1410,17 +1413,17 @@ static void wait_for_signal_thread_to_end()
|
|||||||
|
|
||||||
static void clean_up_mutexes()
|
static void clean_up_mutexes()
|
||||||
{
|
{
|
||||||
(void) pthread_mutex_destroy(&LOCK_mysql_create_db);
|
mysql_mutex_destroy(&LOCK_mysql_create_db);
|
||||||
(void) pthread_mutex_destroy(&LOCK_lock_db);
|
mysql_mutex_destroy(&LOCK_lock_db);
|
||||||
(void) rwlock_destroy(&LOCK_grant);
|
(void) rwlock_destroy(&LOCK_grant);
|
||||||
(void) pthread_mutex_destroy(&LOCK_open);
|
mysql_mutex_destroy(&LOCK_open);
|
||||||
(void) pthread_mutex_destroy(&LOCK_thread_count);
|
(void) pthread_mutex_destroy(&LOCK_thread_count);
|
||||||
(void) pthread_mutex_destroy(&LOCK_mapped_file);
|
(void) pthread_mutex_destroy(&LOCK_mapped_file);
|
||||||
(void) pthread_mutex_destroy(&LOCK_status);
|
mysql_mutex_destroy(&LOCK_status);
|
||||||
(void) pthread_mutex_destroy(&LOCK_error_log);
|
(void) pthread_mutex_destroy(&LOCK_error_log);
|
||||||
(void) pthread_mutex_destroy(&LOCK_delayed_insert);
|
mysql_mutex_destroy(&LOCK_delayed_insert);
|
||||||
(void) pthread_mutex_destroy(&LOCK_delayed_status);
|
mysql_mutex_destroy(&LOCK_delayed_status);
|
||||||
(void) pthread_mutex_destroy(&LOCK_delayed_create);
|
mysql_mutex_destroy(&LOCK_delayed_create);
|
||||||
(void) pthread_mutex_destroy(&LOCK_manager);
|
(void) pthread_mutex_destroy(&LOCK_manager);
|
||||||
(void) pthread_mutex_destroy(&LOCK_crypt);
|
(void) pthread_mutex_destroy(&LOCK_crypt);
|
||||||
(void) pthread_mutex_destroy(&LOCK_user_conn);
|
(void) pthread_mutex_destroy(&LOCK_user_conn);
|
||||||
@ -1448,7 +1451,7 @@ static void clean_up_mutexes()
|
|||||||
(void) pthread_mutex_destroy(&LOCK_prepared_stmt_count);
|
(void) pthread_mutex_destroy(&LOCK_prepared_stmt_count);
|
||||||
(void) pthread_mutex_destroy(&LOCK_error_messages);
|
(void) pthread_mutex_destroy(&LOCK_error_messages);
|
||||||
(void) pthread_cond_destroy(&COND_thread_count);
|
(void) pthread_cond_destroy(&COND_thread_count);
|
||||||
(void) pthread_cond_destroy(&COND_refresh);
|
mysql_cond_destroy(&COND_refresh);
|
||||||
(void) pthread_cond_destroy(&COND_global_read_lock);
|
(void) pthread_cond_destroy(&COND_global_read_lock);
|
||||||
(void) pthread_cond_destroy(&COND_thread_cache);
|
(void) pthread_cond_destroy(&COND_thread_cache);
|
||||||
(void) pthread_cond_destroy(&COND_flush_thread_cache);
|
(void) pthread_cond_destroy(&COND_flush_thread_cache);
|
||||||
@ -3591,16 +3594,20 @@ You should consider changing lower_case_table_names to 1 or 2",
|
|||||||
|
|
||||||
static int init_thread_environment()
|
static int init_thread_environment()
|
||||||
{
|
{
|
||||||
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
|
mysql_mutex_init(key_LOCK_mysql_create_db,
|
||||||
(void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
|
&LOCK_mysql_create_db, MY_MUTEX_INIT_SLOW);
|
||||||
(void) pthread_mutex_init(&LOCK_open, MY_MUTEX_INIT_FAST);
|
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);
|
||||||
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
|
(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_mapped_file,MY_MUTEX_INIT_SLOW);
|
||||||
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST);
|
||||||
(void) pthread_mutex_init(&LOCK_error_log,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);
|
mysql_mutex_init(key_LOCK_deleyed_insert,
|
||||||
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
|
&LOCK_delayed_insert, MY_MUTEX_INIT_FAST);
|
||||||
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
|
mysql_mutex_init(key_LOCK_delayed_status,
|
||||||
|
&LOCK_delayed_status, MY_MUTEX_INIT_FAST);
|
||||||
|
mysql_mutex_init(key_LOCK_delayed_create,
|
||||||
|
&LOCK_delayed_create, MY_MUTEX_INIT_SLOW);
|
||||||
(void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
|
(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_crypt,MY_MUTEX_INIT_FAST);
|
||||||
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
|
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
|
||||||
@ -3630,7 +3637,7 @@ static int init_thread_environment()
|
|||||||
(void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
|
(void) my_rwlock_init(&LOCK_sys_init_slave, NULL);
|
||||||
(void) my_rwlock_init(&LOCK_grant, NULL);
|
(void) my_rwlock_init(&LOCK_grant, NULL);
|
||||||
(void) pthread_cond_init(&COND_thread_count,NULL);
|
(void) pthread_cond_init(&COND_thread_count,NULL);
|
||||||
(void) pthread_cond_init(&COND_refresh,NULL);
|
mysql_cond_init(key_COND_refresh, &COND_refresh, NULL);
|
||||||
(void) pthread_cond_init(&COND_global_read_lock,NULL);
|
(void) pthread_cond_init(&COND_global_read_lock,NULL);
|
||||||
(void) pthread_cond_init(&COND_thread_cache,NULL);
|
(void) pthread_cond_init(&COND_thread_cache,NULL);
|
||||||
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
|
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
|
||||||
@ -8896,7 +8903,7 @@ static void create_pid_file()
|
|||||||
/** Clear most status variables. */
|
/** Clear most status variables. */
|
||||||
void refresh_status(THD *thd)
|
void refresh_status(THD *thd)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_status);
|
mysql_mutex_lock(&LOCK_status);
|
||||||
|
|
||||||
/* Add thread's status variabes to global status */
|
/* Add thread's status variabes to global status */
|
||||||
add_to_status(&global_status_var, &thd->status_var);
|
add_to_status(&global_status_var, &thd->status_var);
|
||||||
@ -8910,7 +8917,7 @@ void refresh_status(THD *thd)
|
|||||||
/* Reset the counters of all key caches (default and named). */
|
/* Reset the counters of all key caches (default and named). */
|
||||||
process_key_caches(reset_key_cache_counters);
|
process_key_caches(reset_key_cache_counters);
|
||||||
flush_status_time= time((time_t*) 0);
|
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
|
Set max_used_connections to the number of currently open
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2008 MySQL AB
|
/* Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -470,8 +470,8 @@ MYSQL *rpl_connect_master(MYSQL *mysql);
|
|||||||
held before call this function
|
held before call this function
|
||||||
@param msg The new process message for the thread
|
@param msg The new process message for the thread
|
||||||
*/
|
*/
|
||||||
const char* thd_enter_cond(MYSQL_THD thd, pthread_cond_t *cond,
|
const char* thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond,
|
||||||
pthread_mutex_t *mutex, const char *msg);
|
mysql_mutex_t *mutex, const char *msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set thread leaving a condition
|
Set thread leaving a condition
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2002 MySQL AB
|
/* Copyright (C) 2002 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include "sp_cache.h"
|
#include "sp_cache.h"
|
||||||
#include "sp_head.h"
|
#include "sp_head.h"
|
||||||
|
|
||||||
static pthread_mutex_t Cversion_lock;
|
static mysql_mutex_t Cversion_lock;
|
||||||
static ulong volatile Cversion= 0;
|
static ulong volatile Cversion= 0;
|
||||||
|
|
||||||
|
|
||||||
@ -75,12 +75,36 @@ private:
|
|||||||
HASH m_hashtable;
|
HASH m_hashtable;
|
||||||
}; // class sp_cache
|
}; // class sp_cache
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
static PSI_mutex_key key_Cversion_lock;
|
||||||
|
|
||||||
|
static PSI_mutex_info all_sp_cache_mutexes[]=
|
||||||
|
{
|
||||||
|
{ &key_Cversion_lock, "Cversion_lock", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void init_sp_cache_psi_keys(void)
|
||||||
|
{
|
||||||
|
const char* category= "sql";
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (PSI_server == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count= array_elements(all_sp_cache_mutexes);
|
||||||
|
PSI_server->register_mutex(category, all_sp_cache_mutexes, count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize the SP caching once at startup */
|
/* Initialize the SP caching once at startup */
|
||||||
|
|
||||||
void sp_cache_init()
|
void sp_cache_init()
|
||||||
{
|
{
|
||||||
pthread_mutex_init(&Cversion_lock, MY_MUTEX_INIT_FAST);
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
init_sp_cache_psi_keys();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mysql_mutex_init(key_Cversion_lock, &Cversion_lock, MY_MUTEX_INIT_FAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
152
sql/sql_base.cc
152
sql/sql_base.cc
@ -566,7 +566,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type)
|
|||||||
(ulong) share, share->db.str, share->table_name.str,
|
(ulong) share, share->db.str, share->table_name.str,
|
||||||
share->ref_count, share->version));
|
share->ref_count, share->version));
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
pthread_mutex_lock(&share->mutex);
|
pthread_mutex_lock(&share->mutex);
|
||||||
if (!--share->ref_count)
|
if (!--share->ref_count)
|
||||||
@ -619,7 +619,7 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name)
|
|||||||
char key[NAME_LEN*2+2];
|
char key[NAME_LEN*2+2];
|
||||||
TABLE_LIST table_list;
|
TABLE_LIST table_list;
|
||||||
uint key_length;
|
uint key_length;
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
table_list.db= (char*) db;
|
table_list.db= (char*) db;
|
||||||
table_list.table_name= (char*) table_name;
|
table_list.table_name= (char*) table_name;
|
||||||
@ -714,7 +714,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
|
|||||||
TABLE_LIST table_list;
|
TABLE_LIST table_list;
|
||||||
DBUG_ENTER("list_open_tables");
|
DBUG_ENTER("list_open_tables");
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
bzero((char*) &table_list,sizeof(table_list));
|
bzero((char*) &table_list,sizeof(table_list));
|
||||||
start_list= &open_list;
|
start_list= &open_list;
|
||||||
open_list=0;
|
open_list=0;
|
||||||
@ -767,7 +767,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
|
|||||||
start_list= &(*start_list)->next;
|
start_list= &(*start_list)->next;
|
||||||
*start_list=0;
|
*start_list=0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(open_list);
|
DBUG_RETURN(open_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -864,7 +864,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
|
|||||||
DBUG_ASSERT(thd || (!wait_for_refresh && !tables));
|
DBUG_ASSERT(thd || (!wait_for_refresh && !tables));
|
||||||
|
|
||||||
if (!have_lock)
|
if (!have_lock)
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (!tables)
|
if (!tables)
|
||||||
{
|
{
|
||||||
refresh_version++; // Force close of open tables
|
refresh_version++; // Force close of open tables
|
||||||
@ -994,7 +994,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
|
|||||||
{
|
{
|
||||||
found=1;
|
found=1;
|
||||||
DBUG_PRINT("signal", ("Waiting for COND_refresh"));
|
DBUG_PRINT("signal", ("Waiting for COND_refresh"));
|
||||||
pthread_cond_wait(&COND_refresh,&LOCK_open);
|
mysql_cond_wait(&COND_refresh, &LOCK_open);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1019,14 +1019,14 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!have_lock)
|
if (!have_lock)
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
if (wait_for_refresh)
|
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_mutex= 0;
|
||||||
thd->mysys_var->current_cond= 0;
|
thd->mysys_var->current_cond= 0;
|
||||||
thd_proc_info(thd, 0);
|
thd_proc_info(thd, 0);
|
||||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
mysql_mutex_unlock(&thd->mysys_var->mutex);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
@ -1049,7 +1049,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh,
|
|||||||
bzero(&tmp, sizeof(TABLE_LIST));
|
bzero(&tmp, sizeof(TABLE_LIST));
|
||||||
|
|
||||||
if (!have_lock)
|
if (!have_lock)
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
for (idx= 0; idx < table_def_cache.records; idx++)
|
for (idx= 0; idx < table_def_cache.records; idx++)
|
||||||
{
|
{
|
||||||
@ -1082,15 +1082,15 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh,
|
|||||||
result= close_cached_tables(thd, tables, TRUE, FALSE, FALSE);
|
result= close_cached_tables(thd, tables, TRUE, FALSE, FALSE);
|
||||||
|
|
||||||
if (!have_lock)
|
if (!have_lock)
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
if (if_wait_for_refresh)
|
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_mutex= 0;
|
||||||
thd->mysys_var->current_cond= 0;
|
thd->mysys_var->current_cond= 0;
|
||||||
thd->proc_info=0;
|
thd->proc_info=0;
|
||||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
mysql_mutex_unlock(&thd->mysys_var->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
@ -1197,9 +1197,9 @@ static void close_open_tables(THD *thd)
|
|||||||
{
|
{
|
||||||
bool found_old_table= 0;
|
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: 0x%lx", (long) thd->open_tables));
|
DBUG_PRINT("info", ("thd->open_tables: 0x%lx", (long) thd->open_tables));
|
||||||
|
|
||||||
@ -1217,7 +1217,7 @@ static void close_open_tables(THD *thd)
|
|||||||
broadcast_refresh();
|
broadcast_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2094,7 +2094,7 @@ void unlink_open_table(THD *thd, TABLE *find, bool unlock)
|
|||||||
TABLE *list, **prev;
|
TABLE *list, **prev;
|
||||||
DBUG_ENTER("unlink_open_table");
|
DBUG_ENTER("unlink_open_table");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
memcpy(key, find->s->table_cache_key.str, key_length);
|
memcpy(key, find->s->table_cache_key.str, key_length);
|
||||||
/*
|
/*
|
||||||
@ -2163,14 +2163,14 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
handlerton *table_type= table->s->db_type();
|
handlerton *table_type= table->s->db_type();
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
/*
|
/*
|
||||||
unlink_open_table() also tells threads waiting for refresh or close
|
unlink_open_table() also tells threads waiting for refresh or close
|
||||||
that something has happened.
|
that something has happened.
|
||||||
*/
|
*/
|
||||||
unlink_open_table(thd, table, FALSE);
|
unlink_open_table(thd, table, FALSE);
|
||||||
quick_rm_table(table_type, db_name, table_name, 0);
|
quick_rm_table(table_type, db_name, table_name, 0);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2186,7 +2186,7 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name,
|
|||||||
cond Condition to wait for
|
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 */
|
/* Wait until the current table is up to date */
|
||||||
const char *proc_info;
|
const char *proc_info;
|
||||||
@ -2196,7 +2196,7 @@ void wait_for_condition(THD *thd, pthread_mutex_t *mutex, pthread_cond_t *cond)
|
|||||||
thd_proc_info(thd, "Waiting for table");
|
thd_proc_info(thd, "Waiting for table");
|
||||||
DBUG_ENTER("wait_for_condition");
|
DBUG_ENTER("wait_for_condition");
|
||||||
if (!thd->killed)
|
if (!thd->killed)
|
||||||
(void) pthread_cond_wait(cond, mutex);
|
mysql_cond_wait(cond, mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We must unlock mutex first to avoid deadlock becasue conditions are
|
We must unlock mutex first to avoid deadlock becasue conditions are
|
||||||
@ -2209,12 +2209,12 @@ void wait_for_condition(THD *thd, pthread_mutex_t *mutex, pthread_cond_t *cond)
|
|||||||
mutex is unlocked
|
mutex is unlocked
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pthread_mutex_unlock(mutex);
|
mysql_mutex_unlock(mutex);
|
||||||
pthread_mutex_lock(&thd->mysys_var->mutex);
|
mysql_mutex_lock(&thd->mysys_var->mutex);
|
||||||
thd->mysys_var->current_mutex= 0;
|
thd->mysys_var->current_mutex= 0;
|
||||||
thd->mysys_var->current_cond= 0;
|
thd->mysys_var->current_cond= 0;
|
||||||
thd_proc_info(thd, proc_info);
|
thd_proc_info(thd, proc_info);
|
||||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
mysql_mutex_unlock(&thd->mysys_var->mutex);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2285,7 +2285,7 @@ bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in)
|
|||||||
TABLE orig_table;
|
TABLE orig_table;
|
||||||
DBUG_ENTER("reopen_name_locked_table");
|
DBUG_ENTER("reopen_name_locked_table");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
if (thd->killed || !table)
|
if (thd->killed || !table)
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
@ -2365,7 +2365,7 @@ TABLE *table_cache_insert_placeholder(THD *thd, const char *key,
|
|||||||
char *key_buff;
|
char *key_buff;
|
||||||
DBUG_ENTER("table_cache_insert_placeholder");
|
DBUG_ENTER("table_cache_insert_placeholder");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create a table entry with the right key and with an old refresh version
|
Create a table entry with the right key and with an old refresh version
|
||||||
@ -2425,24 +2425,24 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db,
|
|||||||
DBUG_ENTER("lock_table_name_if_not_cached");
|
DBUG_ENTER("lock_table_name_if_not_cached");
|
||||||
|
|
||||||
key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1;
|
key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
if (my_hash_search(&open_cache, (uchar *)key, key_length))
|
if (my_hash_search(&open_cache, (uchar *)key, key_length))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_PRINT("info", ("Table is cached, name-lock is not obtained"));
|
DBUG_PRINT("info", ("Table is cached, name-lock is not obtained"));
|
||||||
*table= 0;
|
*table= 0;
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
}
|
}
|
||||||
if (!(*table= table_cache_insert_placeholder(thd, key, key_length)))
|
if (!(*table= table_cache_insert_placeholder(thd, key, key_length)))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
(*table)->open_placeholder= 1;
|
(*table)->open_placeholder= 1;
|
||||||
(*table)->next= thd->open_tables;
|
(*table)->next= thd->open_tables;
|
||||||
thd->open_tables= *table;
|
thd->open_tables= *table;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2474,7 +2474,7 @@ bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists)
|
|||||||
int rc;
|
int rc;
|
||||||
DBUG_ENTER("check_if_table_exists");
|
DBUG_ENTER("check_if_table_exists");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
*exists= TRUE;
|
*exists= TRUE;
|
||||||
|
|
||||||
@ -2699,15 +2699,15 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
*/
|
*/
|
||||||
TABLE tab;
|
TABLE tab;
|
||||||
table= &tab;
|
table= &tab;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (!open_unireg_entry(thd, table, table_list, alias,
|
if (!open_unireg_entry(thd, table, table_list, alias,
|
||||||
key, key_length, mem_root, 0))
|
key, key_length, mem_root, 0))
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(table_list->view != 0);
|
DBUG_ASSERT(table_list->view != 0);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0); // VIEW
|
DBUG_RETURN(0); // VIEW
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -2740,7 +2740,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
on disk.
|
on disk.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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,
|
If it's the first table from a list of tables used in a query,
|
||||||
@ -2758,7 +2758,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
/* Someone did a refresh while thread was opening tables */
|
/* Someone did a refresh while thread was opening tables */
|
||||||
if (refresh)
|
if (refresh)
|
||||||
*refresh=1;
|
*refresh=1;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2824,7 +2824,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
/* Avoid self-deadlocks by detecting self-dependencies. */
|
/* Avoid self-deadlocks by detecting self-dependencies. */
|
||||||
if (table->open_placeholder && table->in_use == thd)
|
if (table->open_placeholder && table->in_use == thd)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), table->s->table_name.str);
|
my_error(ER_UPDATE_TABLE_USED, MYF(0), table->s->table_name.str);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
@ -2865,7 +2865,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
There is a refresh in progress for this table.
|
There is a refresh in progress for this table.
|
||||||
@ -2906,7 +2906,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
|
|
||||||
if (check_if_table_exists(thd, table_list, &exists))
|
if (check_if_table_exists(thd, table_list, &exists))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2917,7 +2917,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
*/
|
*/
|
||||||
if (!(table= table_cache_insert_placeholder(thd, key, key_length)))
|
if (!(table= table_cache_insert_placeholder(thd, key, key_length)))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -2928,7 +2928,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
table->open_placeholder= 1;
|
table->open_placeholder= 1;
|
||||||
table->next= thd->open_tables;
|
table->next= thd->open_tables;
|
||||||
thd->open_tables= table;
|
thd->open_tables= table;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(table);
|
DBUG_RETURN(table);
|
||||||
}
|
}
|
||||||
/* Table exists. Let us try to open it. */
|
/* Table exists. Let us try to open it. */
|
||||||
@ -2937,7 +2937,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
/* make a new table */
|
/* make a new table */
|
||||||
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
|
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2946,7 +2946,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
if (error > 0)
|
if (error > 0)
|
||||||
{
|
{
|
||||||
my_free((uchar*)table, MYF(0));
|
my_free((uchar*)table, MYF(0));
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
}
|
}
|
||||||
if (table_list->view || error < 0)
|
if (table_list->view || error < 0)
|
||||||
@ -2959,7 +2959,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
table_list->view= (LEX*)1;
|
table_list->view= (LEX*)1;
|
||||||
|
|
||||||
my_free((uchar*)table, MYF(0));
|
my_free((uchar*)table, MYF(0));
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0); // VIEW
|
DBUG_RETURN(0); // VIEW
|
||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("inserting table '%s'.'%s' 0x%lx into the cache",
|
DBUG_PRINT("info", ("inserting table '%s'.'%s' 0x%lx into the cache",
|
||||||
@ -2970,7 +2970,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||||||
|
|
||||||
check_unused(); // Debugging call
|
check_unused(); // Debugging call
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
if (refresh)
|
if (refresh)
|
||||||
{
|
{
|
||||||
table->next=thd->open_tables; /* Link into simple list */
|
table->next=thd->open_tables; /* Link into simple list */
|
||||||
@ -3174,7 +3174,7 @@ void close_data_files_and_morph_locks(THD *thd, const char *db,
|
|||||||
TABLE *table;
|
TABLE *table;
|
||||||
DBUG_ENTER("close_data_files_and_morph_locks");
|
DBUG_ENTER("close_data_files_and_morph_locks");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
if (thd->lock)
|
if (thd->lock)
|
||||||
{
|
{
|
||||||
@ -3313,7 +3313,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old)
|
|||||||
if (!thd->open_tables)
|
if (!thd->open_tables)
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
if (get_locks)
|
if (get_locks)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -3576,7 +3576,7 @@ bool wait_for_tables(THD *thd)
|
|||||||
DBUG_ENTER("wait_for_tables");
|
DBUG_ENTER("wait_for_tables");
|
||||||
|
|
||||||
thd_proc_info(thd, "Waiting for tables");
|
thd_proc_info(thd, "Waiting for tables");
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
while (!thd->killed)
|
while (!thd->killed)
|
||||||
{
|
{
|
||||||
thd->some_tables_deleted=0;
|
thd->some_tables_deleted=0;
|
||||||
@ -3584,7 +3584,7 @@ bool wait_for_tables(THD *thd)
|
|||||||
mysql_ha_flush(thd);
|
mysql_ha_flush(thd);
|
||||||
if (!table_is_used(thd->open_tables,1))
|
if (!table_is_used(thd->open_tables,1))
|
||||||
break;
|
break;
|
||||||
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
|
mysql_cond_wait(&COND_refresh, &LOCK_open);
|
||||||
}
|
}
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
result= 1; // aborted
|
result= 1; // aborted
|
||||||
@ -3595,7 +3595,7 @@ bool wait_for_tables(THD *thd)
|
|||||||
thd->version= refresh_version;
|
thd->version= refresh_version;
|
||||||
result=reopen_tables(thd,0,0);
|
result=reopen_tables(thd,0,0);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
thd_proc_info(thd, 0);
|
thd_proc_info(thd, 0);
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
@ -3748,7 +3748,7 @@ void assign_new_table_id(TABLE_SHARE *share)
|
|||||||
|
|
||||||
/* Preconditions */
|
/* Preconditions */
|
||||||
DBUG_ASSERT(share != NULL);
|
DBUG_ASSERT(share != NULL);
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
ulong tid= ++last_table_id; /* get next id */
|
ulong tid= ++last_table_id; /* get next id */
|
||||||
/*
|
/*
|
||||||
@ -3872,7 +3872,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
|
|||||||
uint discover_retry_count= 0;
|
uint discover_retry_count= 0;
|
||||||
DBUG_ENTER("open_unireg_entry");
|
DBUG_ENTER("open_unireg_entry");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
retry:
|
retry:
|
||||||
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
|
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
|
||||||
cache_key_length,
|
cache_key_length,
|
||||||
@ -4001,7 +4001,7 @@ retry:
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
thd->clear_error(); // Clear error message
|
thd->clear_error(); // Clear error message
|
||||||
error= 0;
|
error= 0;
|
||||||
if (open_table_from_share(thd, share, alias,
|
if (open_table_from_share(thd, share, alias,
|
||||||
@ -4024,7 +4024,7 @@ retry:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
thd->clear_error(); // Clear error message
|
thd->clear_error(); // Clear error message
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
@ -8430,10 +8430,10 @@ void remove_db_from_cache(const char *db)
|
|||||||
|
|
||||||
void flush_tables()
|
void flush_tables()
|
||||||
{
|
{
|
||||||
(void) pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
while (unused_tables)
|
while (unused_tables)
|
||||||
my_hash_delete(&open_cache,(uchar*) unused_tables);
|
my_hash_delete(&open_cache,(uchar*) unused_tables);
|
||||||
(void) pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -8504,15 +8504,15 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
|
|||||||
! in_use->killed)
|
! in_use->killed)
|
||||||
{
|
{
|
||||||
in_use->killed= THD::KILL_CONNECTION;
|
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)
|
if (in_use->mysys_var->current_cond)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(in_use->mysys_var->current_mutex);
|
mysql_mutex_lock(in_use->mysys_var->current_mutex);
|
||||||
signalled= 1;
|
signalled= 1;
|
||||||
pthread_cond_broadcast(in_use->mysys_var->current_cond);
|
mysql_cond_broadcast(in_use->mysys_var->current_cond);
|
||||||
pthread_mutex_unlock(in_use->mysys_var->current_mutex);
|
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);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Now we must abort all tables locks used by this thread
|
Now we must abort all tables locks used by this thread
|
||||||
@ -8569,7 +8569,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
|
|||||||
{
|
{
|
||||||
dropping_tables++;
|
dropping_tables++;
|
||||||
if (likely(signalled))
|
if (likely(signalled))
|
||||||
(void) pthread_cond_wait(&COND_refresh, &LOCK_open);
|
mysql_cond_wait(&COND_refresh, &LOCK_open);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
@ -8584,7 +8584,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
|
|||||||
remove_table_from_cache routine.
|
remove_table_from_cache routine.
|
||||||
*/
|
*/
|
||||||
set_timespec(abstime, 10);
|
set_timespec(abstime, 10);
|
||||||
pthread_cond_timedwait(&COND_refresh, &LOCK_open, &abstime);
|
mysql_cond_timedwait(&COND_refresh, &LOCK_open, &abstime);
|
||||||
}
|
}
|
||||||
dropping_tables--;
|
dropping_tables--;
|
||||||
continue;
|
continue;
|
||||||
@ -8730,12 +8730,12 @@ int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
|
|||||||
DBUG_ENTER("abort_and_upgrade_locks");
|
DBUG_ENTER("abort_and_upgrade_locks");
|
||||||
|
|
||||||
lpt->old_lock_type= lpt->table->reginfo.lock_type;
|
lpt->old_lock_type= lpt->table->reginfo.lock_type;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
/* If MERGE child, forward lock handling to parent. */
|
/* If MERGE child, forward lock handling to parent. */
|
||||||
mysql_lock_abort(lpt->thd, lpt->table->parent ? lpt->table->parent :
|
mysql_lock_abort(lpt->thd, lpt->table->parent ? lpt->table->parent :
|
||||||
lpt->table, TRUE);
|
lpt->table, TRUE);
|
||||||
(void) remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, flags);
|
(void) remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, flags);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8757,10 +8757,10 @@ int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
|
|||||||
/* purecov: begin deadcode */
|
/* purecov: begin deadcode */
|
||||||
void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt)
|
void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name,
|
remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name,
|
||||||
RTFC_WAIT_OTHER_THREAD_FLAG);
|
RTFC_WAIT_OTHER_THREAD_FLAG);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
/* If MERGE child, forward lock handling to parent. */
|
/* If MERGE child, forward lock handling to parent. */
|
||||||
mysql_lock_downgrade_write(lpt->thd, lpt->table->parent ? lpt->table->parent :
|
mysql_lock_downgrade_write(lpt->thd, lpt->table->parent ? lpt->table->parent :
|
||||||
lpt->table, lpt->old_lock_type);
|
lpt->table, lpt->old_lock_type);
|
||||||
@ -8799,7 +8799,7 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
|
|||||||
DBUG_ENTER("mysql_wait_completed_table");
|
DBUG_ENTER("mysql_wait_completed_table");
|
||||||
|
|
||||||
key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1;
|
key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
HASH_SEARCH_STATE state;
|
HASH_SEARCH_STATE state;
|
||||||
for (table= (TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length,
|
for (table= (TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length,
|
||||||
&state) ;
|
&state) ;
|
||||||
@ -8820,14 +8820,14 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
|
|||||||
! in_use->killed)
|
! in_use->killed)
|
||||||
{
|
{
|
||||||
in_use->killed= THD::KILL_CONNECTION;
|
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)
|
if (in_use->mysys_var->current_cond)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(in_use->mysys_var->current_mutex);
|
mysql_mutex_lock(in_use->mysys_var->current_mutex);
|
||||||
pthread_cond_broadcast(in_use->mysys_var->current_cond);
|
mysql_cond_broadcast(in_use->mysys_var->current_cond);
|
||||||
pthread_mutex_unlock(in_use->mysys_var->current_mutex);
|
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);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Now we must abort all tables locks used by this thread
|
Now we must abort all tables locks used by this thread
|
||||||
@ -8857,7 +8857,7 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
|
|||||||
*/
|
*/
|
||||||
mysql_lock_abort(lpt->thd, my_table->parent ? my_table->parent : my_table,
|
mysql_lock_abort(lpt->thd, my_table->parent ? my_table->parent : my_table,
|
||||||
FALSE);
|
FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9096,7 +9096,7 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
|
|||||||
mysql_unlock_tables(thd, thd->lock);
|
mysql_unlock_tables(thd, thd->lock);
|
||||||
thd->lock= 0;
|
thd->lock= 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
found_old_table= false;
|
found_old_table= false;
|
||||||
/*
|
/*
|
||||||
@ -9112,7 +9112,7 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
|
|||||||
if (found_old_table)
|
if (found_old_table)
|
||||||
broadcast_refresh();
|
broadcast_refresh();
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
thd->restore_backup_open_tables_state(backup);
|
thd->restore_backup_open_tables_state(backup);
|
||||||
}
|
}
|
||||||
|
@ -957,9 +957,9 @@ void THD::init_for_queries()
|
|||||||
|
|
||||||
void THD::change_user(void)
|
void THD::change_user(void)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_status);
|
mysql_mutex_lock(&LOCK_status);
|
||||||
add_to_status(&global_status_var, &status_var);
|
add_to_status(&global_status_var, &status_var);
|
||||||
pthread_mutex_unlock(&LOCK_status);
|
mysql_mutex_unlock(&LOCK_status);
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
killed= NOT_KILLED;
|
killed= NOT_KILLED;
|
||||||
@ -1018,9 +1018,9 @@ void THD::cleanup(void)
|
|||||||
unlock_global_read_lock(this);
|
unlock_global_read_lock(this);
|
||||||
if (ull)
|
if (ull)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_user_locks);
|
mysql_mutex_lock(&LOCK_user_locks);
|
||||||
item_user_lock_release(ull);
|
item_user_lock_release(ull);
|
||||||
pthread_mutex_unlock(&LOCK_user_locks);
|
mysql_mutex_unlock(&LOCK_user_locks);
|
||||||
ull= NULL;
|
ull= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,7 +1159,7 @@ void THD::awake(THD::killed_state state_to_set)
|
|||||||
}
|
}
|
||||||
if (mysys_var)
|
if (mysys_var)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mysys_var->mutex);
|
mysql_mutex_lock(&mysys_var->mutex);
|
||||||
if (!system_thread) // Don't abort locks
|
if (!system_thread) // Don't abort locks
|
||||||
mysys_var->abort=1;
|
mysys_var->abort=1;
|
||||||
/*
|
/*
|
||||||
@ -1183,11 +1183,11 @@ void THD::awake(THD::killed_state state_to_set)
|
|||||||
*/
|
*/
|
||||||
if (mysys_var->current_cond && mysys_var->current_mutex)
|
if (mysys_var->current_cond && mysys_var->current_mutex)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(mysys_var->current_mutex);
|
mysql_mutex_lock(mysys_var->current_mutex);
|
||||||
pthread_cond_broadcast(mysys_var->current_cond);
|
mysql_cond_broadcast(mysys_var->current_cond);
|
||||||
pthread_mutex_unlock(mysys_var->current_mutex);
|
mysql_mutex_unlock(mysys_var->current_mutex);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mysys_var->mutex);
|
mysql_mutex_unlock(&mysys_var->mutex);
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@ -1874,21 +1874,21 @@ public:
|
|||||||
enter_cond(); this mutex is then released by exit_cond().
|
enter_cond(); this mutex is then released by exit_cond().
|
||||||
Usage must be: lock mutex; enter_cond(); your code; 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* msg)
|
||||||
{
|
{
|
||||||
const char* old_msg = proc_info;
|
const char* old_msg = proc_info;
|
||||||
safe_mutex_assert_owner(mutex);
|
mysql_mutex_assert_owner(mutex);
|
||||||
mysys_var->current_mutex = mutex;
|
mysys_var->current_mutex = mutex;
|
||||||
mysys_var->current_cond = cond;
|
mysys_var->current_cond = cond;
|
||||||
proc_info = msg;
|
proc_info = msg;
|
||||||
return old_msg;
|
return old_msg;
|
||||||
}
|
}
|
||||||
inline const char* enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex,
|
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
/* TO BE REMOVED: temporary helper, to help with merges */
|
/* TO BE REMOVED: temporary helper, to help with merges */
|
||||||
return enter_cond(&cond->m_cond, &mutex->m_mutex, msg);
|
return enter_cond((mysql_cond_t*) cond, (mysql_mutex_t*) mutex, msg);
|
||||||
}
|
}
|
||||||
inline void exit_cond(const char* old_msg)
|
inline void exit_cond(const char* old_msg)
|
||||||
{
|
{
|
||||||
@ -1898,12 +1898,12 @@ public:
|
|||||||
locked (if that would not be the case, you'll get a deadlock if someone
|
locked (if that would not be the case, you'll get a deadlock if someone
|
||||||
does a THD::awake() on you).
|
does a THD::awake() on you).
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(mysys_var->current_mutex);
|
mysql_mutex_unlock(mysys_var->current_mutex);
|
||||||
pthread_mutex_lock(&mysys_var->mutex);
|
mysql_mutex_lock(&mysys_var->mutex);
|
||||||
mysys_var->current_mutex = 0;
|
mysys_var->current_mutex = 0;
|
||||||
mysys_var->current_cond = 0;
|
mysys_var->current_cond = 0;
|
||||||
proc_info = old_msg;
|
proc_info = old_msg;
|
||||||
pthread_mutex_unlock(&mysys_var->mutex);
|
mysql_mutex_unlock(&mysys_var->mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inline time_t query_start() { query_start_used=1; return start_time; }
|
inline time_t query_start() { query_start_used=1; return start_time; }
|
||||||
|
116
sql/sql_db.cc
116
sql/sql_db.cc
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000-2003 MySQL AB
|
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -47,7 +47,7 @@ static void mysql_change_db_impl(THD *thd,
|
|||||||
|
|
||||||
/* Database lock hash */
|
/* Database lock hash */
|
||||||
HASH lock_db_cache;
|
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
|
int creating_database= 0; // how many database locks are made
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ static my_bool lock_db_insert(const char *dbname, uint length)
|
|||||||
my_bool error= 0;
|
my_bool error= 0;
|
||||||
DBUG_ENTER("lock_db_insert");
|
DBUG_ENTER("lock_db_insert");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_lock_db);
|
mysql_mutex_assert_owner(&LOCK_lock_db);
|
||||||
|
|
||||||
if (!(opt= (my_dblock_t*) my_hash_search(&lock_db_cache,
|
if (!(opt= (my_dblock_t*) my_hash_search(&lock_db_cache,
|
||||||
(uchar*) dbname, length)))
|
(uchar*) dbname, length)))
|
||||||
@ -138,7 +138,7 @@ end:
|
|||||||
void lock_db_delete(const char *name, uint length)
|
void lock_db_delete(const char *name, uint length)
|
||||||
{
|
{
|
||||||
my_dblock_t *opt;
|
my_dblock_t *opt;
|
||||||
safe_mutex_assert_owner(&LOCK_lock_db);
|
mysql_mutex_assert_owner(&LOCK_lock_db);
|
||||||
if ((opt= (my_dblock_t *)my_hash_search(&lock_db_cache,
|
if ((opt= (my_dblock_t *)my_hash_search(&lock_db_cache,
|
||||||
(const uchar*) name, length)))
|
(const uchar*) name, length)))
|
||||||
my_hash_delete(&lock_db_cache, (uchar*) opt);
|
my_hash_delete(&lock_db_cache, (uchar*) opt);
|
||||||
@ -148,7 +148,7 @@ void lock_db_delete(const char *name, uint length)
|
|||||||
/* Database options hash */
|
/* Database options hash */
|
||||||
static HASH dboptions;
|
static HASH dboptions;
|
||||||
static my_bool dboptions_init= 0;
|
static my_bool dboptions_init= 0;
|
||||||
static rw_lock_t LOCK_dboptions;
|
static mysql_rwlock_t LOCK_dboptions;
|
||||||
|
|
||||||
/* Structure for database options */
|
/* Structure for database options */
|
||||||
typedef struct my_dbopt_st
|
typedef struct my_dbopt_st
|
||||||
@ -199,6 +199,26 @@ void free_dbopt(void *dbopt)
|
|||||||
my_free((uchar*) dbopt, MYF(0));
|
my_free((uchar*) dbopt, MYF(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
static PSI_rwlock_key key_rwlock_LOCK_dboptions;
|
||||||
|
|
||||||
|
static PSI_rwlock_info all_database_names_rwlocks[]=
|
||||||
|
{
|
||||||
|
{ &key_rwlock_LOCK_dboptions, "LOCK_dboptions", PSI_FLAG_GLOBAL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void init_database_names_psi_keys(void)
|
||||||
|
{
|
||||||
|
const char* category= "sql";
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (PSI_server == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count= array_elements(all_database_names_rwlocks);
|
||||||
|
PSI_server->register_rwlock(category, all_database_names_rwlocks, count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initialize database option hash and locked database hash.
|
Initialize database option hash and locked database hash.
|
||||||
@ -216,8 +236,12 @@ void free_dbopt(void *dbopt)
|
|||||||
|
|
||||||
bool my_database_names_init(void)
|
bool my_database_names_init(void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
|
init_database_names_psi_keys();
|
||||||
|
#endif
|
||||||
|
|
||||||
bool error= 0;
|
bool error= 0;
|
||||||
(void) my_rwlock_init(&LOCK_dboptions, NULL);
|
mysql_rwlock_init(key_rwlock_LOCK_dboptions, &LOCK_dboptions);
|
||||||
if (!dboptions_init)
|
if (!dboptions_init)
|
||||||
{
|
{
|
||||||
dboptions_init= 1;
|
dboptions_init= 1;
|
||||||
@ -246,7 +270,7 @@ void my_database_names_free(void)
|
|||||||
{
|
{
|
||||||
dboptions_init= 0;
|
dboptions_init= 0;
|
||||||
my_hash_free(&dboptions);
|
my_hash_free(&dboptions);
|
||||||
(void) rwlock_destroy(&LOCK_dboptions);
|
mysql_rwlock_destroy(&LOCK_dboptions);
|
||||||
my_hash_free(&lock_db_cache);
|
my_hash_free(&lock_db_cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,13 +282,13 @@ void my_database_names_free(void)
|
|||||||
|
|
||||||
void my_dbopt_cleanup(void)
|
void my_dbopt_cleanup(void)
|
||||||
{
|
{
|
||||||
rw_wrlock(&LOCK_dboptions);
|
mysql_rwlock_wrlock(&LOCK_dboptions);
|
||||||
my_hash_free(&dboptions);
|
my_hash_free(&dboptions);
|
||||||
my_hash_init(&dboptions, lower_case_table_names ?
|
my_hash_init(&dboptions, lower_case_table_names ?
|
||||||
&my_charset_bin : system_charset_info,
|
&my_charset_bin : system_charset_info,
|
||||||
32, 0, 0, (my_hash_get_key) dboptions_get_key,
|
32, 0, 0, (my_hash_get_key) dboptions_get_key,
|
||||||
free_dbopt,0);
|
free_dbopt,0);
|
||||||
rw_unlock(&LOCK_dboptions);
|
mysql_rwlock_unlock(&LOCK_dboptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -288,13 +312,13 @@ static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create)
|
|||||||
|
|
||||||
length= (uint) strlen(dbname);
|
length= (uint) strlen(dbname);
|
||||||
|
|
||||||
rw_rdlock(&LOCK_dboptions);
|
mysql_rwlock_rdlock(&LOCK_dboptions);
|
||||||
if ((opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname, length)))
|
if ((opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname, length)))
|
||||||
{
|
{
|
||||||
create->default_table_charset= opt->charset;
|
create->default_table_charset= opt->charset;
|
||||||
error= 0;
|
error= 0;
|
||||||
}
|
}
|
||||||
rw_unlock(&LOCK_dboptions);
|
mysql_rwlock_unlock(&LOCK_dboptions);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +344,7 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create)
|
|||||||
|
|
||||||
length= (uint) strlen(dbname);
|
length= (uint) strlen(dbname);
|
||||||
|
|
||||||
rw_wrlock(&LOCK_dboptions);
|
mysql_rwlock_wrlock(&LOCK_dboptions);
|
||||||
if (!(opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname,
|
if (!(opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname,
|
||||||
length)))
|
length)))
|
||||||
{
|
{
|
||||||
@ -349,7 +373,7 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create)
|
|||||||
opt->charset= create->default_table_charset;
|
opt->charset= create->default_table_charset;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
rw_unlock(&LOCK_dboptions);
|
mysql_rwlock_unlock(&LOCK_dboptions);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,11 +385,11 @@ end:
|
|||||||
void del_dbopt(const char *path)
|
void del_dbopt(const char *path)
|
||||||
{
|
{
|
||||||
my_dbopt_t *opt;
|
my_dbopt_t *opt;
|
||||||
rw_wrlock(&LOCK_dboptions);
|
mysql_rwlock_wrlock(&LOCK_dboptions);
|
||||||
if ((opt= (my_dbopt_t *)my_hash_search(&dboptions, (const uchar*) path,
|
if ((opt= (my_dbopt_t *)my_hash_search(&dboptions, (const uchar*) path,
|
||||||
strlen(path))))
|
strlen(path))))
|
||||||
my_hash_delete(&dboptions, (uchar*) opt);
|
my_hash_delete(&dboptions, (uchar*) opt);
|
||||||
rw_unlock(&LOCK_dboptions);
|
mysql_rwlock_unlock(&LOCK_dboptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -392,7 +416,8 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
|
|||||||
if (put_dbopt(path, create))
|
if (put_dbopt(path, create))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0)
|
if ((file= mysql_file_create(key_file_dbopt, path, CREATE_MODE,
|
||||||
|
O_RDWR | O_TRUNC, MYF(MY_WME))) >= 0)
|
||||||
{
|
{
|
||||||
ulong length;
|
ulong length;
|
||||||
length= (ulong) (strxnmov(buf, sizeof(buf)-1, "default-character-set=",
|
length= (ulong) (strxnmov(buf, sizeof(buf)-1, "default-character-set=",
|
||||||
@ -401,10 +426,10 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
|
|||||||
create->default_table_charset->name,
|
create->default_table_charset->name,
|
||||||
"\n", NullS) - buf);
|
"\n", NullS) - buf);
|
||||||
|
|
||||||
/* Error is written by my_write */
|
/* Error is written by mysql_file_write */
|
||||||
if (!my_write(file,(uchar*) buf, length, MYF(MY_NABP+MY_WME)))
|
if (!mysql_file_write(file, (uchar*) buf, length, MYF(MY_NABP+MY_WME)))
|
||||||
error=0;
|
error=0;
|
||||||
my_close(file,MYF(0));
|
mysql_file_close(file, MYF(0));
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -441,7 +466,8 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
|
|||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
/* Otherwise, load options from the .opt file */
|
/* Otherwise, load options from the .opt file */
|
||||||
if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0)
|
if ((file= mysql_file_open(key_file_dbopt,
|
||||||
|
path, O_RDONLY | O_SHARE, MYF(0))) < 0)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
IO_CACHE cache;
|
IO_CACHE cache;
|
||||||
@ -499,7 +525,7 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
|
|||||||
|
|
||||||
end_io_cache(&cache);
|
end_io_cache(&cache);
|
||||||
err2:
|
err2:
|
||||||
my_close(file,MYF(0));
|
mysql_file_close(file, MYF(0));
|
||||||
err1:
|
err1:
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@ -643,13 +669,13 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
|
|||||||
goto exit2;
|
goto exit2;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_mysql_create_db);
|
mysql_mutex_lock(&LOCK_mysql_create_db);
|
||||||
|
|
||||||
/* Check directory */
|
/* Check directory */
|
||||||
path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
|
path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
|
||||||
path[path_len-1]= 0; // Remove last '/' from path
|
path[path_len-1]= 0; // Remove last '/' from path
|
||||||
|
|
||||||
if (my_stat(path,&stat_info,MYF(0)))
|
if (mysql_file_stat(key_file_misc, path, &stat_info, MYF(0)))
|
||||||
{
|
{
|
||||||
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
|
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
|
||||||
{
|
{
|
||||||
@ -753,7 +779,7 @@ not_silent:
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
pthread_mutex_unlock(&LOCK_mysql_create_db);
|
mysql_mutex_unlock(&LOCK_mysql_create_db);
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
exit2:
|
exit2:
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
@ -784,7 +810,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
|
|||||||
if ((error=wait_if_global_read_lock(thd,0,1)))
|
if ((error=wait_if_global_read_lock(thd,0,1)))
|
||||||
goto exit2;
|
goto exit2;
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_mysql_create_db);
|
mysql_mutex_lock(&LOCK_mysql_create_db);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Recreate db options file: /dbpath/.db.opt
|
Recreate db options file: /dbpath/.db.opt
|
||||||
@ -830,7 +856,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
|
|||||||
my_ok(thd, result);
|
my_ok(thd, result);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
pthread_mutex_unlock(&LOCK_mysql_create_db);
|
mysql_mutex_unlock(&LOCK_mysql_create_db);
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
exit2:
|
exit2:
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
@ -882,7 +908,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
|||||||
goto exit2;
|
goto exit2;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_mysql_create_db);
|
mysql_mutex_lock(&LOCK_mysql_create_db);
|
||||||
|
|
||||||
length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
|
length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
|
||||||
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
|
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
|
||||||
@ -904,9 +930,9 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
remove_db_from_cache(db);
|
remove_db_from_cache(db);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
Drop_table_error_handler err_handler(thd->get_internal_handler());
|
Drop_table_error_handler err_handler(thd->get_internal_handler());
|
||||||
thd->push_internal_handler(&err_handler);
|
thd->push_internal_handler(&err_handler);
|
||||||
@ -1030,7 +1056,7 @@ exit:
|
|||||||
*/
|
*/
|
||||||
if (thd->db && !strcmp(thd->db, db) && error == 0)
|
if (thd->db && !strcmp(thd->db, db) && error == 0)
|
||||||
mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
|
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);
|
start_waiting_global_read_lock(thd);
|
||||||
exit2:
|
exit2:
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
@ -1156,7 +1182,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
strxmov(filePath, org_path, "/", file->name, NullS);
|
strxmov(filePath, org_path, "/", file->name, NullS);
|
||||||
if (my_delete_with_symlink(filePath,MYF(MY_WME)))
|
if (mysql_file_delete_with_symlink(key_file_misc, filePath, MYF(MY_WME)))
|
||||||
{
|
{
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -1234,7 +1260,7 @@ static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error)
|
|||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
if (my_delete(path, MYF(send_error ? MY_WME : 0)))
|
if (mysql_file_delete(key_file_misc, path, MYF(send_error ? MY_WME : 0)))
|
||||||
{
|
{
|
||||||
DBUG_RETURN(send_error);
|
DBUG_RETURN(send_error);
|
||||||
}
|
}
|
||||||
@ -1311,7 +1337,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
strxmov(filePath, org_path, "/", file->name, NullS);
|
strxmov(filePath, org_path, "/", file->name, NullS);
|
||||||
if (my_delete_with_symlink(filePath,MYF(MY_WME)))
|
if (mysql_file_delete_with_symlink(key_file_misc, filePath, MYF(MY_WME)))
|
||||||
{
|
{
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -1718,18 +1744,18 @@ static int
|
|||||||
lock_databases(THD *thd, const char *db1, uint length1,
|
lock_databases(THD *thd, const char *db1, uint length1,
|
||||||
const char *db2, uint length2)
|
const char *db2, uint length2)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
while (!thd->killed &&
|
while (!thd->killed &&
|
||||||
(my_hash_search(&lock_db_cache,(uchar*) db1, length1) ||
|
(my_hash_search(&lock_db_cache,(uchar*) db1, length1) ||
|
||||||
my_hash_search(&lock_db_cache,(uchar*) db2, length2)))
|
my_hash_search(&lock_db_cache,(uchar*) db2, length2)))
|
||||||
{
|
{
|
||||||
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
|
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1746,7 +1772,7 @@ lock_databases(THD *thd, const char *db1, uint length1,
|
|||||||
while (!thd->killed && creating_table)
|
while (!thd->killed && creating_table)
|
||||||
{
|
{
|
||||||
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
|
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
@ -1754,8 +1780,8 @@ lock_databases(THD *thd, const char *db1, uint length1,
|
|||||||
lock_db_delete(db1, length1);
|
lock_db_delete(db1, length1);
|
||||||
lock_db_delete(db2, length2);
|
lock_db_delete(db2, length2);
|
||||||
creating_database--;
|
creating_database--;
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
pthread_cond_signal(&COND_refresh);
|
mysql_cond_signal(&COND_refresh);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1763,7 +1789,7 @@ lock_databases(THD *thd, const char *db1, uint length1,
|
|||||||
We can unlock now as the hash will protect against anyone creating a table
|
We can unlock now as the hash will protect against anyone creating a table
|
||||||
in the databases we are using
|
in the databases we are using
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1892,7 +1918,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
|
|||||||
*/
|
*/
|
||||||
build_table_filename(path, sizeof(path)-1,
|
build_table_filename(path, sizeof(path)-1,
|
||||||
new_db.str,"",MY_DB_OPT_FILE, 0);
|
new_db.str,"",MY_DB_OPT_FILE, 0);
|
||||||
my_delete(path, MYF(MY_WME));
|
mysql_file_delete(key_file_dbopt, path, MYF(MY_WME));
|
||||||
length= build_table_filename(path, sizeof(path)-1, new_db.str, "", "", 0);
|
length= build_table_filename(path, sizeof(path)-1, new_db.str, "", "", 0);
|
||||||
if (length && path[length-1] == FN_LIBCHAR)
|
if (length && path[length-1] == FN_LIBCHAR)
|
||||||
path[length-1]=0; // remove ending '\'
|
path[length-1]=0; // remove ending '\'
|
||||||
@ -1948,7 +1974,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
|
|||||||
old_db->str, "", file->name, 0);
|
old_db->str, "", file->name, 0);
|
||||||
build_table_filename(newname, sizeof(newname)-1,
|
build_table_filename(newname, sizeof(newname)-1,
|
||||||
new_db.str, "", file->name, 0);
|
new_db.str, "", file->name, 0);
|
||||||
my_rename(oldname, newname, MYF(MY_WME));
|
mysql_file_rename(key_file_misc, oldname, newname, MYF(MY_WME));
|
||||||
}
|
}
|
||||||
my_dirend(dirp);
|
my_dirend(dirp);
|
||||||
}
|
}
|
||||||
@ -1976,14 +2002,14 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
|
|||||||
error|= mysql_change_db(thd, & new_db, FALSE);
|
error|= mysql_change_db(thd, & new_db, FALSE);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
/* Remove the databases from db lock cache */
|
/* Remove the databases from db lock cache */
|
||||||
lock_db_delete(old_db->str, old_db->length);
|
lock_db_delete(old_db->str, old_db->length);
|
||||||
lock_db_delete(new_db.str, new_db.length);
|
lock_db_delete(new_db.str, new_db.length);
|
||||||
creating_database--;
|
creating_database--;
|
||||||
/* Signal waiting CREATE TABLE's to continue */
|
/* Signal waiting CREATE TABLE's to continue */
|
||||||
pthread_cond_signal(&COND_refresh);
|
mysql_cond_signal(&COND_refresh);
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
|
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
@ -1166,10 +1166,10 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
|
|||||||
// crashes, replacement works. *(path + path_length - reg_ext_length)=
|
// crashes, replacement works. *(path + path_length - reg_ext_length)=
|
||||||
// '\0';
|
// '\0';
|
||||||
path[path_length - reg_ext_length] = 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,
|
error= ha_create_table(thd, path, table_list->db, table_list->table_name,
|
||||||
&create_info, 1);
|
&create_info, 1);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
query_cache_invalidate3(thd, table_list, 0);
|
query_cache_invalidate3(thd, table_list, 0);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
@ -1184,15 +1184,15 @@ end:
|
|||||||
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||||
my_ok(thd); // This should return record count
|
my_ok(thd); // This should return record count
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
else if (error)
|
else if (error)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
|
@ -143,14 +143,14 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables,
|
|||||||
{
|
{
|
||||||
(*table_ptr)->file->ha_index_or_rnd_end();
|
(*table_ptr)->file->ha_index_or_rnd_end();
|
||||||
if (! is_locked)
|
if (! is_locked)
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (close_thread_table(thd, table_ptr))
|
if (close_thread_table(thd, table_ptr))
|
||||||
{
|
{
|
||||||
/* Tell threads waiting for refresh that something has happened */
|
/* Tell threads waiting for refresh that something has happened */
|
||||||
broadcast_refresh();
|
broadcast_refresh();
|
||||||
}
|
}
|
||||||
if (! is_locked)
|
if (! is_locked)
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
else if (tables->table)
|
else if (tables->table)
|
||||||
{
|
{
|
||||||
@ -775,7 +775,7 @@ void mysql_ha_flush(THD *thd)
|
|||||||
TABLE_LIST *hash_tables;
|
TABLE_LIST *hash_tables;
|
||||||
DBUG_ENTER("mysql_ha_flush");
|
DBUG_ENTER("mysql_ha_flush");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
for (uint i= 0; i < thd->handler_tables_hash.records; i++)
|
for (uint i= 0; i < thd->handler_tables_hash.records; i++)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -888,7 +888,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
|||||||
thd->net.last_error/errno. For example if there has
|
thd->net.last_error/errno. For example if there has
|
||||||
been a disk full error when writing the row, and it was
|
been a disk full error when writing the row, and it was
|
||||||
MyISAM, then thd->net.last_error/errno will be set to
|
MyISAM, then thd->net.last_error/errno will be set to
|
||||||
"disk full"... and the my_pwrite() will wait until free
|
"disk full"... and the mysql_file_pwrite() will wait until free
|
||||||
space appears, and so when it finishes then the
|
space appears, and so when it finishes then the
|
||||||
write_row() was entirely successful
|
write_row() was entirely successful
|
||||||
*/
|
*/
|
||||||
@ -1730,8 +1730,8 @@ class Delayed_insert :public ilink {
|
|||||||
public:
|
public:
|
||||||
THD thd;
|
THD thd;
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
pthread_mutex_t mutex;
|
mysql_mutex_t mutex;
|
||||||
pthread_cond_t cond,cond_client;
|
mysql_cond_t cond, cond_client;
|
||||||
volatile uint tables_in_use,stacked_inserts;
|
volatile uint tables_in_use,stacked_inserts;
|
||||||
volatile bool status,dead;
|
volatile bool status,dead;
|
||||||
COPY_INFO info;
|
COPY_INFO info;
|
||||||
@ -1763,9 +1763,9 @@ public:
|
|||||||
thd.system_thread= SYSTEM_THREAD_DELAYED_INSERT;
|
thd.system_thread= SYSTEM_THREAD_DELAYED_INSERT;
|
||||||
thd.security_ctx->host_or_ip= "";
|
thd.security_ctx->host_or_ip= "";
|
||||||
bzero((char*) &info,sizeof(info));
|
bzero((char*) &info,sizeof(info));
|
||||||
pthread_mutex_init(&mutex,MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_delayed_insert_mutex, &mutex, MY_MUTEX_INIT_FAST);
|
||||||
pthread_cond_init(&cond,NULL);
|
mysql_cond_init(key_delayed_insert_cond, &cond, NULL);
|
||||||
pthread_cond_init(&cond_client,NULL);
|
mysql_cond_init(key_delayed_insert_cond_client, &cond_client, NULL);
|
||||||
pthread_mutex_lock(&LOCK_thread_count);
|
pthread_mutex_lock(&LOCK_thread_count);
|
||||||
delayed_insert_threads++;
|
delayed_insert_threads++;
|
||||||
delayed_lock= global_system_variables.low_priority_updates ?
|
delayed_lock= global_system_variables.low_priority_updates ?
|
||||||
@ -1781,9 +1781,9 @@ public:
|
|||||||
if (table)
|
if (table)
|
||||||
close_thread_tables(&thd);
|
close_thread_tables(&thd);
|
||||||
pthread_mutex_lock(&LOCK_thread_count);
|
pthread_mutex_lock(&LOCK_thread_count);
|
||||||
pthread_mutex_destroy(&mutex);
|
mysql_mutex_destroy(&mutex);
|
||||||
pthread_cond_destroy(&cond);
|
mysql_cond_destroy(&cond);
|
||||||
pthread_cond_destroy(&cond_client);
|
mysql_cond_destroy(&cond_client);
|
||||||
thd.unlink(); // Must be unlinked under lock
|
thd.unlink(); // Must be unlinked under lock
|
||||||
x_free(thd.query());
|
x_free(thd.query());
|
||||||
thd.security_ctx->user= thd.security_ctx->host=0;
|
thd.security_ctx->user= thd.security_ctx->host=0;
|
||||||
@ -1800,18 +1800,18 @@ public:
|
|||||||
}
|
}
|
||||||
void unlock()
|
void unlock()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_delayed_insert);
|
mysql_mutex_lock(&LOCK_delayed_insert);
|
||||||
if (!--locks_in_memory)
|
if (!--locks_in_memory)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
if (thd.killed && ! stacked_inserts && ! tables_in_use)
|
if (thd.killed && ! stacked_inserts && ! tables_in_use)
|
||||||
{
|
{
|
||||||
pthread_cond_signal(&cond);
|
mysql_cond_signal(&cond);
|
||||||
status=1;
|
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; }
|
inline uint lock_count() { return locks_in_memory; }
|
||||||
|
|
||||||
@ -1832,7 +1832,7 @@ static
|
|||||||
Delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
|
Delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
|
||||||
{
|
{
|
||||||
thd_proc_info(thd, "waiting for delay_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);
|
I_List_iterator<Delayed_insert> it(delayed_threads);
|
||||||
Delayed_insert *di;
|
Delayed_insert *di;
|
||||||
while ((di= it++))
|
while ((di= it++))
|
||||||
@ -1844,7 +1844,7 @@ Delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_delayed_insert); // For unlink from list
|
mysql_mutex_unlock(&LOCK_delayed_insert); // For unlink from list
|
||||||
return di;
|
return di;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1914,7 +1914,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
|
if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
thd_proc_info(thd, "Creating delayed handler");
|
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.
|
The first search above was done without LOCK_delayed_create.
|
||||||
Another thread might have created the handler in between. Search again.
|
Another thread might have created the handler in between. Search again.
|
||||||
@ -1940,14 +1940,15 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
di->table_list.alias= di->table_list.table_name= di->thd.query();
|
di->table_list.alias= di->table_list.table_name= di->thd.query();
|
||||||
di->table_list.db= di->thd.db;
|
di->table_list.db= di->thd.db;
|
||||||
di->lock();
|
di->lock();
|
||||||
pthread_mutex_lock(&di->mutex);
|
mysql_mutex_lock(&di->mutex);
|
||||||
if ((error= pthread_create(&di->thd.real_id, &connection_attrib,
|
if ((error= mysql_thread_create(key_thread_delayed_insert,
|
||||||
handle_delayed_insert, (void*) di)))
|
&di->thd.real_id, &connection_attrib,
|
||||||
|
handle_delayed_insert, (void*) di)))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("error",
|
DBUG_PRINT("error",
|
||||||
("Can't create thread to handle delayed insert (error %d)",
|
("Can't create thread to handle delayed insert (error %d)",
|
||||||
error));
|
error));
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
di->unlock();
|
di->unlock();
|
||||||
delete di;
|
delete di;
|
||||||
my_error(ER_CANT_CREATE_THREAD, MYF(ME_FATALERROR), error);
|
my_error(ER_CANT_CREATE_THREAD, MYF(ME_FATALERROR), error);
|
||||||
@ -1958,9 +1959,9 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
thd_proc_info(thd, "waiting for handler open");
|
thd_proc_info(thd, "waiting for handler open");
|
||||||
while (!di->thd.killed && !di->table && !thd->killed)
|
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");
|
thd_proc_info(thd, "got old table");
|
||||||
if (di->thd.killed)
|
if (di->thd.killed)
|
||||||
{
|
{
|
||||||
@ -1983,16 +1984,16 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
di->unlock();
|
di->unlock();
|
||||||
goto end_create;
|
goto end_create;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_delayed_insert);
|
mysql_mutex_lock(&LOCK_delayed_insert);
|
||||||
delayed_threads.append(di);
|
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);
|
table_list->table= di->get_local_table(thd);
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
if (table_list->table)
|
if (table_list->table)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(! thd->is_error());
|
DBUG_ASSERT(! thd->is_error());
|
||||||
@ -2003,7 +2004,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
DBUG_RETURN((table_list->table == NULL));
|
DBUG_RETURN((table_list->table == NULL));
|
||||||
|
|
||||||
end_create:
|
end_create:
|
||||||
pthread_mutex_unlock(&LOCK_delayed_create);
|
mysql_mutex_unlock(&LOCK_delayed_create);
|
||||||
DBUG_RETURN(thd->is_error());
|
DBUG_RETURN(thd->is_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2039,10 +2040,10 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
|
|||||||
if (!thd.lock) // Table is not locked
|
if (!thd.lock) // Table is not locked
|
||||||
{
|
{
|
||||||
thd_proc_info(client_thd, "waiting for handler lock");
|
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)
|
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");
|
thd_proc_info(client_thd, "got handler lock");
|
||||||
if (client_thd->killed)
|
if (client_thd->killed)
|
||||||
@ -2129,7 +2130,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
|
|||||||
error:
|
error:
|
||||||
tables_in_use--;
|
tables_in_use--;
|
||||||
status=1;
|
status=1;
|
||||||
pthread_cond_signal(&cond); // Inform thread about abort
|
mysql_cond_signal(&cond); // Inform thread about abort
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2148,9 +2149,9 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
|
|||||||
(ulong) query.length));
|
(ulong) query.length));
|
||||||
|
|
||||||
thd_proc_info(thd, "waiting for handler insert");
|
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)
|
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");
|
thd_proc_info(thd, "storing row into queue");
|
||||||
|
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
@ -2225,15 +2226,15 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
|
|||||||
di->status=1;
|
di->status=1;
|
||||||
if (table->s->blob_fields)
|
if (table->s->blob_fields)
|
||||||
unlink_blobs(table);
|
unlink_blobs(table);
|
||||||
pthread_cond_signal(&di->cond);
|
mysql_cond_signal(&di->cond);
|
||||||
|
|
||||||
thread_safe_increment(delayed_rows_in_use,&LOCK_delayed_status);
|
thread_safe_increment(delayed_rows_in_use,&LOCK_delayed_status);
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
delete row;
|
delete row;
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2246,14 +2247,14 @@ static void end_delayed_insert(THD *thd)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("end_delayed_insert");
|
DBUG_ENTER("end_delayed_insert");
|
||||||
Delayed_insert *di=thd->di;
|
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));
|
DBUG_PRINT("info",("tables in use: %d",di->tables_in_use));
|
||||||
if (!--di->tables_in_use || di->thd.killed)
|
if (!--di->tables_in_use || di->thd.killed)
|
||||||
{ // Unlock table
|
{ // Unlock table
|
||||||
di->status=1;
|
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;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2262,7 +2263,7 @@ static void end_delayed_insert(THD *thd)
|
|||||||
|
|
||||||
void kill_delayed_threads(void)
|
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);
|
I_List_iterator<Delayed_insert> it(delayed_threads);
|
||||||
Delayed_insert *di;
|
Delayed_insert *di;
|
||||||
@ -2271,7 +2272,7 @@ void kill_delayed_threads(void)
|
|||||||
di->thd.killed= THD::KILL_CONNECTION;
|
di->thd.killed= THD::KILL_CONNECTION;
|
||||||
if (di->thd.mysys_var)
|
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)
|
if (di->thd.mysys_var->current_cond)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -2279,15 +2280,15 @@ void kill_delayed_threads(void)
|
|||||||
in handle_delayed_insert()
|
in handle_delayed_insert()
|
||||||
*/
|
*/
|
||||||
if (&di->mutex != di->thd.mysys_var->current_mutex)
|
if (&di->mutex != di->thd.mysys_var->current_mutex)
|
||||||
pthread_mutex_lock(di->thd.mysys_var->current_mutex);
|
mysql_mutex_lock(di->thd.mysys_var->current_mutex);
|
||||||
pthread_cond_broadcast(di->thd.mysys_var->current_cond);
|
mysql_cond_broadcast(di->thd.mysys_var->current_cond);
|
||||||
if (&di->mutex != di->thd.mysys_var->current_mutex)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2309,15 +2310,17 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
|
thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
|
||||||
pthread_mutex_unlock(&LOCK_thread_count);
|
pthread_mutex_unlock(&LOCK_thread_count);
|
||||||
|
|
||||||
|
mysql_thread_set_psi_id(thd->thread_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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.
|
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
|
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
|
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,
|
and allow another thread to create another handler for the same table,
|
||||||
since it does not find one in the list.
|
since it does not find one in the list.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&di->mutex);
|
mysql_mutex_lock(&di->mutex);
|
||||||
if (my_thread_init())
|
if (my_thread_init())
|
||||||
{
|
{
|
||||||
/* Can't use my_error since store_globals has not yet been called */
|
/* Can't use my_error since store_globals has not yet been called */
|
||||||
@ -2376,7 +2379,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
di->table->copy_blobs=1;
|
di->table->copy_blobs=1;
|
||||||
|
|
||||||
/* Tell client that the thread is initialized */
|
/* 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 */
|
/* Now wait until we get an insert or lock to handle */
|
||||||
/* We will not abort as long as a client thread uses this thread */
|
/* We will not abort as long as a client thread uses this thread */
|
||||||
@ -2390,12 +2393,12 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
Remove this from delay insert list so that no one can request a
|
Remove this from delay insert list so that no one can request a
|
||||||
table from this
|
table from this
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
pthread_mutex_lock(&LOCK_delayed_insert);
|
mysql_mutex_lock(&LOCK_delayed_insert);
|
||||||
di->unlink();
|
di->unlink();
|
||||||
lock_count=di->lock_count();
|
lock_count=di->lock_count();
|
||||||
pthread_mutex_unlock(&LOCK_delayed_insert);
|
mysql_mutex_unlock(&LOCK_delayed_insert);
|
||||||
pthread_mutex_lock(&di->mutex);
|
mysql_mutex_lock(&di->mutex);
|
||||||
if (!lock_count && !di->tables_in_use && !di->stacked_inserts)
|
if (!lock_count && !di->tables_in_use && !di->stacked_inserts)
|
||||||
break; // Time to die
|
break; // Time to die
|
||||||
}
|
}
|
||||||
@ -2415,15 +2418,15 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
#if defined(HAVE_BROKEN_COND_TIMEDWAIT)
|
#if defined(HAVE_BROKEN_COND_TIMEDWAIT)
|
||||||
error=pthread_cond_wait(&di->cond,&di->mutex);
|
error= mysql_cond_wait(&di->cond, &di->mutex);
|
||||||
#else
|
#else
|
||||||
error=pthread_cond_timedwait(&di->cond,&di->mutex,&abstime);
|
error= mysql_cond_timedwait(&di->cond, &di->mutex, &abstime);
|
||||||
#ifdef EXTRA_DEBUG
|
#ifdef EXTRA_DEBUG
|
||||||
if (error && error != EINTR && error != ETIMEDOUT)
|
if (error && error != EINTR && error != ETIMEDOUT)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Got error %d from pthread_cond_timedwait\n",error);
|
fprintf(stderr, "Got error %d from mysql_cond_timedwait\n", error);
|
||||||
DBUG_PRINT("error",("Got error %d from pthread_cond_timedwait",
|
DBUG_PRINT("error", ("Got error %d from mysql_cond_timedwait",
|
||||||
error));
|
error));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -2436,12 +2439,12 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* We can't lock di->mutex and mysys_var->mutex at the same time */
|
/* We can't lock di->mutex and mysys_var->mutex at the same time */
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
pthread_mutex_lock(&di->thd.mysys_var->mutex);
|
mysql_mutex_lock(&di->thd.mysys_var->mutex);
|
||||||
di->thd.mysys_var->current_mutex= 0;
|
di->thd.mysys_var->current_mutex= 0;
|
||||||
di->thd.mysys_var->current_cond= 0;
|
di->thd.mysys_var->current_cond= 0;
|
||||||
pthread_mutex_unlock(&di->thd.mysys_var->mutex);
|
mysql_mutex_unlock(&di->thd.mysys_var->mutex);
|
||||||
pthread_mutex_lock(&di->mutex);
|
mysql_mutex_lock(&di->mutex);
|
||||||
}
|
}
|
||||||
thd_proc_info(&(di->thd), 0);
|
thd_proc_info(&(di->thd), 0);
|
||||||
|
|
||||||
@ -2466,7 +2469,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
di->dead= 1;
|
di->dead= 1;
|
||||||
thd->killed= THD::KILL_CONNECTION;
|
thd->killed= THD::KILL_CONNECTION;
|
||||||
}
|
}
|
||||||
pthread_cond_broadcast(&di->cond_client);
|
mysql_cond_broadcast(&di->cond_client);
|
||||||
}
|
}
|
||||||
if (di->stacked_inserts)
|
if (di->stacked_inserts)
|
||||||
{
|
{
|
||||||
@ -2486,7 +2489,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
*/
|
*/
|
||||||
MYSQL_LOCK *lock=thd->lock;
|
MYSQL_LOCK *lock=thd->lock;
|
||||||
thd->lock=0;
|
thd->lock=0;
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
/*
|
/*
|
||||||
We need to release next_insert_id before unlocking. This is
|
We need to release next_insert_id before unlocking. This is
|
||||||
enforced by handler::ha_external_lock().
|
enforced by handler::ha_external_lock().
|
||||||
@ -2495,10 +2498,10 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
mysql_unlock_tables(thd, lock);
|
mysql_unlock_tables(thd, lock);
|
||||||
ha_autocommit_or_rollback(thd, 0);
|
ha_autocommit_or_rollback(thd, 0);
|
||||||
di->group_count=0;
|
di->group_count=0;
|
||||||
pthread_mutex_lock(&di->mutex);
|
mysql_mutex_lock(&di->mutex);
|
||||||
}
|
}
|
||||||
if (di->tables_in_use)
|
if (di->tables_in_use)
|
||||||
pthread_cond_broadcast(&di->cond_client); // If waiting clients
|
mysql_cond_broadcast(&di->cond_client); // If waiting clients
|
||||||
}
|
}
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@ -2527,14 +2530,14 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
|||||||
di->table=0;
|
di->table=0;
|
||||||
di->dead= 1; // If error
|
di->dead= 1; // If error
|
||||||
thd->killed= THD::KILL_CONNECTION; // If error
|
thd->killed= THD::KILL_CONNECTION; // If error
|
||||||
pthread_cond_broadcast(&di->cond_client); // Safety
|
mysql_cond_broadcast(&di->cond_client); // Safety
|
||||||
pthread_mutex_unlock(&di->mutex);
|
mysql_mutex_unlock(&di->mutex);
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_delayed_create); // Because of delayed_get_table
|
mysql_mutex_lock(&LOCK_delayed_create); // Because of delayed_get_table
|
||||||
pthread_mutex_lock(&LOCK_delayed_insert);
|
mysql_mutex_lock(&LOCK_delayed_insert);
|
||||||
delete di;
|
delete 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);
|
||||||
|
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
@ -2581,7 +2584,7 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
DBUG_ENTER("handle_inserts");
|
DBUG_ENTER("handle_inserts");
|
||||||
|
|
||||||
/* Allow client to insert new rows */
|
/* Allow client to insert new rows */
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
|
|
||||||
table->next_number_field=table->found_next_number_field;
|
table->next_number_field=table->found_next_number_field;
|
||||||
table->use_all_columns();
|
table->use_all_columns();
|
||||||
@ -2614,12 +2617,12 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
*/
|
*/
|
||||||
if (!using_bin_log)
|
if (!using_bin_log)
|
||||||
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
|
|
||||||
while ((row=rows.get()))
|
while ((row=rows.get()))
|
||||||
{
|
{
|
||||||
stacked_inserts--;
|
stacked_inserts--;
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
memcpy(table->record[0],row->record,table->s->reclength);
|
memcpy(table->record[0],row->record,table->s->reclength);
|
||||||
|
|
||||||
thd.start_time=row->start_time;
|
thd.start_time=row->start_time;
|
||||||
@ -2737,7 +2740,7 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
free_delayed_insert_blobs(table);
|
free_delayed_insert_blobs(table);
|
||||||
thread_safe_decrement(delayed_rows_in_use,&LOCK_delayed_status);
|
thread_safe_decrement(delayed_rows_in_use,&LOCK_delayed_status);
|
||||||
thread_safe_increment(delayed_insert_writes,&LOCK_delayed_status);
|
thread_safe_increment(delayed_insert_writes,&LOCK_delayed_status);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reset the table->auto_increment_field_not_null as it is valid for
|
Reset the table->auto_increment_field_not_null as it is valid for
|
||||||
@ -2759,9 +2762,9 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
if (stacked_inserts || tables_in_use) // Let these wait a while
|
if (stacked_inserts || tables_in_use) // Let these wait a while
|
||||||
{
|
{
|
||||||
if (tables_in_use)
|
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");
|
thd_proc_info(&thd, "reschedule");
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
|
if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
|
||||||
{
|
{
|
||||||
/* This should never happen */
|
/* This should never happen */
|
||||||
@ -2780,15 +2783,15 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
}
|
}
|
||||||
if (!using_bin_log)
|
if (!using_bin_log)
|
||||||
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
thd_proc_info(&thd, "insert");
|
thd_proc_info(&thd, "insert");
|
||||||
}
|
}
|
||||||
if (tables_in_use)
|
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);
|
thd_proc_info(&thd, 0);
|
||||||
pthread_mutex_unlock(&mutex);
|
mysql_mutex_unlock(&mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We need to flush the pending event when using row-based
|
We need to flush the pending event when using row-based
|
||||||
@ -2813,7 +2816,7 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
query_cache_invalidate3(&thd, table, 1);
|
query_cache_invalidate3(&thd, table, 1);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@ -2837,7 +2840,7 @@ bool Delayed_insert::handle_inserts(void)
|
|||||||
}
|
}
|
||||||
DBUG_PRINT("error", ("dropped %lu rows after an error", max_rows));
|
DBUG_PRINT("error", ("dropped %lu rows after an error", max_rows));
|
||||||
thread_safe_increment(delayed_insert_errors, &LOCK_delayed_status);
|
thread_safe_increment(delayed_insert_errors, &LOCK_delayed_status);
|
||||||
pthread_mutex_lock(&mutex);
|
mysql_mutex_lock(&mutex);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
#endif /* EMBEDDED_LIBRARY */
|
#endif /* EMBEDDED_LIBRARY */
|
||||||
@ -3494,7 +3497,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
|
|
||||||
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (reopen_name_locked_table(thd, create_table, FALSE))
|
if (reopen_name_locked_table(thd, create_table, FALSE))
|
||||||
{
|
{
|
||||||
quick_rm_table(create_info->db_type, create_table->db,
|
quick_rm_table(create_info->db_type, create_table->db,
|
||||||
@ -3503,7 +3506,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
table= create_table->table;
|
table= create_table->table;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2081,11 +2081,11 @@ mysql_execute_command(THD *thd)
|
|||||||
restore status variables, as we don't want 'show status' to cause
|
restore status variables, as we don't want 'show status' to cause
|
||||||
changes
|
changes
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_status);
|
mysql_mutex_lock(&LOCK_status);
|
||||||
add_diff_to_status(&global_status_var, &thd->status_var,
|
add_diff_to_status(&global_status_var, &thd->status_var,
|
||||||
&old_status_var);
|
&old_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;
|
break;
|
||||||
}
|
}
|
||||||
case SQLCOM_SHOW_DATABASES:
|
case SQLCOM_SHOW_DATABASES:
|
||||||
|
@ -6223,7 +6223,7 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
|
|||||||
since all table objects were closed and removed as part of the
|
since all table objects were closed and removed as part of the
|
||||||
ALTER TABLE of partitioning structure.
|
ALTER TABLE of partitioning structure.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
lpt->thd->in_lock_tables= 1;
|
lpt->thd->in_lock_tables= 1;
|
||||||
err= reopen_tables(lpt->thd, 1, 1);
|
err= reopen_tables(lpt->thd, 1, 1);
|
||||||
lpt->thd->in_lock_tables= 0;
|
lpt->thd->in_lock_tables= 0;
|
||||||
@ -6237,7 +6237,7 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
|
|||||||
unlink_open_table(lpt->thd, lpt->table, FALSE);
|
unlink_open_table(lpt->thd, lpt->table, FALSE);
|
||||||
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
|
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6261,9 +6261,9 @@ static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt)
|
|||||||
We set lock to zero to ensure we don't do this twice
|
We set lock to zero to ensure we don't do this twice
|
||||||
and we set db_stat to zero to ensure we don't close twice.
|
and we set db_stat to zero to ensure we don't close twice.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
close_data_files_and_morph_locks(thd, db, table_name);
|
close_data_files_and_morph_locks(thd, db, table_name);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1372,10 +1372,10 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
|
|||||||
When building an embedded library, if the mysql.plugin table
|
When building an embedded library, if the mysql.plugin table
|
||||||
does not exist, we silently ignore the missing 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))
|
if (check_if_table_exists(new_thd, &tables, &table_exists))
|
||||||
table_exists= FALSE;
|
table_exists= FALSE;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
if (!table_exists)
|
if (!table_exists)
|
||||||
goto end;
|
goto end;
|
||||||
#endif /* EMBEDDED_LIBRARY */
|
#endif /* EMBEDDED_LIBRARY */
|
||||||
|
@ -133,10 +133,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (lock_table_names_exclusively(thd, table_list))
|
if (lock_table_names_exclusively(thd, table_list))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
|
|||||||
higher concurrency - query_cache_invalidate can take minutes to
|
higher concurrency - query_cache_invalidate can take minutes to
|
||||||
complete.
|
complete.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
/* Lets hope this doesn't fail as the result will be messy */
|
/* Lets hope this doesn't fail as the result will be messy */
|
||||||
if (!silent && !error)
|
if (!silent && !error)
|
||||||
@ -184,9 +184,9 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
|
|||||||
if (!error)
|
if (!error)
|
||||||
query_cache_invalidate3(thd, table_list, 0);
|
query_cache_invalidate3(thd, table_list, 0);
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
|
unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
|
@ -1759,11 +1759,11 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
|
|||||||
thd_info->db=thd->strdup(thd_info->db);
|
thd_info->db=thd->strdup(thd_info->db);
|
||||||
thd_info->command=(int) tmp->command;
|
thd_info->command=(int) tmp->command;
|
||||||
if ((mysys_var= tmp->mysys_var))
|
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);
|
thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);
|
||||||
thd_info->state_info= thread_state_info(tmp);
|
thd_info->state_info= thread_state_info(tmp);
|
||||||
if (mysys_var)
|
if (mysys_var)
|
||||||
pthread_mutex_unlock(&mysys_var->mutex);
|
mysql_mutex_unlock(&mysys_var->mutex);
|
||||||
|
|
||||||
thd_info->start_time= tmp->start_time;
|
thd_info->start_time= tmp->start_time;
|
||||||
thd_info->query=0;
|
thd_info->query=0;
|
||||||
@ -1862,7 +1862,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((mysys_var= tmp->mysys_var))
|
if ((mysys_var= tmp->mysys_var))
|
||||||
pthread_mutex_lock(&mysys_var->mutex);
|
mysql_mutex_lock(&mysys_var->mutex);
|
||||||
/* COMMAND */
|
/* COMMAND */
|
||||||
if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
|
if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
|
||||||
table->field[4]->store(val, strlen(val), cs);
|
table->field[4]->store(val, strlen(val), cs);
|
||||||
@ -1880,7 +1880,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mysys_var)
|
if (mysys_var)
|
||||||
pthread_mutex_unlock(&mysys_var->mutex);
|
mysql_mutex_unlock(&mysys_var->mutex);
|
||||||
|
|
||||||
/* INFO */
|
/* INFO */
|
||||||
if (tmp->query())
|
if (tmp->query())
|
||||||
@ -1958,7 +1958,7 @@ int add_status_vars(SHOW_VAR *list)
|
|||||||
{
|
{
|
||||||
int res= 0;
|
int res= 0;
|
||||||
if (status_vars_inited)
|
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
|
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))
|
my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20))
|
||||||
{
|
{
|
||||||
@ -1973,7 +1973,7 @@ int add_status_vars(SHOW_VAR *list)
|
|||||||
sort_dynamic(&all_status_vars, show_var_cmp);
|
sort_dynamic(&all_status_vars, show_var_cmp);
|
||||||
err:
|
err:
|
||||||
if (status_vars_inited)
|
if (status_vars_inited)
|
||||||
pthread_mutex_unlock(&LOCK_status);
|
mysql_mutex_unlock(&LOCK_status);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2035,7 +2035,7 @@ void remove_status_vars(SHOW_VAR *list)
|
|||||||
{
|
{
|
||||||
if (status_vars_inited)
|
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 *);
|
SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *);
|
||||||
int a= 0, b= all_status_vars.elements, c= (a+b)/2;
|
int a= 0, b= all_status_vars.elements, c= (a+b)/2;
|
||||||
|
|
||||||
@ -2056,7 +2056,7 @@ void remove_status_vars(SHOW_VAR *list)
|
|||||||
all[c].type= SHOW_UNDEF;
|
all[c].type= SHOW_UNDEF;
|
||||||
}
|
}
|
||||||
shrink_var_array(&all_status_vars);
|
shrink_var_array(&all_status_vars);
|
||||||
pthread_mutex_unlock(&LOCK_status);
|
mysql_mutex_unlock(&LOCK_status);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3102,7 +3102,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
key_length= create_table_def_key(thd, key, &table_list, 0);
|
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,
|
share= get_table_share(thd, &table_list, key,
|
||||||
key_length, OPEN_VIEW, &error);
|
key_length, OPEN_VIEW, &error);
|
||||||
if (!share)
|
if (!share)
|
||||||
@ -3149,7 +3149,7 @@ err1:
|
|||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share, RELEASE_NORMAL);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
thd->clear_error();
|
thd->clear_error();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -5524,14 +5524,14 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
tmp1= &thd->status_var;
|
tmp1= &thd->status_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_status);
|
mysql_mutex_lock(&LOCK_status);
|
||||||
if (option_type == OPT_GLOBAL)
|
if (option_type == OPT_GLOBAL)
|
||||||
calc_sum_of_all_status(&tmp);
|
calc_sum_of_all_status(&tmp);
|
||||||
res= show_status_array(thd, wild,
|
res= show_status_array(thd, wild,
|
||||||
(SHOW_VAR *)all_status_vars.buffer,
|
(SHOW_VAR *)all_status_vars.buffer,
|
||||||
option_type, tmp1, "", tables->table,
|
option_type, tmp1, "", tables->table,
|
||||||
upper_case_names, cond);
|
upper_case_names, cond);
|
||||||
pthread_mutex_unlock(&LOCK_status);
|
mysql_mutex_unlock(&LOCK_status);
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7192,7 +7192,7 @@ static TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
|
|||||||
{
|
{
|
||||||
/* Acquire LOCK_open (stop the server). */
|
/* 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.
|
Load base table name from the TRN-file and create TABLE_LIST object.
|
||||||
@ -7202,7 +7202,7 @@ static TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
|
|||||||
|
|
||||||
/* Release LOCK_open (continue the server). */
|
/* Release LOCK_open (continue the server). */
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
/* That's it. */
|
/* That's it. */
|
||||||
|
|
||||||
|
134
sql/sql_table.cc
134
sql/sql_table.cc
@ -1653,7 +1653,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
|||||||
completing this we write a new phase to the log entry that will
|
completing this we write a new phase to the log entry that will
|
||||||
deactivate it.
|
deactivate it.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (my_delete(frm_name, MYF(MY_WME)) ||
|
if (my_delete(frm_name, MYF(MY_WME)) ||
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
lpt->table->file->ha_create_handler_files(path, shadow_path,
|
lpt->table->file->ha_create_handler_files(path, shadow_path,
|
||||||
@ -1706,7 +1706,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
err:
|
err:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos);
|
deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos);
|
||||||
part_info->frm_log_entry= NULL;
|
part_info->frm_log_entry= NULL;
|
||||||
@ -1869,7 +1869,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
|||||||
|
|
||||||
mysql_ha_rm_tables(thd, tables, FALSE);
|
mysql_ha_rm_tables(thd, tables, FALSE);
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If we have the table in the definition cache, we don't have to check the
|
If we have the table in the definition cache, we don't have to check the
|
||||||
@ -1890,14 +1890,14 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
|||||||
table->table_name_length, table->table_name, 1))
|
table->table_name_length, table->table_name, 1))
|
||||||
{
|
{
|
||||||
my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP");
|
my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP");
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!drop_temporary && lock_table_names_exclusively(thd, tables))
|
if (!drop_temporary && lock_table_names_exclusively(thd, tables))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2068,7 +2068,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
|||||||
It's safe to unlock LOCK_open: we have an exclusive lock
|
It's safe to unlock LOCK_open: we have an exclusive lock
|
||||||
on the table name.
|
on the table name.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
thd->thread_specific_used|= tmp_table_deleted;
|
thd->thread_specific_used|= tmp_table_deleted;
|
||||||
error= 0;
|
error= 0;
|
||||||
if (wrong_tables.length())
|
if (wrong_tables.length())
|
||||||
@ -2151,10 +2151,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
err_with_placeholders:
|
err_with_placeholders:
|
||||||
unlock_table_names(thd, tables, (TABLE_LIST*) 0);
|
unlock_table_names(thd, tables, (TABLE_LIST*) 0);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3870,7 +3870,7 @@ bool mysql_create_table_no_lock(THD *thd,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
||||||
{
|
{
|
||||||
if (!access(path,F_OK))
|
if (!access(path,F_OK))
|
||||||
@ -4015,7 +4015,7 @@ bool mysql_create_table_no_lock(THD *thd,
|
|||||||
write_create_table_bin_log(thd, create_info, internal_tmp_table);
|
write_create_table_bin_log(thd, create_info, internal_tmp_table);
|
||||||
error= FALSE;
|
error= FALSE;
|
||||||
unlock_and_end:
|
unlock_and_end:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
thd_proc_info(thd, "After create");
|
thd_proc_info(thd, "After create");
|
||||||
@ -4048,21 +4048,21 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
|
|||||||
DBUG_ENTER("mysql_create_table");
|
DBUG_ENTER("mysql_create_table");
|
||||||
|
|
||||||
/* Wait for any database locks */
|
/* Wait for any database locks */
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
while (!thd->killed &&
|
while (!thd->killed &&
|
||||||
my_hash_search(&lock_db_cache,(uchar*) db, strlen(db)))
|
my_hash_search(&lock_db_cache,(uchar*) db, strlen(db)))
|
||||||
{
|
{
|
||||||
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
|
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
creating_table++;
|
creating_table++;
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
|
|
||||||
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
|
||||||
{
|
{
|
||||||
@ -4099,14 +4099,14 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
|
|||||||
unlock:
|
unlock:
|
||||||
if (name_lock)
|
if (name_lock)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlink_open_table(thd, name_lock, FALSE);
|
unlink_open_table(thd, name_lock, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_lock_db);
|
mysql_mutex_lock(&LOCK_lock_db);
|
||||||
if (!--creating_table && creating_database)
|
if (!--creating_table && creating_database)
|
||||||
pthread_cond_signal(&COND_refresh);
|
mysql_cond_signal(&COND_refresh);
|
||||||
pthread_mutex_unlock(&LOCK_lock_db);
|
mysql_mutex_unlock(&LOCK_lock_db);
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4267,7 +4267,7 @@ void wait_while_table_is_used(THD *thd, TABLE *table,
|
|||||||
table->s->table_name.str, (ulong) table->s,
|
table->s->table_name.str, (ulong) table->s,
|
||||||
table->db_stat, table->s->version));
|
table->db_stat, table->s->version));
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
(void) table->file->extra(function);
|
(void) table->file->extra(function);
|
||||||
/* Mark all tables that are in use as 'old' */
|
/* Mark all tables that are in use as 'old' */
|
||||||
@ -4352,22 +4352,22 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
|||||||
uint key_length;
|
uint key_length;
|
||||||
|
|
||||||
key_length= create_table_def_key(thd, key, table_list, 0);
|
key_length= create_table_def_key(thd, key, table_list, 0);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (!(share= (get_table_share(thd, table_list, key, key_length, 0,
|
if (!(share= (get_table_share(thd, table_list, key, key_length, 0,
|
||||||
&error))))
|
&error))))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0); // Can't open frm file
|
DBUG_RETURN(0); // Can't open frm file
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE))
|
if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE))
|
||||||
{
|
{
|
||||||
release_table_share(share, RELEASE_NORMAL);
|
release_table_share(share, RELEASE_NORMAL);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(0); // Out of memory
|
DBUG_RETURN(0); // Out of memory
|
||||||
}
|
}
|
||||||
table= &tmp_table;
|
table= &tmp_table;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A MERGE table must not come here. */
|
/* A MERGE table must not come here. */
|
||||||
@ -4421,9 +4421,9 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
|||||||
/* If we could open the table, close it */
|
/* If we could open the table, close it */
|
||||||
if (table_list->table)
|
if (table_list->table)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
close_cached_table(thd, table);
|
close_cached_table(thd, table);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
if (lock_and_wait_for_table_name(thd,table_list))
|
if (lock_and_wait_for_table_name(thd,table_list))
|
||||||
{
|
{
|
||||||
@ -4432,27 +4432,27 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
|||||||
}
|
}
|
||||||
if (my_rename(from, tmp, MYF(MY_WME)))
|
if (my_rename(from, tmp, MYF(MY_WME)))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
error= send_check_errmsg(thd, table_list, "repair",
|
error= send_check_errmsg(thd, table_list, "repair",
|
||||||
"Failed renaming data file");
|
"Failed renaming data file");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (mysql_truncate(thd, table_list, 1))
|
if (mysql_truncate(thd, table_list, 1))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
error= send_check_errmsg(thd, table_list, "repair",
|
error= send_check_errmsg(thd, table_list, "repair",
|
||||||
"Failed generating table from .frm file");
|
"Failed generating table from .frm file");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (my_rename(tmp, from, MYF(MY_WME)))
|
if (my_rename(tmp, from, MYF(MY_WME)))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
error= send_check_errmsg(thd, table_list, "repair",
|
error= send_check_errmsg(thd, table_list, "repair",
|
||||||
"Failed restoring .MYD file");
|
"Failed restoring .MYD file");
|
||||||
goto end;
|
goto end;
|
||||||
@ -4462,23 +4462,23 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
|||||||
Now we should be able to open the partially repaired table
|
Now we should be able to open the partially repaired table
|
||||||
to finish the repair in the handler later on.
|
to finish the repair in the handler later on.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (reopen_name_locked_table(thd, table_list, TRUE))
|
if (reopen_name_locked_table(thd, table_list, TRUE))
|
||||||
{
|
{
|
||||||
unlock_table_name(thd, table_list);
|
unlock_table_name(thd, table_list);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
error= send_check_errmsg(thd, table_list, "repair",
|
error= send_check_errmsg(thd, table_list, "repair",
|
||||||
"Failed to open partially repaired table");
|
"Failed to open partially repaired table");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (table == &tmp_table)
|
if (table == &tmp_table)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
closefrm(table, 1); // Free allocated memory
|
closefrm(table, 1); // Free allocated memory
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@ -4705,7 +4705,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
|||||||
if (lock_type == TL_WRITE && table->table->s->version)
|
if (lock_type == TL_WRITE && table->table->s->version)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("admin", ("removing table from cache"));
|
DBUG_PRINT("admin", ("removing table from cache"));
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
|
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
|
||||||
"Waiting to get writelock");
|
"Waiting to get writelock");
|
||||||
mysql_lock_abort(thd,table->table, TRUE);
|
mysql_lock_abort(thd,table->table, TRUE);
|
||||||
@ -4968,10 +4968,10 @@ send_result_message:
|
|||||||
table->table->file->info(HA_STATUS_CONST);
|
table->table->file->info(HA_STATUS_CONST);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
remove_table_from_cache(thd, table->table->s->db.str,
|
remove_table_from_cache(thd, table->table->s->db.str,
|
||||||
table->table->s->table_name.str, RTFC_NO_FLAG);
|
table->table->s->table_name.str, RTFC_NO_FLAG);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
/* May be something modified consequently we have to invalidate cache */
|
/* May be something modified consequently we have to invalidate cache */
|
||||||
query_cache_invalidate3(thd, table->table, 0);
|
query_cache_invalidate3(thd, table->table, 0);
|
||||||
@ -5274,12 +5274,12 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
|||||||
Also some engines (e.g. NDB cluster) require that LOCK_open should be held
|
Also some engines (e.g. NDB cluster) require that LOCK_open should be held
|
||||||
during the call to ha_create_table(). See bug #28614 for more info.
|
during the call to ha_create_table(). See bug #28614 for more info.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (src_table->schema_table)
|
if (src_table->schema_table)
|
||||||
{
|
{
|
||||||
if (mysql_create_like_schema_frm(thd, src_table, dst_path, create_info))
|
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;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5289,7 +5289,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
|||||||
my_error(ER_BAD_DB_ERROR,MYF(0),db);
|
my_error(ER_BAD_DB_ERROR,MYF(0),db);
|
||||||
else
|
else
|
||||||
my_error(ER_CANT_CREATE_FILE,MYF(0),dst_path,my_errno);
|
my_error(ER_CANT_CREATE_FILE,MYF(0),dst_path,my_errno);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5318,7 +5318,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
|||||||
if (thd->variables.keep_files_on_create)
|
if (thd->variables.keep_files_on_create)
|
||||||
create_info->options|= HA_CREATE_KEEP_FILES;
|
create_info->options|= HA_CREATE_KEEP_FILES;
|
||||||
err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
|
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)
|
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
|
||||||
{
|
{
|
||||||
@ -5392,13 +5392,13 @@ binlog:
|
|||||||
of this function.
|
of this function.
|
||||||
*/
|
*/
|
||||||
table->table= name_lock;
|
table->table= name_lock;
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (reopen_name_locked_table(thd, table, FALSE))
|
if (reopen_name_locked_table(thd, table, FALSE))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
int result __attribute__((unused))=
|
int result __attribute__((unused))=
|
||||||
store_create_info(thd, table, &query,
|
store_create_info(thd, table, &query,
|
||||||
@ -5422,9 +5422,9 @@ binlog:
|
|||||||
err:
|
err:
|
||||||
if (name_lock)
|
if (name_lock)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlink_open_table(thd, name_lock, FALSE);
|
unlink_open_table(thd, name_lock, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
@ -6501,7 +6501,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
|
|
||||||
if (wait_if_global_read_lock(thd,0,1))
|
if (wait_if_global_read_lock(thd,0,1))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (lock_table_names(thd, table_list))
|
if (lock_table_names(thd, table_list))
|
||||||
{
|
{
|
||||||
error= 1;
|
error= 1;
|
||||||
@ -6523,7 +6523,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
|
unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
|
||||||
|
|
||||||
view_err:
|
view_err:
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@ -6684,17 +6684,17 @@ view_err:
|
|||||||
while the fact that the table is still open gives us protection
|
while the fact that the table is still open gives us protection
|
||||||
from concurrent DDL statements.
|
from concurrent DDL statements.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
|
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_EXECUTE_IF("sleep_alter_enable_indexes", my_sleep(6000000););
|
DBUG_EXECUTE_IF("sleep_alter_enable_indexes", my_sleep(6000000););
|
||||||
error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
|
error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
|
||||||
/* COND_refresh will be signaled in close_thread_tables() */
|
/* COND_refresh will be signaled in close_thread_tables() */
|
||||||
break;
|
break;
|
||||||
case DISABLE:
|
case DISABLE:
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
|
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
|
error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
|
||||||
/* COND_refresh will be signaled in close_thread_tables() */
|
/* COND_refresh will be signaled in close_thread_tables() */
|
||||||
break;
|
break;
|
||||||
@ -6711,7 +6711,7 @@ view_err:
|
|||||||
table->alias);
|
table->alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
/*
|
/*
|
||||||
Unlike to the above case close_cached_table() below will remove ALL
|
Unlike to the above case close_cached_table() below will remove ALL
|
||||||
instances of TABLE from table cache (it will also remove table lock
|
instances of TABLE from table cache (it will also remove table lock
|
||||||
@ -6777,7 +6777,7 @@ view_err:
|
|||||||
}
|
}
|
||||||
if (name_lock)
|
if (name_lock)
|
||||||
unlink_open_table(thd, name_lock, FALSE);
|
unlink_open_table(thd, name_lock, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
table_list->table= NULL; // For query cache
|
table_list->table= NULL; // For query cache
|
||||||
query_cache_invalidate3(thd, table_list, 0);
|
query_cache_invalidate3(thd, table_list, 0);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
@ -7138,9 +7138,9 @@ view_err:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
|
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
thd_proc_info(thd, "manage keys");
|
thd_proc_info(thd, "manage keys");
|
||||||
alter_table_manage_keys(table, table->file->indexes_are_disabled(),
|
alter_table_manage_keys(table, table->file->indexes_are_disabled(),
|
||||||
alter_info->keys_onoff);
|
alter_info->keys_onoff);
|
||||||
@ -7270,11 +7270,11 @@ view_err:
|
|||||||
intern_close_table(new_table);
|
intern_close_table(new_table);
|
||||||
my_free(new_table,MYF(0));
|
my_free(new_table,MYF(0));
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
(void) quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
|
(void) quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7407,7 +7407,7 @@ view_err:
|
|||||||
if (error)
|
if (error)
|
||||||
goto err_with_placeholders;
|
goto err_with_placeholders;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
thd_proc_info(thd, "end");
|
thd_proc_info(thd, "end");
|
||||||
|
|
||||||
@ -7454,10 +7454,10 @@ view_err:
|
|||||||
from the list of open tables and table cache. If we are not under
|
from the list of open tables and table cache. If we are not under
|
||||||
LOCK TABLES we can rely on close_thread_tables() doing this job.
|
LOCK TABLES we can rely on close_thread_tables() doing this job.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlink_open_table(thd, table, FALSE);
|
unlink_open_table(thd, table, FALSE);
|
||||||
unlink_open_table(thd, name_lock, FALSE);
|
unlink_open_table(thd, name_lock, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
end_temporary:
|
end_temporary:
|
||||||
@ -7514,9 +7514,9 @@ err:
|
|||||||
}
|
}
|
||||||
if (name_lock)
|
if (name_lock)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
unlink_open_table(thd, name_lock, FALSE);
|
unlink_open_table(thd, name_lock, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
@ -7529,7 +7529,7 @@ err_with_placeholders:
|
|||||||
unlink_open_table(thd, table, FALSE);
|
unlink_open_table(thd, table, FALSE);
|
||||||
if (name_lock)
|
if (name_lock)
|
||||||
unlink_open_table(thd, name_lock, FALSE);
|
unlink_open_table(thd, name_lock, FALSE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
/* mysql_alter_table */
|
/* mysql_alter_table */
|
||||||
|
@ -80,7 +80,7 @@ void print_cached_tables(void)
|
|||||||
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
|
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
|
||||||
|
|
||||||
/* purecov: begin tested */
|
/* purecov: begin tested */
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
puts("DB Table Version Thread Open Lock");
|
puts("DB Table Version Thread Open Lock");
|
||||||
|
|
||||||
for (idx=unused=0 ; idx < open_cache.records ; idx++)
|
for (idx=unused=0 ; idx < open_cache.records ; idx++)
|
||||||
@ -116,7 +116,7 @@ void print_cached_tables(void)
|
|||||||
if (my_hash_check(&open_cache))
|
if (my_hash_check(&open_cache))
|
||||||
printf("Error: File hash table is corrupted\n");
|
printf("Error: File hash table is corrupted\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
/* purecov: end */
|
/* purecov: end */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -381,12 +381,12 @@ static void display_table_locks(void)
|
|||||||
DYNAMIC_ARRAY saved_table_locks;
|
DYNAMIC_ARRAY saved_table_locks;
|
||||||
|
|
||||||
(void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO),open_cache.records + 20,50);
|
(void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO),open_cache.records + 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))
|
for (list= thr_lock_thread_list; list; list= list_rest(list))
|
||||||
{
|
{
|
||||||
THR_LOCK *lock=(THR_LOCK*) list->data;
|
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,
|
push_locks_into_array(&saved_table_locks, lock->write.data, FALSE,
|
||||||
"Locked - write");
|
"Locked - write");
|
||||||
push_locks_into_array(&saved_table_locks, lock->write_wait.data, TRUE,
|
push_locks_into_array(&saved_table_locks, lock->write_wait.data, TRUE,
|
||||||
@ -395,9 +395,9 @@ static void display_table_locks(void)
|
|||||||
"Locked - read");
|
"Locked - read");
|
||||||
push_locks_into_array(&saved_table_locks, lock->read_wait.data, TRUE,
|
push_locks_into_array(&saved_table_locks, lock->read_wait.data, TRUE,
|
||||||
"Waiting - read");
|
"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;
|
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);
|
qsort((uchar*) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare);
|
||||||
@ -473,7 +473,7 @@ void mysql_print_status()
|
|||||||
/* Print key cache status */
|
/* Print key cache status */
|
||||||
puts("\nKey caches:");
|
puts("\nKey caches:");
|
||||||
process_key_caches(print_key_cache_status);
|
process_key_caches(print_key_cache_status);
|
||||||
pthread_mutex_lock(&LOCK_status);
|
mysql_mutex_lock(&LOCK_status);
|
||||||
printf("\nhandler status:\n\
|
printf("\nhandler status:\n\
|
||||||
read_key: %10lu\n\
|
read_key: %10lu\n\
|
||||||
read_next: %10lu\n\
|
read_next: %10lu\n\
|
||||||
@ -489,7 +489,7 @@ update: %10lu\n",
|
|||||||
tmp.ha_write_count,
|
tmp.ha_write_count,
|
||||||
tmp.ha_delete_count,
|
tmp.ha_delete_count,
|
||||||
tmp.ha_update_count);
|
tmp.ha_update_count);
|
||||||
pthread_mutex_unlock(&LOCK_status);
|
mysql_mutex_unlock(&LOCK_status);
|
||||||
printf("\nTable status:\n\
|
printf("\nTable status:\n\
|
||||||
Opened tables: %10lu\n\
|
Opened tables: %10lu\n\
|
||||||
Open tables: %10lu\n\
|
Open tables: %10lu\n\
|
||||||
|
@ -387,7 +387,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
|
|||||||
!(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
|
!(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
|
|
||||||
if (!create)
|
if (!create)
|
||||||
{
|
{
|
||||||
@ -510,7 +510,7 @@ end:
|
|||||||
write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length());
|
write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
if (need_start_waiting)
|
if (need_start_waiting)
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
@ -1884,7 +1884,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db,
|
|||||||
old_table)-(char*)&key[0])+1;
|
old_table)-(char*)&key[0])+1;
|
||||||
|
|
||||||
if (!is_table_name_exclusively_locked_by_this_thread(thd, key, key_length))
|
if (!is_table_name_exclusively_locked_by_this_thread(thd, key, key_length))
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
mysql_mutex_assert_owner(&LOCK_open);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBUG_ASSERT(my_strcasecmp(table_alias_charset, db, new_db) ||
|
DBUG_ASSERT(my_strcasecmp(table_alias_charset, db, new_db) ||
|
||||||
|
@ -620,7 +620,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
|
|||||||
res= TRUE;
|
res= TRUE;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
res= mysql_register_view(thd, view, mode);
|
res= mysql_register_view(thd, view, mode);
|
||||||
|
|
||||||
if (mysql_bin_log.is_open())
|
if (mysql_bin_log.is_open())
|
||||||
@ -666,7 +666,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
|
|||||||
buff.ptr(), buff.length(), FALSE, FALSE, errcode);
|
buff.ptr(), buff.length(), FALSE, FALSE, errcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
if (mode != VIEW_CREATE_NEW)
|
if (mode != VIEW_CREATE_NEW)
|
||||||
query_cache_invalidate3(thd, view, 0);
|
query_cache_invalidate3(thd, view, 0);
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
@ -1579,7 +1579,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
|||||||
bool something_wrong= FALSE;
|
bool something_wrong= FALSE;
|
||||||
DBUG_ENTER("mysql_drop_view");
|
DBUG_ENTER("mysql_drop_view");
|
||||||
|
|
||||||
pthread_mutex_lock(&LOCK_open);
|
mysql_mutex_lock(&LOCK_open);
|
||||||
for (view= views; view; view= view->next_local)
|
for (view= views; view; view= view->next_local)
|
||||||
{
|
{
|
||||||
TABLE_SHARE *share;
|
TABLE_SHARE *share;
|
||||||
@ -1656,7 +1656,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
|||||||
write_bin_log(thd, !something_wrong, thd->query(), thd->query_length());
|
write_bin_log(thd, !something_wrong, thd->query(), thd->query_length());
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
mysql_mutex_unlock(&LOCK_open);
|
||||||
|
|
||||||
if (something_wrong)
|
if (something_wrong)
|
||||||
{
|
{
|
||||||
|
@ -3141,7 +3141,7 @@ int ha_federated::real_connect()
|
|||||||
to establish Federated connection to guard against a trivial
|
to establish Federated connection to guard against a trivial
|
||||||
Denial of Service scenerio.
|
Denial of Service scenerio.
|
||||||
*/
|
*/
|
||||||
safe_mutex_assert_not_owner(&LOCK_open);
|
mysql_mutex_assert_not_owner(&LOCK_open);
|
||||||
|
|
||||||
DBUG_ASSERT(mysql == NULL);
|
DBUG_ASSERT(mysql == NULL);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user