1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Patch set contributed by Alex Budovski (MCA)

Fix for Bug#31173: mysqlslap.exe crashes if called without any parameters

.bzrignore:
  Fixed .bzrignore rules. Many were simply not ignoring what they were meant to.
client/mysqlslap.c:
  Fixed bug for Bug#31173: mysqlslap.exe crashes if called without any parameters
  The original patch could cause memory leaks and odd problems depending on how connection was made.
  This code ensures that all mysql_options() are set for each mysql_real_connect().
  (This patch by Monty)
mysys/my_thr_init.c:
  Fixed multiply-initialized critical section on Windows, due to code incorrectly
  checking the wrong field in an attempt to prevent multiple-initialization.
sql-common/client.c:
  Don't use shared memory if it's not set (for example after failed mysql_real_connect).
  Ensure that mysql_close() resets all resources so that it's safe to call it twice.
  (Patch by monty, related to Bug#31173: mysqlslap.exe crashes if called without any parameters)
sql/CMakeLists.txt:
   Added page fault counters for SHOW PROFILE on Windows.
sql/mysqld.cc:
  Fixed attempt to set a NULL event. The code now only sets the event if appropriate (i.e. shared memory is being used)
sql/sql_profile.cc:
  Added page fault counters for SHOW PROFILE on Windows.
sql/sql_profile.h:
  Added page fault counters for SHOW PROFILE on Windows.
sql/udf_example.def:
  Some cleanup functions were not exported from udf_example.dll, causing them to
  never be executed, and as a result multiple-initialization of kernel objects
  occurred and resources were not being freed correctly.
storage/maria/ma_close.c:
  Condition variable share->key_del_cond was never being destroyed, while its
  containing heap block was being freed in maria_close(), leaking kernel
  resources.
This commit is contained in:
Michael Widenius
2010-01-29 20:42:22 +02:00
parent ea0380f43c
commit e9bce6c9d4
10 changed files with 121 additions and 29 deletions

View File

@ -1940,7 +1940,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
#if defined(HAVE_SMEM)
if ((!mysql->options.protocol ||
mysql->options.protocol == MYSQL_PROTOCOL_MEMORY) &&
(!host || !strcmp(host,LOCAL_HOST)))
(!host || !strcmp(host,LOCAL_HOST)) &&
mysql->options.shared_memory_base_name)
{
if ((create_shared_memory(mysql,net, mysql->options.connect_timeout)) ==
INVALID_HANDLE_VALUE)
@ -1949,7 +1950,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
("host: '%s' socket: '%s' shared memory: %s have_tcpip: %d",
host ? host : "<null>",
unix_socket ? unix_socket : "<null>",
(int) mysql->options.shared_memory_base_name,
mysql->options.shared_memory_base_name,
(int) have_tcpip));
if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY)
goto error;
@ -2752,6 +2753,13 @@ void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)),
}
/*
Close a MySQL connection and free all resources attached to it.
This function is coded in such that it can be called multiple times
(As some clients call this after mysql_real_connect() fails)
*/
void STDCALL mysql_close(MYSQL *mysql)
{
DBUG_ENTER("mysql_close");
@ -2785,10 +2793,16 @@ void STDCALL mysql_close(MYSQL *mysql)
}
#endif
if (mysql != mysql->master)
{
mysql_close(mysql->master);
mysql->master= 0;
}
#ifndef MYSQL_SERVER
if (mysql->thd)
{
(*mysql->methods->free_embedded_thd)(mysql);
mysql->thd= 0;
}
#endif
if (mysql->free_me)
my_free((uchar*) mysql,MYF(0));