summaryrefslogtreecommitdiff
path: root/storage/connect/libdoc.cpp
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2013-10-29 13:44:05 +0400
committerAlexander Barkov <bar@mnogosearch.org>2013-10-29 13:44:05 +0400
commit3a424fc1190e876c3bc6fcf25b45586c1f22bed7 (patch)
tree4f64667d445f3c2db9b5714043a13b7bd7613a2a /storage/connect/libdoc.cpp
parent7dc48ae327ad27205dffe0cec16b445d01529f84 (diff)
downloadmariadb-git-3a424fc1190e876c3bc6fcf25b45586c1f22bed7.tar.gz
ConnectSE: fixing memory leaks reported by valgrind
Diffstat (limited to 'storage/connect/libdoc.cpp')
-rw-r--r--storage/connect/libdoc.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp
index 31aa90da076..e6046a07c5c 100644
--- a/storage/connect/libdoc.cpp
+++ b/storage/connect/libdoc.cpp
@@ -8,6 +8,9 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
+#include <libxml/catalog.h>
+#include <libxml/xmlschemastypes.h>
+#include <libxml/relaxng.h>
//#if defined(WIN32)
//#include <windows.h>
//#else // !WIN32
@@ -290,10 +293,46 @@ if (!rc)
/******************************************************************/
/* XML library cleanup function. */
/******************************************************************/
+/*
+ This is a copy of xmlCleanupParser() from the libxml2 sources
+ with xmlResetLastError() commented.
+
+ xmlResetLastError() called from the original xmlCleanupParser() causes
+ valgrind to report memory leaks. This happens because
+ ha_initialize_handlerton() is called from the main thread in mysqld.cc,
+ while ha_finalize_handlerton() is called from a non-main thread.
+ libxml2 gets confused because of xmlInitParser() and xmlCleanupParser()
+ being called from the different threads.
+
+ Perhaps the code in mysqld.cc should eventually be modified
+ to shutdown plugins from the main thread.
+*/
+static void
+xmlCleanupParser_replacement(void)
+ {
+ xmlCleanupCharEncodingHandlers();
+#ifdef LIBXML_CATALOG_ENABLED
+ xmlCatalogCleanup();
+#endif
+ xmlDictCleanup();
+ xmlCleanupInputCallbacks();
+#ifdef LIBXML_OUTPUT_ENABLED
+ xmlCleanupOutputCallbacks();
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
+ xmlSchemaCleanupTypes();
+ xmlRelaxNGCleanupTypes();
+#endif
+ //xmlResetLastError();
+ xmlCleanupGlobals();
+ xmlCleanupThreads(); /* must be last if called not from the main thread */
+ xmlCleanupMemory();
+ }
+
+
void XmlCleanupParserLib(void)
{
- xmlCleanupParser();
- xmlMemoryDump();
+ xmlCleanupParser_replacement();
} // end of XmlCleanupParserLib
/******************************************************************/