Skip to content

Commit

Permalink
Bug #30850310 MYSQLSLAP THREADS ARE NOT SHUT DOWN PROPERLY
Browse files Browse the repository at this point in the history
Do not call 'exit(0)' from multiple threads, it is not thread safe,
and will start multiple instances of atexit() handlers. If run_task()
encounters an error, close resources, and do pthread_exit().

Change-Id: I4f51e27740c99c353812c574d6515771470c3131
  • Loading branch information
Tor Didriksen authored and dahlerlend committed Mar 2, 2020
1 parent 4ab2308 commit 8799388
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions client/mysqlslap.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
Expand Down Expand Up @@ -1737,7 +1737,7 @@ extern "C" void *run_task(void *p) {
if (!(mysql = mysql_init(nullptr))) {
fprintf(stderr, "%s: mysql_init() failed ERROR : %s\n", my_progname,
mysql_error(mysql));
exit(0);
goto end;
}

if (slap_connect(mysql)) goto end;
Expand Down Expand Up @@ -1774,16 +1774,14 @@ extern "C" void *run_task(void *p) {
if (run_query(mysql, buffer, length)) {
fprintf(stderr, "%s: Cannot run query %.*s ERROR : %s\n",
my_progname, (uint)length, buffer, mysql_error(mysql));
mysql_close(mysql);
exit(0);
goto end;
}
}
} else {
if (run_query(mysql, ptr->string, ptr->length)) {
fprintf(stderr, "%s: Cannot run query %.*s ERROR : %s\n", my_progname,
(uint)ptr->length, ptr->string, mysql_error(mysql));
mysql_close(mysql);
exit(0);
goto end;
}
}

Expand Down

0 comments on commit 8799388

Please sign in to comment.