* New state callback signature (ca_statedata2)
* The new callback contains parameters for paging * Goal is to replace ca_statedata callback * New plugin callback when lock/unlock occurs * Add `ca_lockdb` tro plugin init to use it. * Fixed: Typing 'q' in CLI more paging did not properly quit output * Output continued but was not shown, for a very large file this could cause considerable delay * Fixed: Lock was broken in first get get access * if the first netconf operation to a backend was lock;get;unlock, the lock was broken in the first get access.
This commit is contained in:
parent
aaf9a89183
commit
caabfd464e
15 changed files with 487 additions and 233 deletions
|
|
@ -52,7 +52,7 @@
|
|||
* modified, and these changes have not been committed or rolled back.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t de_id; /* session id */
|
||||
uint32_t de_id; /* session id keeps lock */
|
||||
cxobj *de_xml; /* cache */
|
||||
int de_modified; /* Dirty since loaded/copied/committed/etc XXX:nocache? */
|
||||
int de_empty; /* Empty on read from file, xmldb_readfile and xmldb_put sets it */
|
||||
|
|
|
|||
|
|
@ -206,11 +206,51 @@ typedef int (plgreset_t)(clicon_handle h, const char *db);
|
|||
*/
|
||||
typedef int (plgstatedata_t)(clicon_handle h, cvec *nsc, char *xpath, cxobj *xtop);
|
||||
|
||||
/*! Temporary new statedata callback */
|
||||
/*! List paging status in the plugin state data callback
|
||||
*
|
||||
* List paging is either enabled or not.
|
||||
* If paging is enabled, the xpath addresses a list/ leaf-list and the plugin should return
|
||||
* entries according to the values of offset and limit.
|
||||
* Paging can use a lock/transaction mechanism
|
||||
* If locking is not used, the plugin cannot expect more paging calls, and no state or caching
|
||||
* should be used
|
||||
* If locking is used, the paging is part of a session transaction and the plugin may cache
|
||||
* state (such as a cache) and can expect more paging calls until the running db-lock is released,
|
||||
* (see ca_lockdb)
|
||||
* The transaction is the regular lock/unlock db of running-db of a specific session.
|
||||
*/
|
||||
enum paging_status{
|
||||
PAGING_NONE, /* No list paging: limit/offset are no-ops */
|
||||
PAGING_STATELESS, /* Stateless list paging, dont expect more paging calls */
|
||||
PAGING_LOCK /* Transactional list paging, can expect more paging until lock release */
|
||||
};
|
||||
|
||||
/* Plugin statedata
|
||||
* @param[in] Clicon handle
|
||||
* @param[in] xpath Part of state requested
|
||||
* @param[in] nsc XPATH namespace context.
|
||||
* @param[in] pagination List pagination: 0: No, 1: begin/next, 2: end
|
||||
* @param[in] offset Offset, for list pagination
|
||||
* @param[in] limit Limit, for list pagination
|
||||
* @param[out] xtop XML tree where statedata is added
|
||||
* @retval -1 Fatal error
|
||||
* @retval 0 OK
|
||||
*/
|
||||
typedef int (plgstatedata2_t)(clicon_handle h, cvec *nsc, char *xpath,
|
||||
enum paging_status pagination,
|
||||
uint32_t offset, uint32_t limit,
|
||||
cxobj *xtop);
|
||||
|
||||
/*! Lock databse status has changed status
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] db Database name (eg "running")
|
||||
* @param[in] lock Lock status: 0: unlocked, 1: locked
|
||||
* @param[in] id Session id (of locker/unlocker)
|
||||
* @retval -1 Fatal error
|
||||
* @retval 0 OK
|
||||
*/
|
||||
typedef int (plglockdb_t)(clicon_handle h, char *db, int lock, int id);
|
||||
|
||||
/* Transaction-data type
|
||||
* @see clixon_backend_transaction.h for full transaction API
|
||||
*/
|
||||
|
|
@ -283,6 +323,7 @@ struct clixon_plugin_api{
|
|||
plgreset_t *cb_reset; /* Reset system status */
|
||||
plgstatedata_t *cb_statedata; /* Get state data from plugin (backend only) */
|
||||
plgstatedata2_t *cb_statedata2; /* Get state data from plugin (backend only) */
|
||||
plglockdb_t *cb_lockdb; /* Database lock changed state */
|
||||
trans_cb_t *cb_trans_begin; /* Transaction start */
|
||||
trans_cb_t *cb_trans_validate; /* Transaction validation */
|
||||
trans_cb_t *cb_trans_complete; /* Transaction validation complete */
|
||||
|
|
@ -305,6 +346,7 @@ struct clixon_plugin_api{
|
|||
#define ca_reset u.cau_backend.cb_reset
|
||||
#define ca_statedata u.cau_backend.cb_statedata
|
||||
#define ca_statedata2 u.cau_backend.cb_statedata2
|
||||
#define ca_lockdb u.cau_backend.cb_lockdb
|
||||
#define ca_trans_begin u.cau_backend.cb_trans_begin
|
||||
#define ca_trans_validate u.cau_backend.cb_trans_validate
|
||||
#define ca_trans_complete u.cau_backend.cb_trans_complete
|
||||
|
|
|
|||
|
|
@ -302,26 +302,29 @@ xmldb_unlock(clicon_handle h,
|
|||
* @param[in] h Clicon handle
|
||||
* @param[in] id Session id
|
||||
* @retval -1 Error
|
||||
* @retval 0 OK
|
||||
* @retval 0 OK
|
||||
*/
|
||||
int
|
||||
xmldb_unlock_all(clicon_handle h,
|
||||
uint32_t id)
|
||||
{
|
||||
int retval = -1;
|
||||
char **keys = NULL;
|
||||
size_t klen;
|
||||
int i;
|
||||
db_elmnt *de;
|
||||
int retval = -1;
|
||||
char **keys = NULL;
|
||||
size_t klen;
|
||||
int i;
|
||||
db_elmnt *de;
|
||||
|
||||
/* get all db:s */
|
||||
if (clicon_hash_keys(clicon_db_elmnt(h), &keys, &klen) < 0)
|
||||
goto done;
|
||||
for (i = 0; i < klen; i++)
|
||||
/* Identify the ones locked by client id */
|
||||
for (i = 0; i < klen; i++) {
|
||||
if ((de = clicon_db_elmnt_get(h, keys[i])) != NULL &&
|
||||
de->de_id == id){
|
||||
de->de_id = 0;
|
||||
clicon_db_elmnt_set(h, keys[i], de);
|
||||
}
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (keys)
|
||||
|
|
|
|||
|
|
@ -794,6 +794,8 @@ xmldb_get_cache(clicon_handle h,
|
|||
* No, argument against: we may want to have a semantically wrong file and wish to edit?
|
||||
*/
|
||||
de0.de_xml = x0t;
|
||||
if (de)
|
||||
de0.de_id = de->de_id;
|
||||
clicon_db_elmnt_set(h, db, &de0); /* Content is copied */
|
||||
} /* x0t == NULL */
|
||||
else
|
||||
|
|
@ -955,6 +957,8 @@ xmldb_get_zerocopy(clicon_handle h,
|
|||
* No, argument against: we may want to have a semantically wrong file and wish to edit?
|
||||
*/
|
||||
de0.de_xml = x0t;
|
||||
if (de)
|
||||
de0.de_id = de->de_id;
|
||||
clicon_db_elmnt_set(h, db, &de0);
|
||||
} /* x0t == NULL */
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue