Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confd: Don't cache libyang module references #237

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/confd/src/infix-system-software.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

#define SW_STATE_PATH_ "/ietf-system:system-state/infix-system:software"

static const struct lys_module *infix_system;

static RaucInstaller *infix_system_sw_new_rauc(void)
{
RaucInstaller *rauc;
Expand Down Expand Up @@ -183,6 +181,8 @@ static int infix_system_sw_state(sr_session_ctx_t *session, uint32_t sub_id,
struct lyd_node **parent, void *priv)
{
sr_error_t srerr = SR_ERR_INTERNAL;
const struct lys_module *ixsys;
const struct ly_ctx *ly;
RaucInstaller *rauc;
struct lyd_node *sw;

Expand All @@ -192,7 +192,15 @@ static int infix_system_sw_state(sr_session_ctx_t *session, uint32_t sub_id,
if (!rauc)
return SR_ERR_INTERNAL;

if (lyd_new_inner(*parent, infix_system, "software", 0, &sw))
ly = sr_acquire_context(sr_session_get_connection(session));
ixsys = ly_ctx_get_module_implemented(ly, "infix-system");
sr_release_context(sr_session_get_connection(session));
if (!ixsys) {
ERROR("infix-system module not found");
goto out;
}

if (lyd_new_inner(*parent, ixsys, "software", 0, &sw))
goto out;

srerr = infix_system_sw_state_fill(sw, rauc);
Expand Down Expand Up @@ -233,18 +241,8 @@ static int infix_system_sw_install(sr_session_ctx_t *session, uint32_t sub_id,

int infix_system_sw_init(struct confd *confd)
{
const struct ly_ctx *ly;
int rc = 0;

ly = sr_acquire_context(sr_session_get_connection(confd->session));
infix_system = ly_ctx_get_module_implemented(ly, "infix-system");
sr_release_context(sr_session_get_connection(confd->session));
if (!infix_system) {
ERROR("infix-system module not found");
rc = -ENOENT;
goto fail;
}

REGISTER_OPER(confd->session, "ietf-system", SW_STATE_PATH_,
infix_system_sw_state, NULL, 0, &confd->sub);

Expand Down