Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=63…
Commit: 6329b3688fca66f5821dedb3f98268c06d2ef122
Parent: dcdb07c5d999d5f4b567a253268c71a14c5475cb
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 8 14:22:25 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 8 14:22:25 2012 +0200
cmannotifyd: deliver cluster status at startup and fix daemon init
cmannotifyd is very often (if not always) started _after_ cman is
completely settled. That means cmannotifyd does not receive/dispatch
any notifications on the current cluster status at startup.
change cman connection loop to generate a fake notification that
config and membership have changed (we can't poll if they did)
and use those information internally too, to reinit logging with
new cman connection.
Resolves: rhbz#819787
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/notifyd/main.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
index 3091d2f..4a9f868 100644
--- a/cman/notifyd/main.c
+++ b/cman/notifyd/main.c
@@ -189,6 +189,10 @@ static void init_logging(int reconf)
ccs_read_logging(ccs_handle, "cmannotifyd", &debug, &mode,
&syslog_facility, &syslog_priority, &logfile_priority, logfile);
ccs_disconnect(ccs_handle);
+ } else {
+ if (debug) {
+ logfile_priority = LOG_DEBUG;
+ }
}
if (!daemonize)
@@ -311,6 +315,8 @@ static void byebye_cman(void)
static void setup_cman(int forever)
{
int init = 0, active = 0;
+ int quorate;
+ const char *str = NULL;
retry_init:
cman_handle = cman_init(NULL);
@@ -346,6 +352,14 @@ retry_active:
exit(EXIT_FAILURE);
}
+ logt_print(LOG_DEBUG, "Dispatching first cluster status\n");
+ init_logging(1);
+ str = "CMAN_REASON_CONFIG_UPDATE";
+ dispatch_notification(str, 0);
+ str = "CMAN_REASON_STATECHANGE";
+ quorate = cman_is_quorate(cman_handle);
+ dispatch_notification(str, &quorate);
+
return;
out:
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=bf…
Commit: bff872891fc58d3f8895361e562be7c8416c937b
Parent: 17fbc520ac69a3b9eb4f33a738cdf6e0b11e4e22
Author: Jan Pokorný <jpokorny(a)redhat.com>
AuthorDate: Mon Apr 2 18:29:46 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 15:10:05 2012 -0400
rgmanager: resrules: simplify getting attributes + avoid memleaks
These memleaks (connected with attrname, dflt and ret) could occur
in some recoverable error corner cases.
Getting of default value is postponed until it is actually needed
(i.e., the value is not inherited which should have the priority,
at least as per in-code comment).
update v2:
Now, also avoid memleak upon store_attribute failure.
Signed-off-by: Jan Pokorný <jpokorny(a)redhat.com>
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/resrules.c | 39 ++++++++++++++++---------------------
1 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/rgmanager/src/daemons/resrules.c b/rgmanager/src/daemons/resrules.c
index 353ead4..557ef9c 100644
--- a/rgmanager/src/daemons/resrules.c
+++ b/rgmanager/src/daemons/resrules.c
@@ -711,28 +711,20 @@ static int
_get_rule_attrs(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
resource_rule_t *rr)
{
- char *ret, *attrname, *dflt = NULL, xpath[256];
+ char *ret, *attrname, xpath[256];
int x, flags, primary_found = 0;
for (x = 1; 1; x++) {
snprintf(xpath, sizeof(xpath), "%s/parameter[%d]/@name",
base, x);
- ret = xpath_get_one(doc,ctx,xpath);
- if (!ret)
+ attrname = xpath_get_one(doc,ctx,xpath);
+ if (!attrname)
break;
flags = 0;
- attrname = ret;
/*
- See if there's a default value.
- */
- snprintf(xpath, sizeof(xpath),
- "%s/parameter[%d]/content/@default", base, x);
- dflt = xpath_get_one(doc,ctx,xpath);
-
- /*
See if this is either the primary identifier or
a required field.
*/
@@ -761,6 +753,7 @@ _get_rule_attrs(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
if ((atoi(ret) != 0) || (ret[0] == 'y')) {
if (primary_found) {
free(ret);
+ free(attrname);
printf("Multiple primary "
"definitions for "
"resource type %s\n",
@@ -786,7 +779,8 @@ _get_rule_attrs(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
}
/*
- See if this is supposed to be inherited
+ See if this is supposed to be inherited;
+ inheritance supercedes a specified default value
*/
snprintf(xpath, sizeof(xpath), "%s/parameter[%d]/@inherit",
base, x);
@@ -795,31 +789,32 @@ _get_rule_attrs(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
if (flags & (RA_REQUIRED | RA_PRIMARY | RA_UNIQUE)) {
free(ret);
+ free(attrname);
printf("Can not inherit and be primary, "
"unique, or required\n");
return -1;
}
- /*
- don't free ret. Store as attr value. If we had
- a default value specified from above, free it;
- inheritance supercedes a specified default value.
- */
- if (dflt)
- free(dflt);
+
+ /* Don't free ret */
+
} else {
/*
Use default value, if specified, as the attribute
value.
*/
- ret = dflt;
+ snprintf(xpath, sizeof(xpath),
+ "%s/parameter[%d]/content/@default", base, x);
+ ret = xpath_get_one(doc,ctx,xpath);
}
/*
Store the attribute. We'll ensure all required
attributes are present soon.
*/
- if (attrname)
- store_attribute(&rr->rr_attrs, attrname, ret, flags);
+ if (store_attribute(&rr->rr_attrs, attrname, ret, flags) != 0) {
+ free(attrname);
+ free(ret);
+ }
}
return 0;
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=21…
Commit: 215dd94070707fdb421197bfe625fb9d531ecbec
Parent: 1e6034e5d698192f48b2317065b10d61410ac824
Author: Jan Pokorný <jpokorny(a)redhat.com>
AuthorDate: Mon Apr 2 13:29:52 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 15:10:05 2012 -0400
resrules: fix free while passing the pointer to caller
(due to previously misconfigured MUA, sorry for inconvenience)
The version ("OCF API Version" as declared in the code) for resource
rules cannot be obtained correctly as the memory is being immediately
freed before passing up to the caller. What's worse, the caller
could then access uninitialized memory through this pointer
(e.g., print_resource_rule).
The patch fixes this, making no difference between success
and failure in getting the version. Both should be handled
correctly when either dumping resource rule or destroying it.
Aside: was this version field ever actively used of is this a legacy
part not expected to be triggered?
[ I have no test case at hand, this was random spot, sorry. ]
Signed-off-by: Jan Pokorný <jpokorny(a)redhat.com>
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/resrules.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/rgmanager/src/daemons/resrules.c b/rgmanager/src/daemons/resrules.c
index cc59e30..581be9e 100644
--- a/rgmanager/src/daemons/resrules.c
+++ b/rgmanager/src/daemons/resrules.c
@@ -205,11 +205,8 @@ _get_version(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
snprintf(xpath, sizeof(xpath), "%s/@version", base);
ret = xpath_get_one(doc, ctx, xpath);
- if (ret) {
- rr->rr_version = ret;
- free(ret);
- }
- rr->rr_version = NULL;
+ /* NULL or actual result of the query */
+ rr->rr_version = ret;
}