Blame SOURCES/mariadb-client-memory-leak.patch
|
|
4284b5 |
# Fix created by Stephane Carrez, little modification by Lukas Javorsky
|
|
|
4284b5 |
# https://bugs.mysql.com/bug.php?id=66740
|
|
|
4284b5 |
# Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689827
|
|
|
4284b5 |
|
|
|
4284b5 |
--- mariadb-5.5.65/mysys/my_thr_init.c.memleak 2019-08-08 11:40:51.223474780 +0200
|
|
|
4284b5 |
+++ mariadb-5.5.65/mysys/my_thr_init.c 2019-10-10 09:40:38.591175329 +0200
|
|
|
4284b5 |
@@ -35,6 +35,7 @@
|
|
|
4284b5 |
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
|
|
4284b5 |
mysql_mutex_t LOCK_localtime_r;
|
|
|
4284b5 |
#endif
|
|
|
4284b5 |
+static void thread_cleanup(void* data);
|
|
|
4284b5 |
#ifdef _MSC_VER
|
|
|
4284b5 |
static void install_sigabrt_handler();
|
|
|
4284b5 |
#endif
|
|
|
4284b5 |
@@ -195,7 +196,7 @@
|
|
|
4284b5 |
without calling my_init() + my_end().
|
|
|
4284b5 |
*/
|
|
|
4284b5 |
if (!my_thr_key_mysys_exists &&
|
|
|
4284b5 |
- (pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
|
|
|
4284b5 |
+ (pth_ret= pthread_key_create(&THR_KEY_mysys, thread_cleanup)) != 0)
|
|
|
4284b5 |
{
|
|
|
4284b5 |
fprintf(stderr, "Can't initialize threads: error %d\n", pth_ret);
|
|
|
4284b5 |
return 1;
|
|
|
4284b5 |
@@ -400,6 +401,19 @@
|
|
|
4284b5 |
|
|
|
4284b5 |
pthread_setspecific(THR_KEY_mysys,0);
|
|
|
4284b5 |
|
|
|
4284b5 |
+ /* Cleanup using the Posix 1003.1 standard mechanism with pthread_key_create */
|
|
|
4284b5 |
+ thread_cleanup(tmp);
|
|
|
4284b5 |
+}
|
|
|
4284b5 |
+
|
|
|
4284b5 |
+
|
|
|
4284b5 |
+/*
|
|
|
4284b5 |
+ Do the real thread memory cleanup. This is called explictly by
|
|
|
4284b5 |
+ my_thread_end() or by the Posix 1003.1 thread cleanup mechanism.
|
|
|
4284b5 |
+*/
|
|
|
4284b5 |
+static void thread_cleanup(void* data)
|
|
|
4284b5 |
+{
|
|
|
4284b5 |
+ struct st_my_thread_var *tmp = (struct st_my_thread_var*) data;
|
|
|
4284b5 |
+
|
|
|
4284b5 |
if (tmp && tmp->init)
|
|
|
4284b5 |
{
|
|
|
4284b5 |
#if !defined(DBUG_OFF)
|