Commit 3050b290 authored by Sergei Golubchik's avatar Sergei Golubchik

fix main.mysqldump test failing after Mroonga merge.

mysqlimport had code for multi-threaded import. By mistake it was disabled for
many years, at least since 5.5 (more likely even in 5.1), but mysqlimport happily
accepted (and ignored) --use-threads option ever since.

After Mroonga merge HAVE_LIBPTHREAD became defined and multi-threaded import
suddenly came to life. As it exit() the program brutally on any error (never mind
that some import threads may be running) mysys rightfully complains. Safemalloc
complains too in debug builds.

Fix: don't try a clean exit on an error, don't shutdown mysys and tell safemalloc
to shut up. Yes, and remove #ifdef HAVE_LIBPTHREAD, since 5.5 the client library
is always multi-threaded.
parent 44f9ddd7
...@@ -30,19 +30,15 @@ ...@@ -30,19 +30,15 @@
#include "client_priv.h" #include "client_priv.h"
#include "mysql_version.h" #include "mysql_version.h"
#ifdef HAVE_LIBPTHREAD
#include <my_pthread.h> #include <my_pthread.h>
#endif
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ #include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
/* Global Thread counter */ /* Global Thread counter */
uint counter; uint counter;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_t counter_mutex; pthread_mutex_t counter_mutex;
pthread_cond_t count_threshhold; pthread_cond_t count_threshhold;
#endif
static void db_error_with_table(MYSQL *mysql, char *table); static void db_error_with_table(MYSQL *mysql, char *table);
static void db_error(MYSQL *mysql); static void db_error(MYSQL *mysql);
...@@ -502,7 +498,10 @@ static void safe_exit(int error, MYSQL *mysql) ...@@ -502,7 +498,10 @@ static void safe_exit(int error, MYSQL *mysql)
free_defaults(argv_to_free); free_defaults(argv_to_free);
mysql_library_end(); mysql_library_end();
my_free(opt_password); my_free(opt_password);
my_end(my_end_arg); if (error)
sf_leaking_memory= 1; /* dirty exit, some threads are still running */
else
my_end(my_end_arg); /* clean exit */
exit(error); exit(error);
} }
...@@ -575,7 +574,6 @@ static char *field_escape(char *to,const char *from,uint length) ...@@ -575,7 +574,6 @@ static char *field_escape(char *to,const char *from,uint length)
int exitcode= 0; int exitcode= 0;
#ifdef HAVE_LIBPTHREAD
pthread_handler_t worker_thread(void *arg) pthread_handler_t worker_thread(void *arg)
{ {
int error; int error;
...@@ -615,7 +613,6 @@ error: ...@@ -615,7 +613,6 @@ error:
return 0; return 0;
} }
#endif
int main(int argc, char **argv) int main(int argc, char **argv)
...@@ -635,7 +632,6 @@ int main(int argc, char **argv) ...@@ -635,7 +632,6 @@ int main(int argc, char **argv)
} }
sf_leaking_memory=0; /* from now on we cleanup properly */ sf_leaking_memory=0; /* from now on we cleanup properly */
#ifdef HAVE_LIBPTHREAD
if (opt_use_threads && !lock_tables) if (opt_use_threads && !lock_tables)
{ {
pthread_t mainthread; /* Thread descriptor */ pthread_t mainthread; /* Thread descriptor */
...@@ -689,7 +685,6 @@ int main(int argc, char **argv) ...@@ -689,7 +685,6 @@ int main(int argc, char **argv)
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
} }
else else
#endif
{ {
MYSQL *mysql= 0; MYSQL *mysql= 0;
if (!(mysql= db_connect(current_host,current_db,current_user,opt_password))) if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))
......
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