From ddc960db4bbbcb38ad1413c4aaedb742c12cc5d3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 1 May 2014 15:43:51 +0200 Subject: [PATCH] MDEV-6091 mysqldump goes in a loop and segfaults if --dump-slave is specified and it cannot connect to the server do_start_slave_sql() is called from maybe_exit(). We should not recurse when maybe_exit() is called for an error during do_start_slave_sql(). Also remove a meaningless (but safe) "goto err". --- client/mysqldump.c | 9 +++++---- mysql-test/t/mysqldump.test | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index a8c201082d9..fa02c74615c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1496,12 +1496,13 @@ static void free_resources() static void maybe_exit(int error) { - if (opt_slave_data) - do_start_slave_sql(mysql); if (!first_error) first_error= error; if (ignore_errors) return; + ignore_errors= 1; /* don't want to recurse, if something fails below */ + if (opt_slave_data) + do_start_slave_sql(mysql); if (mysql) mysql_close(mysql); free_resources(); @@ -5682,8 +5683,8 @@ int main(int argc, char **argv) */ err: /* if --dump-slave , start the slave sql thread */ - if (opt_slave_data && do_start_slave_sql(mysql)) - goto err; + if (opt_slave_data) + do_start_slave_sql(mysql); #ifdef HAVE_SMEM my_free(shared_memory_base_name); diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 9824abe7d43..20afec8b63f 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -2455,3 +2455,10 @@ drop table t1, t2; --echo # --echo # End of 5.1 tests --echo # + +# +# MDEV-6091 mysqldump goes in a loop and segfaults if --dump-slave is specified and it cannot connect to the server +# +--error 2 +--exec $MYSQL_DUMP -hunknownhost --dump-slave nulldb +