From b439e653d731c4d106cbf55ff0a3ece5b056db14 Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Mon, 3 Sep 2012 15:33:44 +0200 Subject: [PATCH] Fix race condition in usage of libxml2 --- src/createrepo_c.c | 4 ++++ src/xml_dump.c | 15 +++++++++++++++ src/xml_dump.h | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/createrepo_c.c b/src/createrepo_c.c index 71ad5a1..e4c50c1 100644 --- a/src/createrepo_c.c +++ b/src/createrepo_c.c @@ -143,6 +143,7 @@ dumper_thread(gpointer data, gpointer user_data) const char *location_href = task->full_path + udata->repodir_name_len; const char *location_base = udata->location_base; + // Get stat info about file if (udata->old_metadata && !(udata->skip_stat)) { if (stat(task->full_path, &stat_buf) == -1) { @@ -745,6 +746,7 @@ main(int argc, char **argv) // Init package parser cr_package_parser_init(); + cr_dumper_init(); // Thread pool - User data initialization @@ -796,6 +798,8 @@ main(int argc, char **argv) g_thread_pool_free(pool, FALSE, TRUE); g_message("Pool finished"); + cr_dumper_cleanup(); + cr_puts(user_data.pri_f, ""); cr_puts(user_data.fil_f, ""); cr_puts(user_data.oth_f, ""); diff --git a/src/xml_dump.c b/src/xml_dump.c index 8bbbfc4..9717d56 100644 --- a/src/xml_dump.c +++ b/src/xml_dump.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "logging.h" #include "misc.h" @@ -31,6 +32,20 @@ void +cr_dumper_init() +{ + xmlInitParser(); +} + + +void +cr_dumper_cleanup() +{ + xmlCleanupParser(); +} + + +void cr_dump_files(xmlNodePtr node, cr_Package *package, int primary) { if (!node || !package->files) { diff --git a/src/xml_dump.h b/src/xml_dump.h index 18976b2..4e8de11 100644 --- a/src/xml_dump.h +++ b/src/xml_dump.h @@ -51,6 +51,16 @@ struct cr_XmlStruct { }; /** \ingroup xml_dump + * Initialize dumping part of library (Initialize libxml2). + */ +void cr_dumper_init(); + +/** \ingroup xml_dump + * Cleanup initialized dumping part of library + */ +void cr_dumper_cleanup(); + +/** \ingroup xml_dump * Generate primary xml chunk from cr_Package. * @param package cr_Package * @return xml chunk string or NULL on error -- 2.7.4