diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d568f63..f307ded5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,7 @@ Developers may need to change their code
### 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)
## 6.5.0
diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index f39a9616..00f8187f 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -173,7 +173,6 @@ ce_event_cb(clixon_handle h,
return retval;
}
-
/*! 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
@@ -1015,7 +1014,6 @@ from_client_kill_session(clixon_handle h,
uint32_t id; /* session id */
char *str = NULL;
struct client_entry *ce;
- char *db = "running"; /* XXX */
cxobj *x;
int ret;
char *reason = NULL;
@@ -1032,16 +1030,10 @@ from_client_kill_session(clixon_handle h,
goto ok;
/* may or may not be in active client list, probably not */
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 */
}
- if (xmldb_islocked(h, db) == id){
- xmldb_unlock(h, db);
- /* user callback */
- if (clixon_plugin_lockdb_all(h, db, 0, id) < 0)
- goto done;
- }
+ if (release_all_dbs(h, id) < 0)
+ goto done;
cprintf(cbret, "", NETCONF_BASE_NAMESPACE);
ok:
retval = 0;
diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c
index 1f5f5ca6..767585a3 100644
--- a/apps/cli/cli_common.c
+++ b/apps/cli/cli_common.c
@@ -1545,7 +1545,7 @@ cli_lock(clixon_handle h,
* @retval 0 OK
* @retval -1 Error
* @code
- * lock("comment"), cli_lock("running");
+ * lock("comment"), cli_unlock("running");
* @endcode
* XXX: format is a memory leak
*/
@@ -1569,6 +1569,49 @@ cli_unlock(clixon_handle h,
return retval;
}
+/*! Kill session
+ *
+ * @param[in] h Clixon handle
+ * @param[in] cvv Not used
+ * @param[in] arg
+ * @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: ");
+ 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
*
* Works for objects that are items in a yang list with a keyname, eg as:
diff --git a/apps/cli/clixon_cli_api.h b/apps/cli/clixon_cli_api.h
index 74330a85..97da9a8c 100644
--- a/apps/cli/clixon_cli_api.h
+++ b/apps/cli/clixon_cli_api.h
@@ -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 cli_lock(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_help(clixon_handle h, cvec *vars, cvec *argv);
cvec *cvec_append(cvec *cvv0, cvec *cvv1);