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