#At file:///home/ram/mysql/b40757-5.1-bugteam/ based on revid:chad@stripped
2750 Ramil Kalimullin 2009-01-29
Fix for bug #40757: Starting server on Windows with
innodb_flush_method=wrong_value causes crash
Problem: failed plugin initialization (e.g. due to improper parameters)
may result in server crash.
Fix: clean-up plugin related data if initialization failed.
modified:
sql/handler.cc
per-file messages:
sql/handler.cc
Fix for bug #40757: Starting server on Windows with
innodb_flush_method=wrong_value causes crash
- free allocated hton and set plugin->data
(pointing to handlerton) to NULL if plugin->init() fails,
as we use it as a sign that ha_initialize_handlerton() is failed,
which is used in ha_finalize_handlerton().
- do the same if there's no free slot for a plugin in the
hton2plugin[] array.
- call plugin->deinit() in such a case as we successfully
called plugin->init() before.
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2008-12-10 20:14:50 +0000
+++ b/sql/handler.cc 2009-01-29 17:03:03 +0000
@@ -429,14 +429,11 @@ int ha_initialize_handlerton(st_plugin_i
MYF(MY_WME | MY_ZEROFILL));
/* Historical Requirement */
plugin->data= hton; // shortcut for the future
- if (plugin->plugin->init)
+ if (plugin->plugin->init && plugin->plugin->init(hton))
{
- if (plugin->plugin->init(hton))
- {
- sql_print_error("Plugin '%s' init function returned error.",
- plugin->name.str);
- goto err;
- }
+ sql_print_error("Plugin '%s' init function returned error.",
+ plugin->name.str);
+ goto err;
}
/*
@@ -494,6 +491,14 @@ int ha_initialize_handlerton(st_plugin_i
{
sql_print_error("Too many plugins loaded. Limit is %lu. "
"Failed on '%s'", (ulong) MAX_HA, plugin->name.str);
+ /*
+ Let's plugin do its inner deinitialization as plugin->init()
+ was successfully called above.
+ */
+ if (plugin->plugin->deinit)
+ {
+ (void) plugin->plugin->deinit(NULL);
+ }
goto err;
}
hton->slot= total_ha++;
@@ -530,7 +535,10 @@ int ha_initialize_handlerton(st_plugin_i
};
DBUG_RETURN(0);
+
err:
+ my_free((uchar*) hton, MYF(0));
+ plugin->data= NULL;
DBUG_RETURN(1);
}