Skip to content

Commit

Permalink
Removed other datastore options than cached
Browse files Browse the repository at this point in the history
Marked `CLICON_DATASTORE_CACHE` as obsolete
  • Loading branch information
olofhagsand committed Feb 1, 2024
1 parent bca315e commit 9989ee4
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 530 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Users may have to change how they access the system

* Revert the creators attribute feature introduced in 6.2. It is now obsoleted.
It is replaced with a configured `creators` and user/application semantics
* New `clixon-lib@2024-01-01.yang` revision
* Replaced container creators to grouping/uses
* New `clixon-config@2024-01-01.yang` revision
* Marked as obsolete:
* `CLICON_DATASTORE_CACHE` Replaced with enhanced datastore read API
* `CLICON_NETCONF_CREATOR_ATTR` reverting 6.5 functionality

### C/CLI-API changes on existing features
Developers may need to change their code
Expand Down
26 changes: 2 additions & 24 deletions apps/backend/backend_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,13 @@ startup_validate(clixon_handle h,
goto fail;
}
plugin_transaction_end_all(h, td);
/* Clear cached trees from default values and marking */
if (xmldb_get0_clear(h, td->td_target) < 0)
goto done;
if (xtr){
*xtr = td->td_target;
td->td_target = NULL;
}
retval = 1;
done:
if (td){
xmldb_get0_free(h, &td->td_target);
transaction_free(td);
}
return retval;
Expand Down Expand Up @@ -421,10 +417,9 @@ startup_commit(clixon_handle h,
/* After commit, make a post-commit call (sure that all plugins have committed) */
if (plugin_transaction_commit_done_all(h, td) < 0)
goto done;
/* Clear cached trees from default values and marking */
if (xmldb_get0_clear(h, td->td_target) < 0)
/* Remove global defaults and empty non-presence containers */
if (xml_defaults_nopresence(td->td_target, 2) < 0)
goto done;

/* [Delete and] create running db */
if (xmldb_exists(h, "running") == 1){
if (xmldb_delete(h, "running") != 0 && errno != ENOENT)
Expand Down Expand Up @@ -454,7 +449,6 @@ startup_commit(clixon_handle h,
if (td){
if (retval < 1)
plugin_transaction_abort_all(h, td);
xmldb_get0_free(h, &td->td_target);
transaction_free(td);
}
return retval;
Expand Down Expand Up @@ -622,10 +616,6 @@ candidate_validate(clixon_handle h,
goto done;
goto fail;
}
if (xmldb_get0_clear(h, td->td_src) < 0 ||
xmldb_get0_clear(h, td->td_target) < 0)
goto done;

plugin_transaction_end_all(h, td);
retval = 1;
done:
Expand All @@ -634,8 +624,6 @@ candidate_validate(clixon_handle h,
if (td){
if (retval < 1)
plugin_transaction_abort_all(h, td);
xmldb_get0_free(h, &td->td_target);
xmldb_get0_free(h, &td->td_src);
transaction_free(td);
}
return retval;
Expand Down Expand Up @@ -715,13 +703,6 @@ candidate_commit(clixon_handle h,
/* After commit, make a post-commit call (sure that all plugins have committed) */
if (plugin_transaction_commit_done_all(h, td) < 0)
goto done;

/* Clear cached trees from default values and marking */
if (xmldb_get0_clear(h, td->td_target) < 0)
goto done;
if (xmldb_get0_clear(h, td->td_src) < 0)
goto done;

/* 8. Success: Copy candidate to running
*/
if (xmldb_copy(h, db, "running") < 0)
Expand All @@ -746,8 +727,6 @@ candidate_commit(clixon_handle h,
if (td){
if (retval < 1)
plugin_transaction_abort_all(h, td);
xmldb_get0_free(h, &td->td_target);
xmldb_get0_free(h, &td->td_src);
transaction_free(td);
}
if (xret)
Expand Down Expand Up @@ -1043,7 +1022,6 @@ from_client_restart_one(clixon_handle h,
retval = 1;
done:
if (td){
xmldb_get0_free(h, &td->td_target);
transaction_free(td);
}
return retval;
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/backend_startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ db_merge(clixon_handle h,
/* Merge xml into db2. Without commit */
retval = xmldb_put(h, (char*)db2, OP_MERGE, xt, clicon_username_get(h), cbret);
done:
xmldb_get0_free(h, &xt);
return retval;
}

Expand Down Expand Up @@ -334,7 +333,6 @@ startup_extraxml(clixon_handle h,
done:
if (xt0)
xml_free(xt0);
xmldb_get0_free(h, &xt);
if (xmldb_delete(h, tmp_db) != 0 && errno != ENOENT)
return -1;
return retval;
Expand Down
2 changes: 0 additions & 2 deletions lib/clixon/clixon_datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ int xmldb_get(clixon_handle h, const char *db, cvec *nsc, char *xpath, cxobj **x
int xmldb_get0(clixon_handle h, const char *db, yang_bind yb,
cvec *nsc, const char *xpath, int copy, withdefaults_type wdef,
cxobj **xtop, modstate_diff_t *msd, cxobj **xerr);
int xmldb_get0_clear(clixon_handle h, cxobj *x);
int xmldb_get0_free(clixon_handle h, cxobj **xp);
int xmldb_put(clixon_handle h, const char *db, enum operation_type op, cxobj *xt, char *username, cbuf *cbret); /* in clixon_datastore_write.[ch] */
int xmldb_copy(clixon_handle h, const char *from, const char *to);
int xmldb_lock(clixon_handle h, const char *db, uint32_t id);
Expand Down
11 changes: 0 additions & 11 deletions lib/clixon/clixon_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ enum nacm_credentials_t{
NC_EXCEPT /* Exact match except for root and www user */
};

/*! Datastore cache behaviour, see clixon_datastore.[ch]
*
* See config option type datastore_cache in clixon-config.yang
*/
enum datastore_cache{
DATASTORE_NOCACHE,
DATASTORE_CACHE,
DATASTORE_CACHE_ZEROCOPY
};

/*! yang clixon regexp engine
*
* @see regexp_mode in clixon-config.yang
Expand Down Expand Up @@ -204,7 +194,6 @@ enum priv_mode_t clicon_backend_privileges_mode(clixon_handle h);
enum priv_mode_t clicon_restconf_privileges_mode(clixon_handle h);
enum nacm_credentials_t clicon_nacm_credentials(clixon_handle h);

enum datastore_cache clicon_datastore_cache(clixon_handle h);
enum regexp_mode clicon_yang_regexp(clixon_handle h);
/*-- Specific option access functions for non-yang options --*/
int clicon_quiet_mode(clixon_handle h);
Expand Down
68 changes: 33 additions & 35 deletions lib/src/clixon_datastore.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,42 +190,40 @@ xmldb_copy(clixon_handle h,

clixon_debug(CLIXON_DBG_DATASTORE, "%s %s", from, to);
/* XXX lock */
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE){
/* Copy in-memory cache */
/* 1. "to" xml tree in x1 */
if ((de1 = clicon_db_elmnt_get(h, from)) != NULL)
x1 = de1->de_xml;
if ((de2 = clicon_db_elmnt_get(h, to)) != NULL)
x2 = de2->de_xml;
if (x1 == NULL && x2 == NULL){
/* do nothing */
}
else if (x1 == NULL){ /* free x2 and set to NULL */
xml_free(x2);
x2 = NULL;
}
else if (x2 == NULL){ /* create x2 and copy from x1 */
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
goto done;
xml_flag_set(x2, XML_FLAG_TOP);
if (xml_copy(x1, x2) < 0)
goto done;
}
else{ /* copy x1 to x2 */
xml_free(x2);
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
goto done;
xml_flag_set(x2, XML_FLAG_TOP);
if (xml_copy(x1, x2) < 0)
goto done;
}
/* always set cache although not strictly necessary in case 1
* above, but logic gets complicated due to differences with
* de and de->de_xml */
if (de2)
de0 = *de2;
de0.de_xml = x2; /* The new tree */
/* Copy in-memory cache */
/* 1. "to" xml tree in x1 */
if ((de1 = clicon_db_elmnt_get(h, from)) != NULL)
x1 = de1->de_xml;
if ((de2 = clicon_db_elmnt_get(h, to)) != NULL)
x2 = de2->de_xml;
if (x1 == NULL && x2 == NULL){
/* do nothing */
}
else if (x1 == NULL){ /* free x2 and set to NULL */
xml_free(x2);
x2 = NULL;
}
else if (x2 == NULL){ /* create x2 and copy from x1 */
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
goto done;
xml_flag_set(x2, XML_FLAG_TOP);
if (xml_copy(x1, x2) < 0)
goto done;
}
else{ /* copy x1 to x2 */
xml_free(x2);
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
goto done;
xml_flag_set(x2, XML_FLAG_TOP);
if (xml_copy(x1, x2) < 0)
goto done;
}
/* always set cache although not strictly necessary in case 1
* above, but logic gets complicated due to differences with
* de and de->de_xml */
if (de2)
de0 = *de2;
de0.de_xml = x2; /* The new tree */
clicon_db_elmnt_set(h, to, &de0);

/* Copy the files themselves (above only in-memory cache) */
Expand Down
Loading

0 comments on commit 9989ee4

Please sign in to comment.