Re: [PATCH] objctl: add missing calls to dispatch notifications and fix memory corruption

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ACK

Fabio M. Di Nitto napsal(a):
From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>

when editing the objdb via objctl, we need to notify objdb users of changes.
That includes the logging subsystem.

In the process of adding the reload call, i spotted that objctl was passing
an incorrect value for key_value_len that was one off (0 byte end string)
that was corrupting the keys.

[root@rhel6-node2 ~]# corosync-objctl -w logging.debug=off
....
Apr 24 07:42:59 corosync [corosy] fabdebug: off2@

Resolves: rhbz#773720

Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
 tools/corosync-objctl.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/tools/corosync-objctl.c b/tools/corosync-objctl.c
index d043865..d7909bb 100644
--- a/tools/corosync-objctl.c
+++ b/tools/corosync-objctl.c
@@ -240,6 +240,18 @@ static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object
 	}
 }
+static cs_error_t reload_db(confdb_handle_t handle)
+{
+	char error[1024];
+	cs_error_t ret;
+
+	ret = confdb_reload(handle, 0, error, sizeof(error) - 1);
+	if (ret != CONFDB_OK) {
+		fprintf (stderr, "Error reloading DB %d\n", ret);
+	}
+	return ret;
+}
+
 static int read_in_config_file (char * filename)
 {
 	confdb_handle_t handle;
@@ -310,7 +322,7 @@ static int read_in_config_file (char * filename)
 		/* write the attribute */
 		write_key (handle, line);
 	}
-
+	reload_db(handle);
 	confdb_finalize (handle);
 	fclose (fh);
 	return 0;
@@ -516,7 +528,7 @@ static void write_key(confdb_handle_t handle, char * path_pt)
 								  old_key_value,
 								  old_key_value_len,
 								  key_value,
-								  strlen(key_value));
+								  strlen(key_value)+1);
if (res != CS_OK)
 			fprintf(stderr, "Failed to replace the key %s=%s. Error %d\n", key_name, key_value, res);
@@ -526,7 +538,7 @@ static void write_key(confdb_handle_t handle, char * path_pt)
 								 obj_handle,
 								 key_name,
 								 key_value,
-								 strlen(key_value),
+								 strlen(key_value)+1,
 								 CONFDB_VALUETYPE_STRING);
 		if (res != CS_OK)
 			fprintf(stderr, "Failed to create the key %s=%s. Error %d\n", key_name, key_value, res);
@@ -645,7 +657,7 @@ static void create_object_key(confdb_handle_t handle, char *name_pt)
 		obj_handle,
 		key_name,
 		key_value,
-		strlen(key_value),
+		strlen(key_value)+1,
 		CONFDB_VALUETYPE_STRING);
 	if (res != CS_OK) {
 		fprintf(stderr,
@@ -910,6 +922,8 @@ int main (int argc, char *argv[]) {
 	if (action == ACTION_TRACK) {
 		listen_for_object_changes(handle);
 		stop_tracking(handle);
+	} else {
+		reload_db(handle);
 	}
result = confdb_finalize (handle);

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux