* [Cluster-devel] [PATCH] cman: fix data copy and memory leak when reloading config
@ 2012-07-11 9:46 Fabio M. Di Nitto
2012-07-12 10:57 ` Christine Caulfield
0 siblings, 1 reply; 2+ messages in thread
From: Fabio M. Di Nitto @ 2012-07-11 9:46 UTC (permalink / raw)
To: cluster-devel.redhat.com
From: "Fabio M. Di Nitto" <fdinitto@redhat.com>
cman.cluster_id,nodename,two_node information were not copied
from the old to the new config at reload time. This triggers
a problem when <cman is set in cluster.conf and we effectively
drop information from objdb (suboptimal).
Also fix a possible memory leak when we have reload issues.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
cman/daemon/cman-preconfig.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 68fec22..22583fe 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -1478,6 +1478,7 @@ static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const
hdb_handle_t cluster_parent_handle_new;
unsigned int config_version = 0, config_version_new = 0;
char *config_value = NULL;
+ char str[255];
/* don't reload if we've been told to run configless */
if (getenv("CMAN_NOCONFIG")) {
@@ -1489,16 +1490,16 @@ static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const
/* find both /cluster entries */
objdb->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
objdb->object_find_next(find_handle, &cluster_parent_handle);
+ objdb->object_find_next(find_handle, &cluster_parent_handle_new);
+ objdb->object_find_destroy(find_handle);
if (!cluster_parent_handle) {
snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find old /cluster/ key in configuration\n");
goto err;
}
- objdb->object_find_next(find_handle, &cluster_parent_handle_new);
if (!cluster_parent_handle_new) {
snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find new /cluster/ key in configuration\n");
goto err;
}
- objdb->object_find_destroy(find_handle);
if (!objdb->object_key_get(cluster_parent_handle, "config_version", strlen("config_version"), (void *)&config_value, NULL)) {
if (config_value) {
@@ -1531,6 +1532,32 @@ static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const
/* destroy the old one */
objdb->object_destroy(cluster_parent_handle);
+ /*
+ * create cluster.cman in the new config if it doesn't exists
+ */
+ objdb->object_find_create(cluster_parent_handle_new, "cman", strlen("cman"), &find_handle);
+ if (objdb->object_find_next(find_handle, &object_handle)) {
+ objdb->object_create(cluster_parent_handle_new, &object_handle,
+ "cman", strlen("cman"));
+ }
+ objdb->object_find_destroy(find_handle);
+
+ /*
+ * readd cluster_id/two_node/nodename
+ */
+ snprintf(str, sizeof(str) - 1, "%d", cluster_id);
+ objdb->object_key_create_typed(object_handle, "cluster_id",
+ str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
+
+ if (two_node) {
+ snprintf(str, sizeof(str) - 1, "%d", 1);
+ objdb->object_key_create_typed(object_handle, "two_node",
+ str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
+ }
+
+ objdb->object_key_create_typed(object_handle, "nodename",
+ nodename, strlen(nodename)+1, OBJDB_VALUETYPE_STRING);
+
/* update the reference to the new config */
cluster_parent_handle = cluster_parent_handle_new;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [PATCH] cman: fix data copy and memory leak when reloading config
2012-07-11 9:46 [Cluster-devel] [PATCH] cman: fix data copy and memory leak when reloading config Fabio M. Di Nitto
@ 2012-07-12 10:57 ` Christine Caulfield
0 siblings, 0 replies; 2+ messages in thread
From: Christine Caulfield @ 2012-07-12 10:57 UTC (permalink / raw)
To: cluster-devel.redhat.com
ACK apart from the comments!
<see below>
On 11/07/12 10:46, Fabio M. Di Nitto wrote:
> From: "Fabio M. Di Nitto" <fdinitto@redhat.com>
>
> cman.cluster_id,nodename,two_node information were not copied
> from the old to the new config at reload time. This triggers
> a problem when <cman is set in cluster.conf and we effectively
> drop information from objdb (suboptimal).
>
> Also fix a possible memory leak when we have reload issues.
>
> Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> ---
> cman/daemon/cman-preconfig.c | 31 +++++++++++++++++++++++++++++--
> 1 files changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
> index 68fec22..22583fe 100644
> --- a/cman/daemon/cman-preconfig.c
> +++ b/cman/daemon/cman-preconfig.c
> @@ -1478,6 +1478,7 @@ static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const
> hdb_handle_t cluster_parent_handle_new;
> unsigned int config_version = 0, config_version_new = 0;
> char *config_value = NULL;
> + char str[255];
>
> /* don't reload if we've been told to run configless */
> if (getenv("CMAN_NOCONFIG")) {
> @@ -1489,16 +1490,16 @@ static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const
> /* find both /cluster entries */
> objdb->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
> objdb->object_find_next(find_handle, &cluster_parent_handle);
> + objdb->object_find_next(find_handle, &cluster_parent_handle_new);
> + objdb->object_find_destroy(find_handle);
> if (!cluster_parent_handle) {
> snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find old /cluster/ key in configuration\n");
> goto err;
> }
> - objdb->object_find_next(find_handle, &cluster_parent_handle_new);
> if (!cluster_parent_handle_new) {
> snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find new /cluster/ key in configuration\n");
> goto err;
> }
> - objdb->object_find_destroy(find_handle);
>
> if (!objdb->object_key_get(cluster_parent_handle, "config_version", strlen("config_version"), (void *)&config_value, NULL)) {
> if (config_value) {
> @@ -1531,6 +1532,32 @@ static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const
> /* destroy the old one */
> objdb->object_destroy(cluster_parent_handle);
>
> + /*
> + * create cluster.cman in the new config if it doesn't exists
* create cluster.cman in the new config if it doesn't exist
> + */
> + objdb->object_find_create(cluster_parent_handle_new, "cman", strlen("cman"), &find_handle);
> + if (objdb->object_find_next(find_handle, &object_handle)) {
> + objdb->object_create(cluster_parent_handle_new, &object_handle,
> + "cman", strlen("cman"));
> + }
> + objdb->object_find_destroy(find_handle);
> +
> + /*
> + * readd cluster_id/two_node/nodename
> + */
* write cluster_id/two_node/nodename
> + snprintf(str, sizeof(str) - 1, "%d", cluster_id);
> + objdb->object_key_create_typed(object_handle, "cluster_id",
> + str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
> +
> + if (two_node) {
> + snprintf(str, sizeof(str) - 1, "%d", 1);
> + objdb->object_key_create_typed(object_handle, "two_node",
> + str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
> + }
> +
> + objdb->object_key_create_typed(object_handle, "nodename",
> + nodename, strlen(nodename)+1, OBJDB_VALUETYPE_STRING);
> +
> /* update the reference to the new config */
> cluster_parent_handle = cluster_parent_handle_new;
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-12 10:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-11 9:46 [Cluster-devel] [PATCH] cman: fix data copy and memory leak when reloading config Fabio M. Di Nitto
2012-07-12 10:57 ` Christine Caulfield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).