summaryrefslogtreecommitdiff
path: root/server-tools
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@sun.com>2009-02-27 11:26:06 +0200
committerAlexey Kopytov <Alexey.Kopytov@sun.com>2009-02-27 11:26:06 +0200
commitf7cf8e57c12f435980bafb4f4b9c657a722345a4 (patch)
treeede7660d1ce7a18f7267f3cd27a0fff7cbcc8675 /server-tools
parent87fcb23d4b509f4b3b00f0e282b44f790a9cb2fd (diff)
downloadmariadb-git-f7cf8e57c12f435980bafb4f4b9c657a722345a4.tar.gz
Fix for bug #40552: Race condition around default_directories
in load_defaults() load_defaults(), my_search_option_files() and my_print_default_files() utilized a global variable containing a pointer to thread local memory. This could lead to race conditions when those functions were called with high concurrency. Fixed by changing the interface of the said functions to avoid the necessity for using a global variable. Since we cannot change load_defaults() prototype for API compatibility reasons, it was renamed my_load_defaults(). Now load_defaults() is a thread-unsafe wrapper around a thread-safe version, my_load_defaults(). mysys/default.c: 1. Added a thread-safe version of load_defaults(), changed load_defaults() with the old interface to be a thread-unsafe wrapper around the thread-safe version. 2. Always use a private MEM_ROOT in my_print_default_files, don't use a global variable. sql-common/client.c: Use a thread-safe version of load_defaults().
Diffstat (limited to 'server-tools')
-rw-r--r--server-tools/instance-manager/instance_map.cc3
-rw-r--r--server-tools/instance-manager/options.cc4
-rw-r--r--server-tools/instance-manager/options.h3
3 files changed, 8 insertions, 2 deletions
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index d7328d51cfe..b137370b50a 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -536,7 +536,8 @@ int Instance_map::load()
*/
if (my_search_option_files(Options::Main::config_file, &argc,
(char ***) &argv, &args_used,
- process_option, (void*) this))
+ process_option, (void*) this,
+ Options::default_directories))
log_info("Falling back to compiled-in defaults.");
return complete_initialization();
diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc
index 7eba3187dd9..6f084e7c63e 100644
--- a/server-tools/instance-manager/options.cc
+++ b/server-tools/instance-manager/options.cc
@@ -86,6 +86,7 @@ const char *Options::Main::bind_address= NULL; /* No default value */
uint Options::Main::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
uint Options::Main::port_number= DEFAULT_PORT;
my_bool Options::Main::mysqld_safe_compatible= FALSE;
+const char **Options::default_directories= NULL;
/* Options::User_management */
@@ -439,7 +440,8 @@ int Options::load(int argc, char **argv)
log_info("Loading config file '%s'...",
(const char *) Main::config_file);
- load_defaults(Main::config_file, default_groups, &argc, &saved_argv);
+ my_load_defaults(Main::config_file, default_groups, &argc,
+ &saved_argv, &default_directories);
if ((handle_options(&argc, &saved_argv, my_long_options, get_one_option)))
return ERR_INVALID_USAGE;
diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h
index 0202ca271c9..5d4df51faae 100644
--- a/server-tools/instance-manager/options.h
+++ b/server-tools/instance-manager/options.h
@@ -91,6 +91,9 @@ struct Options
#endif
public:
+ /* Array of paths to be passed to my_search_option_files() later */
+ static const char **default_directories;
+
static int load(int argc, char **argv);
static void cleanup();