Open SamSKore opened 1 week ago
Please include more details, what threads are you talking about and about what atomicity? nc_recv_notif_dispatch_data()
should create a thread every time it is called.
Hi Michal,
File name: netopeer2/cli/commands.c
Function name: int cmd_establishpush(const char *arg, char **tmp_config_file)
after handling of all command line args, following is the code:
/* create request */
if (periodic) {
rpc = nc_rpc_establishpush_periodic(datastore, filter, stop, encoding, period, anchor, NC_PARAMTYPE_CONST);
} else {
rpc = nc_rpc_establishpush_onchange(datastore, filter, stop, encoding, damp_period, sync_on_start,
(const char **)excluded_change, NC_PARAMTYPE_CONST);
}
if (!rpc) {
ERROR(__func__, "RPC creation failed.");
goto fail;
}
/* create notification thread so that notifications can immediately be received */
if (!nc_session_ntf_thread_running(session)) {
if (!output) {
output = stdout;
}
printf("calling nc_recv_notif_dispatch_data clb: %p\n", push_notif_clb);
ret = nc_recv_notif_dispatch_data(session, push_notif_clb, output, cli_ntf_free_data);
if (ret) {
ERROR(__func__, "Failed to create notification thread.");
goto fail;
}
}
ret = cli_send_recv(rpc, stdout, 0, timeout);
if (ret) {
goto fail;
}
The condition if (!nc_session_ntf_thread_running(session))
is not letting another thread to be created.
The function nc_session_ntf_thread_running
is defined in libnetconf2/src/session_client.c
Ah, you are talking about netopeer2-cli. Then you are out of luck, we are still keeping it as a rather simple single-session NETCONF client and there is no point for it to create more notification threads.
Hi Michal, Thanks for confirming.
If that is not planned yet, I think at least we shall have some parameter, based on which we could separate out the processing of notifications in order to process the data.
for ex. We could have one notification coming for running
datastore, another might have been configured for getting operational
datastore changes or may be a specific xpath.
This can be done by the id
received as the response of the establish-push
rpc. This id
can be returned from or be updated in cli_send_rcv
to keep the processing of the data coming from multiple notifications separate.
Currently lyd_print_file
is just printing it out inside cli_send_rcv
and returning back.
we could separate out the processing of notifications in order to process the data
What exactly do you mean by this? How do you want to separate them? There is only one stdout
.
Okay I can understand that the netopeer2-cli
is all about receiving the replies of the rpc and printing them out on stdout
.
What I'm trying to do with it is taking the data out from the lyd_node* to process it further for my application.
So thought there shall be some way to fetch the data out of multiple notifications without mixing them.
Hi,
I'm trying to establish notifications with 2 different datastores which will be served by 2 different callbacks.
datastore running
withfilter-xpath <module_1>
--on-changedatastore operational
withfilter-xpath <module_2
> --on-changeby changing the
cmd_establishpush
() fornc_recv_notif_dispatch_data
(), I'm givingcallback_1
in case of module_1 andcallback_2
in case of module_2.But it is not creating 2 separate threads for handling above 2 different notifications. What I understood at high level is that atomicity is being maintained. But if there are different callbacks which can handle the data separately for different notifications, it should not affect the atomicity.
Can you tell how can I achieve it?