Rev 269: fixed setvnnmap to use wire structures too in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Wed May 9 22:22:28 GMT 2007


------------------------------------------------------------
revno: 269
revision-id: tridge at samba.org-20070509222226-gxev7f84ugyfdkti
parent: tridge at samba.org-20070509221319-2i6pfo0e6gudc6dz
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Thu 2007-05-10 08:22:26 +1000
message:
  fixed setvnnmap to use wire structures too
modified:
  common/ctdb_client.c           ctdb_client.c-20070411010216-3kd8v37k61steeya-1
  common/ctdb_recover.c          ctdb_recover.c-20070503002147-admmfgt1oj6gexfo-1
=== modified file 'common/ctdb_client.c'
--- a/common/ctdb_client.c	2007-05-09 22:13:19 +0000
+++ b/common/ctdb_client.c	2007-05-09 22:22:26 +0000
@@ -990,9 +990,19 @@
 	int ret;
 	TDB_DATA data, outdata;
 	int32_t res;
-
-	data.dsize = offsetof(struct ctdb_vnn_map, map) + 4*vnnmap->size;
-	data.dptr  = (unsigned char *)vnnmap;
+	struct ctdb_vnn_map_wire *map;
+	size_t len;
+
+	len = offsetof(struct ctdb_vnn_map_wire, map) + sizeof(uint32_t)*vnnmap->size;
+	map = talloc_size(mem_ctx, len);
+	CTDB_NO_MEMORY_VOID(ctdb, map);
+
+	map->generation = vnnmap->generation;
+	map->size = vnnmap->size;
+	memcpy(map->map, vnnmap->map, sizeof(uint32_t)*map->size);
+	
+	data.dsize = len;
+	data.dptr  = (uint8_t *)map;
 
 	ret = ctdb_control(ctdb, destnode, 0, 
 			   CTDB_CONTROL_SETVNNMAP, 0, data, 
@@ -1002,6 +1012,8 @@
 		return -1;
 	}
 
+	talloc_free(map);
+
 	return 0;
 }
 

=== modified file 'common/ctdb_recover.c'
--- a/common/ctdb_recover.c	2007-05-09 22:13:19 +0000
+++ b/common/ctdb_recover.c	2007-05-09 22:22:26 +0000
@@ -52,12 +52,19 @@
 int 
 ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
 {
-	if (ctdb->vnn_map) {
-		talloc_free(ctdb->vnn_map);
-		ctdb->vnn_map = NULL;
-	}
-
-	ctdb->vnn_map = (struct ctdb_vnn_map *)talloc_memdup(ctdb, indata.dptr, indata.dsize);
+	struct ctdb_vnn_map_wire *map = (struct ctdb_vnn_map_wire *)indata.dptr;
+
+	talloc_free(ctdb->vnn_map);
+
+	ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
+	CTDB_NO_MEMORY(ctdb, ctdb->vnn_map);
+
+	ctdb->vnn_map->generation = map->generation;
+	ctdb->vnn_map->size       = map->size;
+	ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, map->size);
+	CTDB_NO_MEMORY(ctdb, ctdb->vnn_map->map);
+
+	memcpy(ctdb->vnn_map->map, map->map, sizeof(uint32_t)*map->size);
 
 	return 0;
 }



More information about the samba-cvs mailing list