Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=6dbd73bff5c...
Commit: 6dbd73bff5c609a9b7aa57c8b15c7194554355df
Parent: 6d807b2d391332fbe401735603d6193a65a7aa3f
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Mon Jun 17 09:34:25 2013 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Wed Jun 19 21:34:19 2013 -0400
rgmanager: Fix improper use of xmlCleanupParser()
The libxml docs state that calling xmlCleanupParser() more than once
could result in memory corruption. I haven't been able to reproduce
memory corruption when calling from only one thread, but this function
does get called improperly any time the configuration is modified
after startup.
Related: rhbz#968322
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/main.c | 5 ++++-
rgmanager/src/daemons/resrules.c | 2 --
rgmanager/src/daemons/rg_locks.c | 4 +---
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index 59150c3..e5ba584 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <libxml/parser.h>
#include <rg_locks.h>
#include <fcntl.h>
#include <resgroup.h>
@@ -1129,6 +1130,8 @@ main(int argc, char **argv)
return -1;
}
+ xmlInitParser();
+
memset(&me, 0, sizeof(me));
cman_get_node(clu, CMAN_NODEID_US, &me);
@@ -1218,7 +1221,7 @@ main(int argc, char **argv)
if (rg_initialized())
cleanup(cluster_ctx);
-
+ xmlCleanupParser();
out_cleanup:
/* XXX - This hangs if CMAN has died, so we skip if we are
* exiting uncleanly. */
diff --git a/rgmanager/src/daemons/resrules.c b/rgmanager/src/daemons/resrules.c
index 97a09a1..9d700c4 100644
--- a/rgmanager/src/daemons/resrules.c
+++ b/rgmanager/src/daemons/resrules.c
@@ -1131,7 +1131,6 @@ load_resource_rules(const char *rpath, resource_rule_t **rules)
if (!dir)
return -1;
- xmlInitParser();
while ((de = readdir(dir))) {
fn = basename(de->d_name);
@@ -1173,7 +1172,6 @@ load_resource_rules(const char *rpath, resource_rule_t **rules)
load_resource_rulefile(path, rules);
}
}
- xmlCleanupParser();
closedir(dir);
diff --git a/rgmanager/src/daemons/rg_locks.c b/rgmanager/src/daemons/rg_locks.c
index ce81711..2222fd2 100644
--- a/rgmanager/src/daemons/rg_locks.c
+++ b/rgmanager/src/daemons/rg_locks.c
@@ -129,9 +129,7 @@ ccs_lock(void)
#else /* No ccs support */
{
pthread_mutex_lock(&_ccs_mutex);
- xmlInitParser();
- ccs_doc = xmlParseFile(conffile);
- xmlCleanupParser();
+ ccs_doc = xmlParseFile(conffile);
if (!ccs_doc)
return -1;
return 0;