ruxob
May 19, 2017, 1:05pm
1
Hello,
i m using mappi_create in my callpoint function and im adding a new elem in my list.
so i’m going in my callpoint function everytime im addind an elem in my list.
How to avoid recursive callpoint.
tailf:callpoint cause_callpoint_add {
tailf:transaction-hook node;
tailf:config “true”;
}
HI,
See maapi_attach(). I.e. you attach to the transaction in your init() callback:
static int init_trans(struct confd_trans_ctx *tctx)
{
OK(maapi_attach(msock, my__ns, tctx));
confd_trans_set_fd(tctx, workersock);
return CONFD_OK;
}
Note that there is no need to commit, e.g. using maapi_apply_trans() after your maapi_create() since you attached to a transaction that will be committed after your hook.
ruxob
July 6, 2017, 9:16am
3
@cohult it doesn’t works ;(
I’m reading the confd user guide but it’s not very clear.
workersock is the socket inside tctx (tctx->fd) right ?
so inside my function_create_elem at the begining i add init_trans right ?
Do you have an exemple ?
If you have access to ConfD premium, examples.confd/snmpa/11-different-keys/hook.c is a good reference, else something similar to one of the below:
$ find $CONFD_DIR -name "*.c" | xargs grep "maapi_attach"
$CONFD_DIR/examples.confd/cdb_upgrade/moved_servers/server_upgrade.c: maapi_attach_init(ms, &th);
$CONFD_DIR/examples.confd/cdb_upgrade/using_maapi/server_upgrade.c: maapi_attach_init(ms, &th);
$CONFD_DIR/examples.confd/cli/cli_command/add_user.c: if ((maapi_attach2(msock, 0, usid, thandle)) != CONFD_OK)
$CONFD_DIR/examples.confd/cli/cli_command/show_snmp.c: if ((maapi_attach2(msock, SNMPv2_MIB__ns, usid, thandle)) != CONFD_OK)
$CONFD_DIR/examples.confd/cli/climods/more_a_than_b.c: OK(maapi_attach(maapi_socket, test__ns, tctx));
$CONFD_DIR/examples.confd/in_service_upgrade/with_helper/src/v2/upgrade_helper.c: OK(maapi_attach_init(ms, &th));
$CONFD_DIR/examples.confd/misc/aaa_transform/users_aaa.c: OK(maapi_attach(maapi_socket, 0, tctx));
$CONFD_DIR/examples.confd/misc/notifications/confd_notifications.c: OK(maapi_attach(maapi_socket, -1, tctx));
$CONFD_DIR/examples.confd/validate/c/more_a_than_b.c: OK(maapi_attach(maapi_socket, mtest__ns, tctx));
$CONFD_DIR/examples.confd/validate/c_dependency/more_a_than_b.c: OK(maapi_attach(maapi_socket, mtest__ns, tctx));
$CONFD_DIR/src/confd/cli/maapi.c: if ((maapi_attach2(msock, -1, usid, thandle)) != CONFD_OK)
$CONFD_DIR/src/confd/cli/maapi.c: if (maapi_attach2(msock, 0, usid, thandle) != CONFD_OK)
$CONFD_DIR/src/confd/tools/confd_cmd.c:static void do_maapi_attach_init(char *argv[])
$CONFD_DIR/src/confd/tools/confd_cmd.c: OK(maapi_attach_init(ms, &mtid));
$CONFD_DIR/src/confd/tools/confd_cmd.c: "mattach_init", {NULL}, do_maapi_attach_init, 0,
$CONFD_DIR/src/confd/tools/confd_load.c: OK(maapi_attach_init(sock, &tid));
$CONFD_DIR/src/confd/tools/confd_load.c: OK(maapi_attach2(sock, 0, usid, tid));