@@ -351,7 +351,6 @@ nc_clb_default_get_schema(struct lyd_node *rpc, struct nc_session *UNUSED(sessio
351351 const struct lys_module * module ;
352352 struct nc_server_error * err ;
353353 struct lyd_node * child , * data = NULL ;
354- const struct lys_node * sdata = NULL ;
355354
356355 LY_TREE_FOR (rpc -> child , child ) {
357356 if (!strcmp (child -> schema -> name , "identifier" )) {
@@ -399,13 +398,6 @@ nc_clb_default_get_schema(struct lyd_node *rpc, struct nc_session *UNUSED(sessio
399398 return NULL ;
400399 }
401400
402- sdata = ly_ctx_get_node (server_opts .ctx , NULL , "/ietf-netconf-monitoring:get-schema/output/data" );
403- if (!sdata ) {
404- ERRINT ;
405- free (model_data );
406- return NULL ;
407- }
408-
409401 data = lyd_new_path (NULL , server_opts .ctx , "/ietf-netconf-monitoring:get-schema/data" , model_data ,
410402 LYD_ANYDATA_STRING , LYD_PATH_OPT_OUTPUT );
411403 if (!data || lyd_validate (& data , LYD_OPT_RPCREPLY , NULL )) {
@@ -427,7 +419,8 @@ nc_clb_default_close_session(struct lyd_node *UNUSED(rpc), struct nc_session *se
427419API int
428420nc_server_init (struct ly_ctx * ctx )
429421{
430- const struct lys_node * rpc ;
422+ struct ly_set * set ;
423+ const struct lys_module * mod ;
431424
432425 if (!ctx ) {
433426 ERRARG ("ctx" );
@@ -437,15 +430,23 @@ nc_server_init(struct ly_ctx *ctx)
437430 nc_init ();
438431
439432 /* set default <get-schema> callback if not specified */
440- rpc = ly_ctx_get_node (ctx , NULL , "/ietf-netconf-monitoring:get-schema" );
441- if (rpc && !rpc -> priv ) {
442- lys_set_private (rpc , nc_clb_default_get_schema );
433+ mod = ly_ctx_get_module (ctx , "ietf-netconf-monitoring" , NULL );
434+ if (mod ) {
435+ set = lys_find_path (mod , NULL , "/get-schema" );
436+ if (!set -> set .s [0 ]-> priv ) {
437+ lys_set_private (set -> set .s [0 ], nc_clb_default_get_schema );
438+ }
439+ ly_set_free (set );
443440 }
444441
445442 /* set default <close-session> callback if not specififed */
446- rpc = ly_ctx_get_node (ctx , NULL , "/ietf-netconf:close-session" );
447- if (rpc && !rpc -> priv ) {
448- lys_set_private (rpc , nc_clb_default_close_session );
443+ mod = ly_ctx_get_module (ctx , "ietf-netconf" , NULL );
444+ if (mod ) {
445+ set = lys_find_path (mod , NULL , "/close-session" );
446+ if (!set -> set .s [0 ]-> priv ) {
447+ lys_set_private (set -> set .s [0 ], nc_clb_default_close_session );
448+ }
449+ ly_set_free (set );
449450 }
450451
451452 server_opts .ctx = ctx ;
@@ -1324,7 +1325,8 @@ nc_ps_poll(struct nc_pollsession *ps, int timeout, struct nc_session **session)
13241325 ret = NC_PSPOLL_ERROR ;
13251326 } else if (r == 1 ) {
13261327 /* no one else is currently working with the session, so we can, otherwise skip it */
1327- if (ps -> sessions [i ].state == NC_PS_STATE_NONE ) {
1328+ switch (ps -> sessions [i ].state ) {
1329+ case NC_PS_STATE_NONE :
13281330 if (cur_session -> status == NC_STATUS_RUNNING ) {
13291331 /* session is fine, work with it */
13301332 ps -> sessions [i ].state = NC_PS_STATE_BUSY ;
@@ -1358,9 +1360,16 @@ nc_ps_poll(struct nc_pollsession *ps, int timeout, struct nc_session **session)
13581360 }
13591361 ps -> sessions [i ].state = NC_PS_STATE_INVALID ;
13601362 }
1361- } else if (ps -> sessions [i ].state == NC_PS_STATE_BUSY ) {
1363+ break ;
1364+ case NC_PS_STATE_BUSY :
13621365 /* it definitely should not be busy because we have the lock */
13631366 ERRINT ;
1367+ ret = NC_PSPOLL_ERROR ;
1368+ break ;
1369+ case NC_PS_STATE_INVALID :
1370+ /* skip this session */
1371+ ret = NC_PSPOLL_TIMEOUT ;
1372+ break ;
13641373 }
13651374
13661375 /* keep the session locked only in this one case */
0 commit comments