Fixed: kill-session cleanup when client none existant, and for all db:s
Added cli_kill_session callback
This commit is contained in:
parent
558a0df1f3
commit
7b58c1c562
4 changed files with 48 additions and 11 deletions
|
|
@ -58,6 +58,7 @@ Developers may need to change their code
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
|
||||||
|
* Fixed: kill-session cleanup when client none existant, and for all db:s
|
||||||
* Fixed: [Using the characters '<' and '>' might cause an invalid diff](https://github.com/clicon/clixon-controller/issues/73)
|
* Fixed: [Using the characters '<' and '>' might cause an invalid diff](https://github.com/clicon/clixon-controller/issues/73)
|
||||||
|
|
||||||
## 6.5.0
|
## 6.5.0
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,6 @@ ce_event_cb(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Unlock all db:s of a client and call user unlock calback
|
/*! Unlock all db:s of a client and call user unlock calback
|
||||||
*
|
*
|
||||||
* @see xmldb_unlock_all unlocks, but does not call user callbacks which is a backend thing
|
* @see xmldb_unlock_all unlocks, but does not call user callbacks which is a backend thing
|
||||||
|
|
@ -1015,7 +1014,6 @@ from_client_kill_session(clixon_handle h,
|
||||||
uint32_t id; /* session id */
|
uint32_t id; /* session id */
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
struct client_entry *ce;
|
struct client_entry *ce;
|
||||||
char *db = "running"; /* XXX */
|
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
int ret;
|
int ret;
|
||||||
char *reason = NULL;
|
char *reason = NULL;
|
||||||
|
|
@ -1032,16 +1030,10 @@ from_client_kill_session(clixon_handle h,
|
||||||
goto ok;
|
goto ok;
|
||||||
/* may or may not be in active client list, probably not */
|
/* may or may not be in active client list, probably not */
|
||||||
if ((ce = ce_find_byid(backend_client_list(h), id)) != NULL){
|
if ((ce = ce_find_byid(backend_client_list(h), id)) != NULL){
|
||||||
if (release_all_dbs(h, id) < 0)
|
|
||||||
goto done;
|
|
||||||
backend_client_rm(h, ce); /* Removes client struct */
|
backend_client_rm(h, ce); /* Removes client struct */
|
||||||
}
|
}
|
||||||
if (xmldb_islocked(h, db) == id){
|
if (release_all_dbs(h, id) < 0)
|
||||||
xmldb_unlock(h, db);
|
|
||||||
/* user callback */
|
|
||||||
if (clixon_plugin_lockdb_all(h, db, 0, id) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok/></rpc-reply>", NETCONF_BASE_NAMESPACE);
|
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok/></rpc-reply>", NETCONF_BASE_NAMESPACE);
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
|
|
@ -1545,7 +1545,7 @@ cli_lock(clixon_handle h,
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @code
|
* @code
|
||||||
* lock("comment"), cli_lock("running");
|
* lock("comment"), cli_unlock("running");
|
||||||
* @endcode
|
* @endcode
|
||||||
* XXX: format is a memory leak
|
* XXX: format is a memory leak
|
||||||
*/
|
*/
|
||||||
|
|
@ -1569,6 +1569,49 @@ cli_unlock(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Kill session
|
||||||
|
*
|
||||||
|
* @param[in] h Clixon handle
|
||||||
|
* @param[in] cvv Not used
|
||||||
|
* @param[in] arg <session-id>
|
||||||
|
* @retval 0 OK
|
||||||
|
* @retval -1 Error
|
||||||
|
* @code
|
||||||
|
* lock("comment"), cli_kill_session(54);
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cli_kill_session(clixon_handle h,
|
||||||
|
cvec *cvv,
|
||||||
|
cvec *argv)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
char *str;
|
||||||
|
uint32_t session_id;
|
||||||
|
int ret;
|
||||||
|
char *reason = NULL;
|
||||||
|
|
||||||
|
if (cvec_len(argv) != 1){
|
||||||
|
clixon_err(OE_PLUGIN, EINVAL, "Requires arguments: <session-id>");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if ((str = cv_string_get(cvec_i(argv, 0))) != NULL){
|
||||||
|
if ((ret = parse_uint32(str, &session_id, NULL)) < 0)
|
||||||
|
goto done;
|
||||||
|
if (ret == 0){
|
||||||
|
cligen_output(stderr, "%s\n", reason);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
else if ((ret = clicon_rpc_kill_session(h, session_id)) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
if (reason)
|
||||||
|
free(reason);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Copy one configuration object to antother
|
/*! Copy one configuration object to antother
|
||||||
*
|
*
|
||||||
* Works for objects that are items in a yang list with a keyname, eg as:
|
* Works for objects that are items in a yang list with a keyname, eg as:
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ int cli_notify(clixon_handle h, cvec *cvv, cvec *argv);
|
||||||
int db_copy(clixon_handle h, cvec *cvv, cvec *argv);
|
int db_copy(clixon_handle h, cvec *cvv, cvec *argv);
|
||||||
int cli_lock(clixon_handle h, cvec *cvv, cvec *argv);
|
int cli_lock(clixon_handle h, cvec *cvv, cvec *argv);
|
||||||
int cli_unlock(clixon_handle h, cvec *cvv, cvec *argv);
|
int cli_unlock(clixon_handle h, cvec *cvv, cvec *argv);
|
||||||
|
int cli_kill_session(clixon_handle h, cvec *cvv, cvec *argv);
|
||||||
int cli_copy_config(clixon_handle h, cvec *cvv, cvec *argv);
|
int cli_copy_config(clixon_handle h, cvec *cvv, cvec *argv);
|
||||||
int cli_help(clixon_handle h, cvec *vars, cvec *argv);
|
int cli_help(clixon_handle h, cvec *vars, cvec *argv);
|
||||||
cvec *cvec_append(cvec *cvv0, cvec *cvv1);
|
cvec *cvec_append(cvec *cvv0, cvec *cvv1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue