abipkgdiff: Initialize libxml2 to use it in a multi-thread context
While running some test, I stumbled upon a transient deadlock happening when using libxml2's text reader to create a reader from a buffer. After reading the documentation at https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Thread-safety, I realized that users of the library need to initialize libxml2 before using it in a multi-thread setting. So this patch is providing the abigail::tools_utils::initialize() function to be called prior to using the library. This is going to be the place where to perform this kind of one-time initialization. * include/abg-tools-utils.h (initialize): Declare ... * src/abg-tools-utils.cc (initialize): ... new function. * tools/abipkgdiff.cc (main): Invoke the new abigail::tools_utils::initialize() here. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
3292453ee3
commit
4071543456
|
@ -30,6 +30,7 @@ using std::string;
|
|||
using std::set;
|
||||
using std::shared_ptr;
|
||||
|
||||
void initialize();
|
||||
const char* get_system_libdir();
|
||||
const char* get_anonymous_struct_internal_name_prefix();
|
||||
const char* get_anonymous_union_internal_name_prefix();
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
@ -76,6 +77,20 @@ using namespace abigail::ini;
|
|||
namespace tools_utils
|
||||
{
|
||||
|
||||
/// This function needs to be called before any libabigail function.
|
||||
///
|
||||
/// Users of libabigail must call it prior to using any of the
|
||||
/// functions of the library.
|
||||
///
|
||||
/// It intends to initialize the underlying libraries that might need
|
||||
/// initialization, especially, libxml2, in multi-threaded environments.
|
||||
void
|
||||
initialize()
|
||||
{
|
||||
LIBXML_TEST_VERSION;
|
||||
xmlInitParser();
|
||||
}
|
||||
|
||||
/// Get the value of $libdir variable of the autotools build
|
||||
/// system. This is where shared libraries are usually installed.
|
||||
///
|
||||
|
|
|
@ -3887,6 +3887,8 @@ main(int argc, char* argv[])
|
|||
| abigail::tools_utils::ABIDIFF_ERROR);
|
||||
}
|
||||
|
||||
abigail::tools_utils::initialize();
|
||||
|
||||
if (opts.self_check)
|
||||
return compare_to_self(first_package, opts);
|
||||
|
||||
|
|
Loading…
Reference in New Issue