From: Andrew Tridgell Date: Wed, 9 May 2007 22:22:26 +0000 (+1000) Subject: fixed setvnnmap to use wire structures too X-Git-Tag: tevent-0.9.20~348^2~2762 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a82665532bd2c61f2faa9b859488fdb5920666c;p=thirdparty%2Fsamba.git fixed setvnnmap to use wire structures too (This used to be ctdb commit 1208e4219d220b80e2f74974cac8ed2b8956d3ef) --- diff --git a/ctdb/common/ctdb_client.c b/ctdb/common/ctdb_client.c index eeff60d405f..c4d315d1e7b 100644 --- a/ctdb/common/ctdb_client.c +++ b/ctdb/common/ctdb_client.c @@ -990,9 +990,19 @@ int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb, struct timeval timeout, uint3 int ret; TDB_DATA data, outdata; int32_t res; + struct ctdb_vnn_map_wire *map; + size_t len; - data.dsize = offsetof(struct ctdb_vnn_map, map) + 4*vnnmap->size; - data.dptr = (unsigned char *)vnnmap; + 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 @@ int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb, struct timeval timeout, uint3 return -1; } + talloc_free(map); + return 0; } diff --git a/ctdb/common/ctdb_recover.c b/ctdb/common/ctdb_recover.c index fd63667dbec..8148182752e 100644 --- a/ctdb/common/ctdb_recover.c +++ b/ctdb/common/ctdb_recover.c @@ -52,12 +52,19 @@ ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA inda 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; - } + 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); - ctdb->vnn_map = (struct ctdb_vnn_map *)talloc_memdup(ctdb, indata.dptr, indata.dsize); + memcpy(ctdb->vnn_map->map, map->map, sizeof(uint32_t)*map->size); return 0; }