diff --git a/example/main/example_backend.c b/example/main/example_backend.c index b2fbc532..e4df5dd8 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -203,7 +203,7 @@ example_copy_extra(clicon_handle h, /* Clicon handle */ { int retval = -1; - fprintf(stderr, "%s\n", __FUNCTION__); + // fprintf(stderr, "%s\n", __FUNCTION__); retval = 0; // done: return retval; diff --git a/lib/clixon/clixon_yang.h b/lib/clixon/clixon_yang.h index 944e9a8f..8f5c775a 100644 --- a/lib/clixon/clixon_yang.h +++ b/lib/clixon/clixon_yang.h @@ -138,18 +138,9 @@ typedef enum yang_class yang_class; struct xml; -/* Yang data node - * See RFC7950 Sec 3: - * o data node: A node in the schema tree that can be instantiated in a - * data tree. One of container, leaf, leaf-list, list, anydata, and - * anyxml. - * XXX move to function - */ -#define yang_datanode(y) ((y)->ys_keyword == Y_CONTAINER || (y)->ys_keyword == Y_LEAF || (y)->ys_keyword == Y_LIST || (y)->ys_keyword == Y_LEAF_LIST || (y)->ys_keyword == Y_ANYXML || (y)->ys_keyword == Y_ANYDATA) - - typedef struct yang_stmt yang_stmt; /* Defined in clixon_yang_internal */ + typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg); /* @@ -197,6 +188,7 @@ int ys_populate(yang_stmt *ys, void *arg); yang_stmt *yang_parse_file(int fd, const char *name, yang_stmt *ysp); int yang_apply(yang_stmt *yn, enum rfc_6020 key, yang_applyfn_t fn, void *arg); +int yang_datanode(yang_stmt *ys); int yang_abs_schema_nodeid(yang_stmt *yspec, yang_stmt *ys, char *schema_nodeid, enum rfc_6020 keyword, yang_stmt **yres); diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 63d2958f..d8d3df12 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -297,7 +297,9 @@ text_modify(clicon_handle h, } #ifdef USE_XML_INSERT /* Add new xml node but without parent - insert when node fully - copied (see changed conditional below) */ + * copied (see changed conditional below) + * Note x0 may dangle cases if exit before changed conditional + */ if ((x0 = xml_new(x1name, NULL, (yang_stmt*)y0)) == NULL) goto done; #else @@ -400,6 +402,11 @@ text_modify(clicon_handle h, #endif retval = 1; done: +#ifdef USE_XML_INSERT + /* Remove dangling added objects */ + if (changed && x0 && xml_parent(x0)==NULL) + xml_purge(x0); +#endif if (x0vec) free(x0vec); return retval; diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 1735df14..b65aef9a 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -934,9 +934,9 @@ xml_wrap(cxobj *xc, * @retval 0 OK * @retval -1 * @note you cannot remove xchild in the loop (unless yoy keep track of xprev) - * + * @note Linear complexity - use xml_child_rm if possible * @see xml_free Free, dont remove from parent - * @see xml_child_rm Only remove dont free + * @see xml_child_rm Remove if child order is known (does not free) * Differs from xml_free it is removed from parent. */ int diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index 25722f11..0d7be1b6 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -2867,6 +2867,26 @@ yang_apply(yang_stmt *yn, return retval; } +/*! Check if a node is a yang "data node" + * @param[in] ys Yang statement node + * @retval 0 Yang node is NOT a data node + * @retval !=0 Yang node IS a data noed + * @see RFC7950 Sec 3: + * o data node: A node in the schema tree that can be instantiated in a + * data tree. One of container, leaf, leaf-list, list, anydata, and + * anyxml. + */ +int +yang_datanode(yang_stmt *ys) +{ + return (yang_keyword_get(ys) == Y_CONTAINER || + yang_keyword_get(ys) == Y_LEAF || + yang_keyword_get(ys) == Y_LIST || + yang_keyword_get(ys) == Y_LEAF_LIST || + yang_keyword_get(ys) == Y_ANYXML || + yang_keyword_get(ys) == Y_ANYDATA); +} + /*! All the work for schema_nodeid functions both absolute and descendant * Ignore prefixes, see _abs * @param[in] yn Yang node. Find next yang stmt and return that if match. diff --git a/test/test_perf.sh b/test/test_perf.sh index c3df0aa3..3990a939 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -5,7 +5,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi # Number of list/leaf-list entries in file -: ${perfnr:=20000} +: ${perfnr:=10000} # Number of requests made get/put : ${perfreq:=100} diff --git a/test/test_startup.sh b/test/test_startup.sh index ac4be92f..8ec21156 100755 --- a/test/test_startup.sh +++ b/test/test_startup.sh @@ -169,16 +169,19 @@ testrun startup "$runvar" "$startvar" "$extravar" '