Commit 6d1ab231 authored by unknown's avatar unknown

Fix for using unitialized mutex when running version compiled with --debug


include/mysql_embed.h:
  Disable shared memory for embedded version
libmysqld/lib_sql.cc:
  Fix for --debug version (init_thread_environment was called in wrong place)
sql/log_event.h:
  Portability fix
sql/mysqld.cc:
  Fix for --debug version (init_thread_environment was called in wrong place)
sql/sql_parse.cc:
  Simply code cleanup
parent 7e2aca56
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#undef HAVE_OPENSSL #undef HAVE_OPENSSL
#undef HAVE_VIO #undef HAVE_VIO
#undef HAVE_ISAM #undef HAVE_ISAM
#undef HAVE_SMEM /* No shared memory */
#define DONT_USE_RAID #define DONT_USE_RAID
......
...@@ -200,12 +200,6 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) ...@@ -200,12 +200,6 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0]) if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */ opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
if (init_thread_environment())
{
mysql_server_end();
return 1;
}
umask(((~my_umask) & 0666)); umask(((~my_umask) & 0666));
if (init_server_components()) if (init_server_components())
{ {
......
...@@ -583,7 +583,7 @@ class Intvar_log_event: public Log_event ...@@ -583,7 +583,7 @@ class Intvar_log_event: public Log_event
~Intvar_log_event() {} ~Intvar_log_event() {}
Log_event_type get_type_code() { return INTVAR_EVENT;} Log_event_type get_type_code() { return INTVAR_EVENT;}
const char* get_var_type_name(); const char* get_var_type_name();
int get_data_size() { return sizeof(type) + sizeof(val);} int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;}
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
bool is_valid() { return 1; } bool is_valid() { return 1; }
}; };
...@@ -616,7 +616,7 @@ class Rand_log_event: public Log_event ...@@ -616,7 +616,7 @@ class Rand_log_event: public Log_event
Rand_log_event(const char* buf, bool old_format); Rand_log_event(const char* buf, bool old_format);
~Rand_log_event() {} ~Rand_log_event() {}
Log_event_type get_type_code() { return RAND_EVENT;} Log_event_type get_type_code() { return RAND_EVENT;}
int get_data_size() { return sizeof(ulonglong) * 2; } int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
bool is_valid() { return 1; } bool is_valid() { return 1; }
}; };
......
...@@ -494,6 +494,7 @@ static void start_signal_handler(void); ...@@ -494,6 +494,7 @@ static void start_signal_handler(void);
extern "C" pthread_handler_decl(signal_hand, arg); extern "C" pthread_handler_decl(signal_hand, arg);
static void set_options(void); static void set_options(void);
static void get_options(int argc,char **argv); static void get_options(int argc,char **argv);
static int init_thread_environment();
static char *get_relative_path(const char *path); static char *get_relative_path(const char *path);
static void fix_paths(void); static void fix_paths(void);
extern "C" pthread_handler_decl(handle_connections_sockets,arg); extern "C" pthread_handler_decl(handle_connections_sockets,arg);
...@@ -504,11 +505,9 @@ static bool read_init_file(char *file_name); ...@@ -504,11 +505,9 @@ static bool read_init_file(char *file_name);
#ifdef __NT__ #ifdef __NT__
extern "C" pthread_handler_decl(handle_connections_namedpipes,arg); extern "C" pthread_handler_decl(handle_connections_namedpipes,arg);
#endif #endif
#if !defined(EMBEDDED_LIBRARY)
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
static pthread_handler_decl(handle_connections_shared_memory,arg); static pthread_handler_decl(handle_connections_shared_memory,arg);
#endif #endif
#endif /* EMBEDDED_LIBRARY */
extern "C" pthread_handler_decl(handle_slave,arg); extern "C" pthread_handler_decl(handle_slave,arg);
#ifdef SET_RLIMIT_NOFILE #ifdef SET_RLIMIT_NOFILE
static uint set_maximum_open_files(uint max_file_limit); static uint set_maximum_open_files(uint max_file_limit);
...@@ -2033,6 +2032,8 @@ static int init_common_variables(const char *conf_file_name, int argc, ...@@ -2033,6 +2032,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
defaults_argv=argv; defaults_argv=argv;
set_options(); set_options();
get_options(argc,argv); get_options(argc,argv);
if (init_thread_environment())
return 1;
if (opt_log || opt_update_log || opt_slow_log || opt_bin_log) if (opt_log || opt_update_log || opt_slow_log || opt_bin_log)
strcat(server_version,"-log"); strcat(server_version,"-log");
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
...@@ -2300,7 +2301,6 @@ static void handle_connections_methods() ...@@ -2300,7 +2301,6 @@ static void handle_connections_methods()
handler_count--; handler_count--;
} }
} }
#if !defined(EMBEDDED_LIBRARY)
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
if (opt_enable_shared_memory) if (opt_enable_shared_memory)
{ {
...@@ -2313,7 +2313,6 @@ static void handle_connections_methods() ...@@ -2313,7 +2313,6 @@ static void handle_connections_methods()
} }
} }
#endif #endif
#endif // EMBEDDED_LIBRARY
while (handler_count > 0) while (handler_count > 0)
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count); pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
...@@ -2349,8 +2348,6 @@ int main(int argc, char **argv) ...@@ -2349,8 +2348,6 @@ int main(int argc, char **argv)
init_signals(); init_signals();
if (!(opt_specialflag & SPECIAL_NO_PRIOR)) if (!(opt_specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),CONNECT_PRIOR); my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
if (init_thread_environment())
unireg_abort(1);
pthread_attr_setstacksize(&connection_attrib,thread_stack); pthread_attr_setstacksize(&connection_attrib,thread_stack);
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
{ {
...@@ -2683,6 +2680,7 @@ static int bootstrap(FILE *file) ...@@ -2683,6 +2680,7 @@ static int bootstrap(FILE *file)
int error= 0; int error= 0;
DBUG_ENTER("bootstrap"); DBUG_ENTER("bootstrap");
#ifndef EMBEDDED_LIBRARY // TODO: Enable this #ifndef EMBEDDED_LIBRARY // TODO: Enable this
THD *thd= new THD; THD *thd= new THD;
thd->bootstrap=1; thd->bootstrap=1;
thd->client_capabilities=0; thd->client_capabilities=0;
......
...@@ -1059,9 +1059,6 @@ bool do_command(THD *thd) ...@@ -1059,9 +1059,6 @@ bool do_command(THD *thd)
bool dispatch_command(enum enum_server_command command, THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length) char* packet, uint packet_length)
{ {
#ifndef EMBEDDED_LIBRARY
int res;
#endif
NET *net= &thd->net; NET *net= &thd->net;
bool error= 0; bool error= 0;
/* /*
...@@ -1138,7 +1135,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1138,7 +1135,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char tmp_db[NAME_LEN+1]; char tmp_db[NAME_LEN+1];
ACL_USER* cached_user ; /* Cached user */ ACL_USER* cached_user ; /* Cached user */
uint cur_priv_version; /* Cached grant version */ uint cur_priv_version; /* Cached grant version */
ulong pkt_len=0; /* Length of reply packet */ int res;
ulong pkt_len= 0; /* Length of reply packet */
bzero((char*) prepared_scramble, sizeof(prepared_scramble)); bzero((char*) prepared_scramble, sizeof(prepared_scramble));
/* Small check for incomming packet */ /* Small check for incomming packet */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment