From 3050b290d5123af0bfa7abf94570b3c8e1ca05df Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 Oct 2014 22:07:19 +0200 Subject: [PATCH] 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. --- client/mysqlimport.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index af0d86b1ed5..0d4ee549c4f 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -30,19 +30,15 @@ #include "client_priv.h" #include "mysql_version.h" -#ifdef HAVE_LIBPTHREAD #include -#endif #include /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ /* Global Thread counter */ uint counter; -#ifdef HAVE_LIBPTHREAD pthread_mutex_t counter_mutex; pthread_cond_t count_threshhold; -#endif static void db_error_with_table(MYSQL *mysql, char *table); static void db_error(MYSQL *mysql); @@ -502,7 +498,10 @@ static void safe_exit(int error, MYSQL *mysql) free_defaults(argv_to_free); mysql_library_end(); 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); } @@ -575,7 +574,6 @@ static char *field_escape(char *to,const char *from,uint length) int exitcode= 0; -#ifdef HAVE_LIBPTHREAD pthread_handler_t worker_thread(void *arg) { int error; @@ -615,7 +613,6 @@ error: return 0; } -#endif 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 */ -#ifdef HAVE_LIBPTHREAD if (opt_use_threads && !lock_tables) { pthread_t mainthread; /* Thread descriptor */ @@ -689,7 +685,6 @@ int main(int argc, char **argv) pthread_attr_destroy(&attr); } else -#endif { MYSQL *mysql= 0; if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))