BUGFIX libyang changes
diff --git a/src/session_client.c b/src/session_client.c
index 96a526f..4ef9d7c 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -627,7 +627,7 @@
goto cleanup;
}
- modules = lyd_find_xpath(data_rpl->data, "/ietf-yang-library:modules-state/module");
+ modules = lyd_find_path(data_rpl->data, "/ietf-yang-library:modules-state/module");
if (!modules || !modules->number) {
ERR("No yang-library modules information for session %u.", session->id);
goto cleanup;
diff --git a/src/session_server.c b/src/session_server.c
index 68a3f50..b982cf9 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -351,7 +351,6 @@
const struct lys_module *module;
struct nc_server_error *err;
struct lyd_node *child, *data = NULL;
- const struct lys_node *sdata = NULL;
LY_TREE_FOR(rpc->child, child) {
if (!strcmp(child->schema->name, "identifier")) {
@@ -399,13 +398,6 @@
return NULL;
}
- sdata = ly_ctx_get_node(server_opts.ctx, NULL, "/ietf-netconf-monitoring:get-schema/output/data");
- if (!sdata) {
- ERRINT;
- free(model_data);
- return NULL;
- }
-
data = lyd_new_path(NULL, server_opts.ctx, "/ietf-netconf-monitoring:get-schema/data", model_data,
LYD_ANYDATA_STRING, LYD_PATH_OPT_OUTPUT);
if (!data || lyd_validate(&data, LYD_OPT_RPCREPLY, NULL)) {
@@ -427,7 +419,8 @@
API int
nc_server_init(struct ly_ctx *ctx)
{
- const struct lys_node *rpc;
+ struct ly_set *set;
+ const struct lys_module *mod;
if (!ctx) {
ERRARG("ctx");
@@ -437,15 +430,23 @@
nc_init();
/* set default <get-schema> callback if not specified */
- rpc = ly_ctx_get_node(ctx, NULL, "/ietf-netconf-monitoring:get-schema");
- if (rpc && !rpc->priv) {
- lys_set_private(rpc, nc_clb_default_get_schema);
+ mod = ly_ctx_get_module(ctx, "ietf-netconf-monitoring", NULL);
+ if (mod) {
+ set = lys_find_path(mod, NULL, "/get-schema");
+ if (!set->set.s[0]->priv) {
+ lys_set_private(set->set.s[0], nc_clb_default_get_schema);
+ }
+ ly_set_free(set);
}
/* set default <close-session> callback if not specififed */
- rpc = ly_ctx_get_node(ctx, NULL, "/ietf-netconf:close-session");
- if (rpc && !rpc->priv) {
- lys_set_private(rpc, nc_clb_default_close_session);
+ mod = ly_ctx_get_module(ctx, "ietf-netconf", NULL);
+ if (mod) {
+ set = lys_find_path(mod, NULL, "/close-session");
+ if (!set->set.s[0]->priv) {
+ lys_set_private(set->set.s[0], nc_clb_default_close_session);
+ }
+ ly_set_free(set);
}
server_opts.ctx = ctx;
@@ -1324,7 +1325,8 @@
ret = NC_PSPOLL_ERROR;
} else if (r == 1) {
/* no one else is currently working with the session, so we can, otherwise skip it */
- if (ps->sessions[i].state == NC_PS_STATE_NONE) {
+ switch (ps->sessions[i].state) {
+ case NC_PS_STATE_NONE:
if (cur_session->status == NC_STATUS_RUNNING) {
/* session is fine, work with it */
ps->sessions[i].state = NC_PS_STATE_BUSY;
@@ -1358,9 +1360,16 @@
}
ps->sessions[i].state = NC_PS_STATE_INVALID;
}
- } else if (ps->sessions[i].state == NC_PS_STATE_BUSY) {
+ break;
+ case NC_PS_STATE_BUSY:
/* it definitely should not be busy because we have the lock */
ERRINT;
+ ret = NC_PSPOLL_ERROR;
+ break;
+ case NC_PS_STATE_INVALID:
+ /* skip this session */
+ ret = NC_PSPOLL_TIMEOUT;
+ break;
}
/* keep the session locked only in this one case */
diff --git a/tests/test_fd_comm.c b/tests/test_fd_comm.c
index e4eee70..d3d6042 100644
--- a/tests/test_fd_comm.c
+++ b/tests/test_fd_comm.c
@@ -324,7 +324,8 @@
{
int ret;
const struct lys_module *module;
- const struct lys_node *node;
+ struct ly_set *set;
+ uint16_t i;
/* create ctx */
ctx = ly_ctx_new(TESTS_DIR"../schemas");
@@ -338,13 +339,15 @@
assert_non_null(module);
/* set RPC callbacks */
- node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:get");
- assert_non_null(node);
- lys_set_private(node, my_get_rpc_clb);
-
- node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:get-config");
- assert_non_null(node);
- lys_set_private(node, my_getconfig_rpc_clb);
+ set = lys_find_path(module, NULL, "/*");
+ for (i = 0; i < set->number; ++i) {
+ if (!strcmp(set->set.s[i]->name, "get")) {
+ lys_set_private(set->set.s[i], my_get_rpc_clb);
+ } else if (!strcmp(set->set.s[i]->name, "get-config")) {
+ lys_set_private(set->set.s[i], my_getconfig_rpc_clb);
+ }
+ }
+ ly_set_free(set);
nc_server_init(ctx);