* Corrected problem with namespace context cache, was not always cleared when adding new subtrees.

This commit is contained in:
Olof hagsand 2019-08-08 11:29:01 +02:00
parent aa14f8ac2c
commit bb2eaa3cc7
4 changed files with 25 additions and 0 deletions

View file

@ -47,6 +47,7 @@
* pseudo-plugin added, to enable callbacks also for main programs. Useful for extensions * pseudo-plugin added, to enable callbacks also for main programs. Useful for extensions
### Corrected Bugs ### Corrected Bugs
* Corrected problem with namespace context cache, was not always cleared when adding new subtrees.
* Corrected CLI bug with lists of multiple keys (netconf/restconf works). * Corrected CLI bug with lists of multiple keys (netconf/restconf works).
* Worked in 3.10, but broke in 4.0 * Worked in 3.10, but broke in 4.0
* Example: `yang list x { key "a b";...}` * Example: `yang list x { key "a b";...}`

View file

@ -108,6 +108,7 @@ char *xml_name(cxobj *xn);
int xml_name_set(cxobj *xn, char *name); int xml_name_set(cxobj *xn, char *name);
char *xml_prefix(cxobj *xn); char *xml_prefix(cxobj *xn);
int xml_prefix_set(cxobj *xn, char *name); int xml_prefix_set(cxobj *xn, char *name);
int nscache_clear(cxobj *x);
int xml2ns(cxobj *x, char *localname, char **namespace); int xml2ns(cxobj *x, char *localname, char **namespace);
int xmlns_set(cxobj *x, char *prefix, char *namespace); int xmlns_set(cxobj *x, char *prefix, char *namespace);
cxobj *xml_parent(cxobj *xn); cxobj *xml_parent(cxobj *xn);

View file

@ -271,6 +271,23 @@ nscache_set(cxobj *x,
return retval; return retval;
} }
/*! Clear cached namespace context
* Clear the whole namespace context, not just single cache lines
* @param[in] x XML node
* @retval 0 OK
* @see nscache_set For setting specific namespace cache lines
* @see xml_addsub
*/
int
nscache_clear(cxobj *x)
{
if (x->x_ns_cache != NULL){
xml_nsctx_free(x->x_ns_cache);
x->x_ns_cache = NULL;
}
return 0;
}
/*! Given an xml tree return URI namespace recursively : default or localname given /*! Given an xml tree return URI namespace recursively : default or localname given
* *
* Given an XML tree and a prefix (or NULL) return URI namespace. * Given an XML tree and a prefix (or NULL) return URI namespace.
@ -934,6 +951,7 @@ xml_find(cxobj *x_up,
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
* @see xml_wrap * @see xml_wrap
* @see xml_insert
* @note xc is not sorted correctly, need to call xml_sort on parent * @note xc is not sorted correctly, need to call xml_sort on parent
*/ */
int int
@ -973,6 +991,8 @@ xml_addsub(cxobj *xp,
if (strcmp(pns, cns) == 0) if (strcmp(pns, cns) == 0)
xml_purge(xa); xml_purge(xa);
} }
/* clear namespace context cache of child */
nscache_clear(xp);
} }
return 0; return 0;
} }

View file

@ -710,6 +710,9 @@ xml_insert(cxobj *xp,
if (xml_child_insert_pos(xp, xi, i) < 0) if (xml_child_insert_pos(xp, xi, i) < 0)
goto done; goto done;
xml_parent_set(xi, xp); xml_parent_set(xi, xp);
/* clear namespace context cache of child */
nscache_clear(xi);
retval = 0; retval = 0;
done: done:
return retval; return retval;