summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_vacuum.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-12-29 17:16:33 +0100
committerAmitay Isaacs <amitay@gmail.com>2013-04-24 18:47:18 +1000
commita0e026498691144ac59a9ab4efa975570b531ea6 (patch)
tree6db9640e2b334ad5b358ea728ee36de8db4ca561 /ctdb/server/ctdb_vacuum.c
parentebc77602fc0397b19ddbf702270e8516fe3d1437 (diff)
downloadsamba-a0e026498691144ac59a9ab4efa975570b531ea6.tar.gz
samba-a0e026498691144ac59a9ab4efa975570b531ea6.tar.xz
samba-a0e026498691144ac59a9ab4efa975570b531ea6.zip
vacuum: add explicit temporary memory context to ctdb_process_delete_list()
This removes the implicit artificial talloc hierarchy and makes the code easier to understand. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-By: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit b7c3b8cdf92c597e621e3dae28b110d321de5ea8)
Diffstat (limited to 'ctdb/server/ctdb_vacuum.c')
-rw-r--r--ctdb/server/ctdb_vacuum.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index f829a67b2a3..d659b8eaff8 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -719,17 +719,25 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
struct ctdb_node_map *nodemap;
uint32_t *active_nodes;
int num_active_nodes;
+ TALLOC_CTX *tmp_ctx;
if (vdata->delete_count == 0) {
return 0;
}
+ tmp_ctx = talloc_new(vdata);
+ if (tmp_ctx == NULL) {
+ DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
+ return 0;
+ }
+
vdata->delete_left = vdata->delete_count;
- recs = talloc_zero(vdata, struct delete_records_list);
+ recs = talloc_zero(tmp_ctx, struct delete_records_list);
if (recs == NULL) {
DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
- return -1;
+ ret = -1;
+ goto done;
}
recs->records = (struct ctdb_marshall_buffer *)
talloc_zero_size(recs,
@@ -758,7 +766,7 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(),
CTDB_CURRENT_NODE,
- recs, /* talloc context */
+ tmp_ctx,
&nodemap);
if (ret != 0) {
DEBUG(DEBUG_ERR,(__location__ " unable to get node map\n"));
@@ -880,8 +888,7 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
ret = 0;
done:
- /* free recs / nodemap / active_nodes */
- talloc_free(recs);
+ talloc_free(tmp_ctx);
return ret;
}