]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Properly initialize libxml2
authorMichał Kępień <michal@isc.org>
Thu, 26 Sep 2019 08:20:26 +0000 (10:20 +0200)
committerMichał Kępień <michal@isc.org>
Thu, 26 Sep 2019 08:20:26 +0000 (10:20 +0200)
When libxml2 is to be used in a multi-threaded application, the
xmlInitThreads() function must be called before any other libxml2
function.  This function does different things on various platforms and
thus one can get away without calling it on Unix systems, but not on
Windows, where it initializes critical section objects used for
synchronizing access to data structures shared between threads.  Add the
missing xmlInitThreads() call to prevent crashes on affected systems.

Also add a matching xmlCleanupThreads() call to properly release the
resources set up by xmlInitThreads().

bin/named/statschannel.c

index 4d277d9ed8d3e61c269e7d62c33e45f4adba8baf..d7f864acec26edae58db0e3f7979b0382a7c40d0 100644 (file)
@@ -3587,6 +3587,10 @@ named_statschannels_configure(named_server_t *server, const cfg_obj_t *config,
 
        ISC_LIST_INIT(new_listeners);
 
+#ifdef HAVE_LIBXML2
+       xmlInitThreads();
+#endif /* HAVE_LIBXML2 */
+
        /*
         * Get the list of named.conf 'statistics-channels' statements.
         */
@@ -3719,6 +3723,10 @@ named_statschannels_shutdown(named_server_t *server) {
                ISC_LIST_UNLINK(server->statschannels, listener, link);
                shutdown_listener(listener);
        }
+
+#ifdef HAVE_LIBXML2
+       xmlCleanupThreads();
+#endif /* HAVE_LIBXML2 */
 }
 
 isc_result_t