Skip to content

Commit a272e09

Browse files
committed
session client UPDATE allow manual context fill
... for new sessions.
1 parent 96da591 commit a272e09

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/session_client.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ nc_client_get_schema_callback(void **user_data)
321321
return client_opts.schema_clb;
322322
}
323323

324+
API void
325+
nc_client_set_new_session_context_autofill(int enabled)
326+
{
327+
client_opts.auto_context_fill_disabled = !enabled;
328+
}
329+
324330
struct module_info {
325331
char *name;
326332
char *revision;
@@ -1240,6 +1246,11 @@ nc_ctx_check_and_fill(struct nc_session *session)
12401246

12411247
assert(session->opts.client.cpblts && session->ctx);
12421248

1249+
if (client_opts.auto_context_fill_disabled) {
1250+
VRB(session, "Context of the new session is left only with the default YANG modules.");
1251+
return 0;
1252+
}
1253+
12431254
/* store the original user's callback, we will be switching between local search, get-schema and user callback */
12441255
old_clb = ly_ctx_get_module_imp_clb(session->ctx, &old_data);
12451256

src/session_client.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data);
8383
*/
8484
ly_module_imp_clb nc_client_get_schema_callback(void **user_data);
8585

86+
/**
87+
* @brief Enable/disable loading of all the YANG modules supported by
88+
* the server when a new session is created. If disabled, it is expected
89+
* that users update the context themselves and load the YANG modules
90+
* that are planned to be used. Otherwise even basic RPCs may fail to be sent!
91+
*
92+
* @param[in] enabled Whether context autofill is enabled or disabled.
93+
*/
94+
void nc_client_set_new_session_context_autofill(int enabled);
95+
8696
/**
8797
* @brief Use the provided thread-specific client's context in the current thread.
8898
*

src/session_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ struct nc_server_unix_opts {
145145
/* ACCESS unlocked */
146146
struct nc_client_opts {
147147
char *schema_searchpath;
148+
int auto_context_fill_disabled;
148149
ly_module_imp_clb schema_clb;
149150
void *schema_clb_data;
150151
struct nc_keepalives ka;

0 commit comments

Comments
 (0)