1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

ctdb-tests: Factor out get_ctdb_iface_list()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2016-12-04 00:59:29 +11:00 committed by Amitay Isaacs
parent b993771ab0
commit d42142246c

View File

@ -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;