1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Fixed compiler warnings

Fixed compile-pentium64 scripts
Fixed wrong estimate of update_with_key_prefix in sql-bench
Merge bk-internal.mysql.com:/home/bk/mysql-5.1 into mysql.com:/home/my/mysql-5.1
Fixed unsafe define of uint4korr()
Fixed that --extern works with mysql-test-run.pl
Small trivial cleanups
This also fixes a bug in counting number of rows that are updated when we have many simultanous queries
Move all connection handling and command exectuion main loop from sql_parse.cc to sql_connection.cc
Split handle_one_connection() into reusable sub functions.
Split create_new_thread() into reusable sub functions.
Added thread_scheduler; Preliminary interface code for future thread_handling code.

Use 'my_thread_id' for internal thread id's
Make thr_alarm_kill() to depend on thread_id instead of thread
Make thr_abort_locks_for_thread() depend on thread_id instead of thread
In store_globals(), set my_thread_var->id to be thd->thread_id.
Use my_thread_var->id as basis for my_thread_name()
The above changes makes the connection we have between THD and threads more soft.

Added a lot of DBUG_PRINT() and DBUG_ASSERT() functions
Fixed compiler warnings
Fixed core dumps when running with --debug
Removed setting of signal masks (was never used)
Made event code call pthread_exit() (portability fix)
Fixed that event code doesn't call DBUG_xxx functions before my_thread_init() is called.
Made handling of thread_id and thd->variables.pseudo_thread_id uniform.
Removed one common 'not freed memory' warning from mysqltest
Fixed a couple of usage of not initialized warnings (unlikely cases)
Suppress compiler warnings from bdb and (for the moment) warnings from ndb
This commit is contained in:
monty@mysql.com/narttu.mysql.fi
2007-02-23 13:13:55 +02:00
parent a5051aa4eb
commit f0ae3ce9b9
171 changed files with 2307 additions and 2592 deletions

View File

@ -46,23 +46,23 @@ pthread_mutexattr_t my_fast_mutexattr;
pthread_mutexattr_t my_errorcheck_mutexattr;
#endif
#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */
#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */
/*
Dummy thread spawned in my_thread_global_init() below to avoid
race conditions in NPTL pthread_exit code.
Dummy thread spawned in my_thread_global_init() below to avoid
race conditions in NPTL pthread_exit code.
*/
static
pthread_handler_t nptl_pthread_exit_hack_handler(void *arg)
static pthread_handler_t
nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
{
/* Do nothing! */
pthread_exit(0);
return 0;
}
#endif
/*
initialize thread environment
@ -83,25 +83,28 @@ my_bool my_thread_global_init(void)
}
#ifdef NPTL_PTHREAD_EXIT_BUG
/*
BUG#24507: Race conditions inside current NPTL pthread_exit()
implementation.
/*
BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.
To avoid a possible segmentation fault during concurrent executions of
pthread_exit(), a dummy thread is spawned which initializes internal variables
of pthread lib. See bug description for thoroughfull explanation.
To avoid a possible segmentation fault during concurrent
executions of pthread_exit(), a dummy thread is spawned which
initializes internal variables of pthread lib. See bug description
for a full explanation.
TODO: Remove this code when fixed versions of glibc6 are in common use.
*/
TODO: Remove this code when fixed versions of glibc6 are in common
use.
*/
{
pthread_t dummy_thread;
pthread_attr_t dummy_thread_attr;
pthread_t dummy_thread;
pthread_attr_t dummy_thread_attr;
pthread_attr_init(&dummy_thread_attr);
pthread_attr_setdetachstate(&dummy_thread_attr,PTHREAD_CREATE_DETACHED);
pthread_create(&dummy_thread,&dummy_thread_attr,nptl_pthread_exit_hack_handler,NULL);
pthread_attr_init(&dummy_thread_attr);
pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_DETACHED);
pthread_create(&dummy_thread,&dummy_thread_attr,
nptl_pthread_exit_hack_handler, NULL);
}
#endif
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
@ -206,7 +209,7 @@ void my_thread_global_end(void)
#endif
}
static long thread_id=0;
static my_thread_id thread_id= 0;
/*
Allocate thread specific memory for the thread, used by mysys and dbug
@ -234,15 +237,16 @@ my_bool my_thread_init(void)
my_bool error=0;
#ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self());
fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n",
(ulong) pthread_self());
#endif
#if !defined(__WIN__) || defined(USE_TLS)
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
{
#ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init() called more than once in thread %ld\n",
pthread_self());
fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
(long) pthread_self());
#endif
goto end;
}
@ -262,7 +266,9 @@ my_bool my_thread_init(void)
tmp= &THR_KEY_mysys;
#endif
#if defined(__WIN__) && defined(EMBEDDED_LIBRARY)
tmp->thread_self= (pthread_t)getpid();
tmp->pthread_self= (pthread_t) getpid();
#else
tmp->pthread_self= pthread_self();
#endif
pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
pthread_cond_init(&tmp->suspend, NULL);
@ -272,6 +278,11 @@ my_bool my_thread_init(void)
tmp->id= ++thread_id;
++THR_thread_count;
pthread_mutex_unlock(&THR_LOCK_threads);
#ifndef DBUG_OFF
/* Generate unique name for thread */
(void) my_thread_name();
#endif
end:
return error;
}
@ -295,8 +306,8 @@ void my_thread_end(void)
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
#ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_end(): tmp: 0x%lx thread_id=%ld\n",
(long) tmp, pthread_self());
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);
#endif
if (tmp && tmp->init)
{
@ -357,17 +368,9 @@ struct st_my_thread_var *_my_thread_var(void)
Get name of current thread.
****************************************************************************/
#define UNKNOWN_THREAD -1
long my_thread_id()
my_thread_id my_thread_dbug_id()
{
#if defined(HAVE_PTHREAD_GETSEQUENCE_NP)
return pthread_getsequence_np(pthread_self());
#elif (defined(__sun) || defined(__sgi) || defined(__linux__))
return pthread_self();
#else
return my_thread_var->id;
#endif
}
#ifdef DBUG_OFF
@ -384,8 +387,8 @@ const char *my_thread_name(void)
struct st_my_thread_var *tmp=my_thread_var;
if (!tmp->name[0])
{
long id=my_thread_id();
sprintf(name_buff,"T@%ld", id);
my_thread_id id= my_thread_dbug_id();
sprintf(name_buff,"T@%lu", (ulong) id);
strmake(tmp->name,name_buff,THREAD_NAME_SIZE);
}
return tmp->name;