summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-12-04 00:59:29 +1100
committerAmitay Isaacs <amitay@samba.org>2016-12-19 04:07:07 +0100
commitd42142246c4fcfc921815c6110eb98646ed75453 (patch)
tree3593b8feca586ce1e682e62f94b0ab3042ba9d64
parentb993771ab0c18802926ebf272fdcf23126532d76 (diff)
downloadsamba-d42142246c4fcfc921815c6110eb98646ed75453.tar.gz
ctdb-tests: Factor out get_ctdb_iface_list()
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r--ctdb/tests/src/fake_ctdbd.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
index 39bae600589..a1b8052d705 100644
--- a/ctdb/tests/src/fake_ctdbd.c
+++ b/ctdb/tests/src/fake_ctdbd.c
@@ -2182,31 +2182,24 @@ static void control_db_get_health(TALLOC_CTX *mem_ctx,
client_send_control(req, header, &reply);
}
-static void control_get_ifaces(TALLOC_CTX *mem_ctx,
- struct tevent_req *req,
- struct ctdb_req_header *header,
- struct ctdb_req_control *request)
+static struct ctdb_iface_list *get_ctdb_iface_list(TALLOC_CTX *mem_ctx,
+ struct ctdbd_context *ctdb)
{
- struct client_state *state = tevent_req_data(
- req, struct client_state);
- struct ctdbd_context *ctdb = state->ctdb;
- struct ctdb_reply_control reply;
struct ctdb_iface_list *iface_list;
struct interface *iface;
int i;
- reply.rdata.opcode = request->opcode;
-
iface_list = talloc_zero(mem_ctx, struct ctdb_iface_list);
if (iface_list == NULL) {
- goto fail;
+ goto done;
}
iface_list->num = ctdb->iface_map->num;
iface_list->iface = talloc_array(iface_list, struct ctdb_iface,
iface_list->num);
if (iface_list->iface == NULL) {
- goto fail;
+ TALLOC_FREE(iface_list);
+ goto done;
}
for (i=0; i<iface_list->num; i++) {
@@ -2219,6 +2212,28 @@ static void control_get_ifaces(TALLOC_CTX *mem_ctx,
sizeof(iface_list->iface[i].name));
}
+done:
+ return iface_list;
+}
+
+static void control_get_ifaces(TALLOC_CTX *mem_ctx,
+ struct tevent_req *req,
+ struct ctdb_req_header *header,
+ struct ctdb_req_control *request)
+{
+ struct client_state *state = tevent_req_data(
+ req, struct client_state);
+ struct ctdbd_context *ctdb = state->ctdb;
+ struct ctdb_reply_control reply;
+ struct ctdb_iface_list *iface_list;
+
+ reply.rdata.opcode = request->opcode;
+
+ iface_list = get_ctdb_iface_list(mem_ctx, ctdb);
+ if (iface_list == NULL) {
+ goto fail;
+ }
+
reply.rdata.data.iface_list = iface_list;
reply.status = 0;
reply.errmsg = NULL;