Fix up state bypass get code

This commit is contained in:
Olof hagsand 2020-05-04 13:10:43 +02:00
parent dafc6d10e0
commit 592c513b83
6 changed files with 30 additions and 13 deletions

View file

@ -630,8 +630,13 @@ show_conf_xpath(clicon_handle h,
namespace = cv_string_get(cv);
if ((nsc = xml_nsctx_init(NULL, namespace)) == NULL)
goto done;
#if 0 /* Use state get intead of config (XXX: better use this but test_cli.sh fails) */
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
goto done;
#else
if (clicon_rpc_get_config(h, NULL, str, xpath, nsc, &xt) < 0)
goto done;
#endif
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clixon_netconf_error(xerr, "Get configuration", NULL);
goto done;

View file

@ -344,8 +344,19 @@ example_statedata(clicon_handle h,
/* If -S is set, then read state data from file, otherwise construct it programmatically */
if (_state_file){
if (_state_file_init){
#if 0 /* This is just for a zero-copy version (only works once) */
{
cxobj *xx = NULL;
while (xml_child_nr(_state_xstate)){
xx = xml_child_i(_state_xstate,0);
if (xml_addsub(xstate, xx) < 0)
goto done;
}
}
#else
if (xml_copy(_state_xstate, xstate) < 0)
goto done;
#endif
}
else{
if ((fd = open(_state_file, O_RDONLY)) < 0){

View file

@ -132,5 +132,5 @@
* This is a temporary option which will go away in future releases, therefore
* marked as obsolete.";
*/
#undef USE_STATE_PATH_KLUDGE
#define USE_STATE_PATH_KLUDGE

View file

@ -734,19 +734,21 @@ clicon_rpc_get(clicon_handle h,
(kpath = clicon_option_str(h, "CLICON_STATE_PATH_KLUDGE")) != NULL &&
strncmp(xpath, kpath, strlen(kpath)) == 0){
}
else
else{
#endif /* USE_STATE_PATH_KLUDGE */
if ((ret = xml_bind_yang(xd, YB_MODULE, yspec, &xerr)) < 0)
goto done;
#ifdef USE_STATE_PATH_KLUDGE
}
#endif
if (ret == 0){
assert(xerr != NULL);
if ((xd = xpath_first(xerr, NULL, "rpc-error")) == NULL){
clicon_err(OE_XML, ENOENT, "Expected rpc-error tag but none found(internal)");
goto done;
}
}
#ifdef USE_STATE_PATH_KLUDGE
}
}
#endif
}
if (xt){
if (xml_rm(xd) < 0)

View file

@ -1603,7 +1603,7 @@ xml_merge(cxobj *x0,
/* See if there is a corresponding node (x1c) in the base tree (x0) */
if (yc && match_base_child(x0, x1c, yc, &x0c) < 0)
goto done;
/* Save x0c, x1c, yc and merge in second wave, so that x1c entries dont "interfer"
/* Save x0c, x1c, yc and merge in second wave, so that x1c entries don't "interfere"
* with itself, ie that later searches are among earlier objects already added
* to x0 */
twophase[i].mt_x0c = x0c;

View file

@ -117,9 +117,8 @@ new "waiting"
wait_restconf
new "cli get large config"
echo "$clixon_cli -1f $cfg show state xml"
# baseline on thinkpad i5-3320M CPU @ 2.60GHz and 500K entries: 39.71s
$TIMEFN $clixon_cli -1f $cfg show state xml 2>&1 | awk '/real/ {print $2}'
$TIMEFN $clixon_cli -1f $cfg show xpath /interfaces urn:example:clixon 2>&1 | awk '/real/ {print $2}'
# START actual tests
# Having a large db, get single entries many times