From 20a5872e69b349e9c893fed488669cffd4b7bd52 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Mar 2001 23:33:26 -0700 Subject: sql/mysqld.cc fixed concurrency bug with a very quickly disconnecting client - the client could disconnect and delete thd before pthread_create could write to &thd->real_id sql/sql_list.h while tracking down the bug, made new/delete go through my_malloc/my_free for ilink - did not help, but this is better anyway - cleaner exit with a message in out of memory codition at least. sql/mysqld.cc: fixed concurrency bug with a very quickly disconnecting client - the client could disconnect and delete thd before pthread_create could write to &thd->real_id sql/sql_list.h: while tracking down the bug, made new/delete go through my_malloc/my_free for ilink - did not help, but this is better anyway - cleaner exit with a message in out of memory codition at least. --- sql/mysqld.cc | 4 ++-- sql/sql_list.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f45614bd0a1..f4649a792b4 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2091,7 +2091,6 @@ static void create_new_thread(THD *thd) threads.append(thd); DBUG_PRINT("info",(("creating thread %d"), thd->thread_id)); thd->connect_time = time(NULL); - (void) pthread_mutex_unlock(&LOCK_thread_count); if ((error=pthread_create(&thd->real_id,&connection_attrib, handle_one_connection, (void*) thd))) @@ -2099,7 +2098,6 @@ static void create_new_thread(THD *thd) DBUG_PRINT("error", ("Can't create thread to handle request (error %d)", error)); - (void) pthread_mutex_lock(&LOCK_thread_count); thread_count--; thd->killed=1; // Safety (void) pthread_mutex_unlock(&LOCK_thread_count); @@ -2110,6 +2108,8 @@ static void create_new_thread(THD *thd) (void) pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; } + + (void) pthread_mutex_unlock(&LOCK_thread_count); } } DBUG_PRINT("info",(("Thread %d created"), thd->thread_id)); diff --git a/sql/sql_list.h b/sql/sql_list.h index 965d1ff9308..b86250f70b6 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -225,6 +225,15 @@ public: struct ilink { struct ilink **prev,*next; + static void *operator new(size_t size) + { + return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE)); + } + static void operator delete(void* ptr_arg, size_t size) + { + my_free((gptr)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); + } + inline ilink() { prev=0; next=0; -- cgit v1.2.1