]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
fixed setvnnmap to use wire structures too
authorAndrew Tridgell <tridge@samba.org>
Wed, 9 May 2007 22:22:26 +0000 (08:22 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 9 May 2007 22:22:26 +0000 (08:22 +1000)
(This used to be ctdb commit 1208e4219d220b80e2f74974cac8ed2b8956d3ef)

ctdb/common/ctdb_client.c
ctdb/common/ctdb_recover.c

index eeff60d405ff5517af4401207089144803a15aa9..c4d315d1e7bdc74a5b50a7003620b4083dbab892 100644 (file)
@@ -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;
 }
 
index fd63667dbec335ca3a6c666a17399e5c220934f0..8148182752eefa94e93613254b8ec31601f50b0c 100644 (file)
@@ -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;
 }