diff --git a/lib/src/clixon_yang_internal.h b/lib/src/clixon_yang_internal.h index 28b8d0ad..d9a4ca42 100644 --- a/lib/src/clixon_yang_internal.h +++ b/lib/src/clixon_yang_internal.h @@ -102,7 +102,9 @@ struct yang_stmt{ Y_EXTENSION: vector of instantiated UNKNOWNS Y_UNKNOWN: app-dep: yang-mount-points */ - int ys_ref; /* Reference count for free, only YS_SPEC */ + int ys_ref; /* Reference count for free, only YS_SPEC: 0 means + * no sharing, 1: two references + */ yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */ char *ys_when_xpath; /* Special conditional for a "when"-associated augment/uses xpath */ cvec *ys_when_nsc; /* Special conditional for a "when"-associated augment/uses namespace ctx */ diff --git a/lib/src/clixon_yang_schema_mount.c b/lib/src/clixon_yang_schema_mount.c index a4cc0f08..efbfa4ab 100644 --- a/lib/src/clixon_yang_schema_mount.c +++ b/lib/src/clixon_yang_schema_mount.c @@ -276,7 +276,6 @@ yang_mount_set(yang_stmt *y, /* tag yspec with key/xpath */ yang_cv_set(yspec, cv2); cv_void_set(cv, yspec); - yang_ref_inc(yspec); /* share */ yang_flag_set(y, YANG_FLAG_MOUNTPOINT); /* Cache value */ retval = 0; done: @@ -1017,10 +1016,11 @@ int yang_schema_yanglib_parse_mount(clixon_handle h, cxobj *xt) { - int retval = -1; - cxobj *xyanglib = NULL; - yang_stmt *yspec = NULL; - int ret; + int retval = -1; + cxobj *xyanglib = NULL; + yang_stmt *yspec = NULL; + int ret; + int shared = 0; /* 1. Get modstate (xyanglib) of node: xyanglib, by querying backend state (via callback) * XXX this xyanglib is not proper RFC8525, submodules appear as modules WHY? @@ -1033,6 +1033,8 @@ yang_schema_yanglib_parse_mount(clixon_handle h, if (clicon_option_bool(h, "CLICON_YANG_SCHEMA_MOUNT_SHARE")) { if (yang_schema_find_share(h, xt, xyanglib, &yspec) < 0) goto done; + if (yspec) + shared++; } if (yspec == NULL){ /* Parse it and set mount-point */ @@ -1045,6 +1047,8 @@ yang_schema_yanglib_parse_mount(clixon_handle h, } if (xml_yang_mount_set(h, xt, yspec) < 0) goto done; + if (shared) + yang_ref_inc(yspec); yspec = NULL; retval = 1; done: diff --git a/test/test_datastore_multi.sh b/test/test_datastore_multi.sh index 54a943cd..6c8be1f0 100755 --- a/test/test_datastore_multi.sh +++ b/test/test_datastore_multi.sh @@ -377,12 +377,15 @@ fi # move running.d/0.xml to running_db to trigger upgrade sudo mv $dir/running.d/0.xml $dir/running_db -new "Check backward compatible: if running.0/0.xml is not found read running_db on startup" +new "Check backward compatible: if running.d/0.xml is not found read running_db on startup" if [ $BE -ne 0 ]; then new "start backend -s running -f $cfg -- -m clixon-mount1 -M urn:example:mount1" start_backend -s running -f $cfg -- -m clixon-mount1 -M urn:example:mount1 fi +new "wait backend 2" +wait_backend + new "Check running after restart" check_db running ${subfilename}