Fixed memory errors in backend, cli and streams
This commit is contained in:
parent
fc3f0cbcd9
commit
d24d5f6a9c
6 changed files with 33 additions and 37 deletions
|
|
@ -320,27 +320,22 @@ backend_client_rm(clixon_handle h,
|
||||||
struct client_entry **ce_prev;
|
struct client_entry **ce_prev;
|
||||||
uint32_t myid = ce->ce_id;
|
uint32_t myid = ce->ce_id;
|
||||||
yang_stmt *yspec;
|
yang_stmt *yspec;
|
||||||
int retval = -1;
|
|
||||||
|
|
||||||
/* If the confirmed-commit feature is enabled, rollback any ephemeral commit originated by this client */
|
/* If the confirmed-commit feature is enabled, rollback any ephemeral commit originated by this client */
|
||||||
if ((yspec = clicon_dbspec_yang(h)) == NULL) {
|
if ((yspec = clicon_dbspec_yang(h)) != NULL) {
|
||||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
|
||||||
goto done;
|
if (confirmed_commit_state_get(h) == EPHEMERAL) {
|
||||||
}
|
/* See if this client is the origin */
|
||||||
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
|
clixon_debug(CLIXON_DBG_BACKEND, "session_id: %u, confirmed_commit.session_id: %u", ce->ce_id, confirmed_commit_session_id_get(h));
|
||||||
if (confirmed_commit_state_get(h) == EPHEMERAL) {
|
if (myid == confirmed_commit_session_id_get(h)) {
|
||||||
/* See if this client is the origin */
|
clixon_debug(CLIXON_DBG_BACKEND, "ok, rolling back");
|
||||||
clixon_debug(CLIXON_DBG_BACKEND, "session_id: %u, confirmed_commit.session_id: %u", ce->ce_id, confirmed_commit_session_id_get(h));
|
clixon_log(h, LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back");
|
||||||
|
/* do_rollback errors are logged internally and there is no client to report errors to, so errors are
|
||||||
if (myid == confirmed_commit_session_id_get(h)) {
|
* ignored here.
|
||||||
clixon_debug(CLIXON_DBG_BACKEND, "ok, rolling back");
|
*/
|
||||||
clixon_log(h, LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back");
|
cancel_rollback_event(h);
|
||||||
|
do_rollback(h, NULL);
|
||||||
/* do_rollback errors are logged internally and there is no client to report errors to, so errors are
|
}
|
||||||
* ignored here.
|
|
||||||
*/
|
|
||||||
cancel_rollback_event(h);
|
|
||||||
do_rollback(h, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -363,9 +358,7 @@ backend_client_rm(clixon_handle h,
|
||||||
}
|
}
|
||||||
ce_prev = &c->ce_next;
|
ce_prev = &c->ce_next;
|
||||||
}
|
}
|
||||||
retval = backend_client_delete(h, ce); /* actually purge it */
|
return backend_client_delete(h, ce); /* actually purge it */
|
||||||
done:
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Get clixon per datastore stats
|
/*! Get clixon per datastore stats
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ backend_handle_exit(clixon_handle h)
|
||||||
{
|
{
|
||||||
struct client_entry *ce;
|
struct client_entry *ce;
|
||||||
|
|
||||||
|
stream_delete_all(h, 1);
|
||||||
/* only delete client structs, not close sockets, etc, see backend_client_rm WHY NOT? */
|
/* only delete client structs, not close sockets, etc, see backend_client_rm WHY NOT? */
|
||||||
while ((ce = backend_client_list(h)) != NULL){
|
while ((ce = backend_client_list(h)) != NULL){
|
||||||
if (ce->ce_s){
|
if (ce->ce_s){
|
||||||
|
|
|
||||||
|
|
@ -1845,8 +1845,11 @@ yang2cli_yspec(clixon_handle h,
|
||||||
clixon_err(OE_YANG, errno, "Failing clispec: %s", cbuf_get(cb));
|
clixon_err(OE_YANG, errno, "Failing clispec: %s", cbuf_get(cb));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
clixon_debug(CLIXON_DBG_CLI, "Generated auto-cli for module:%s",
|
clixon_debug(CLIXON_DBG_CLI, "%s", cbuf_get(cbname));
|
||||||
yang_filename_get(ymod));
|
if (cbname){
|
||||||
|
cbuf_free(cbname);
|
||||||
|
cbname = NULL;
|
||||||
|
}
|
||||||
/* Add prefix: assume new are appended */
|
/* Add prefix: assume new are appended */
|
||||||
for (i=0; i<pt_len_get(pt); i++){
|
for (i=0; i<pt_len_get(pt); i++){
|
||||||
if ((co = pt_vec_i_get(pt, i)) != NULL){
|
if ((co = pt_vec_i_get(pt, i)) != NULL){
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,6 @@ clixon_handle_exit(clixon_handle h)
|
||||||
clicon_hash_free(ha);
|
clicon_hash_free(ha);
|
||||||
if ((ha = clicon_db_elmnt(h)) != NULL)
|
if ((ha = clicon_db_elmnt(h)) != NULL)
|
||||||
clicon_hash_free(ha);
|
clicon_hash_free(ha);
|
||||||
stream_delete_all(h, 1);
|
|
||||||
free(ch);
|
free(ch);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -181,8 +181,9 @@ stream_add(clixon_handle h,
|
||||||
/*! Delete complete notification event stream list (not just single stream)
|
/*! Delete complete notification event stream list (not just single stream)
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] force Force deletion of
|
* @param[in] force Also free ss
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
stream_delete_all(clixon_handle h,
|
stream_delete_all(clixon_handle h,
|
||||||
|
|
@ -395,20 +396,20 @@ stream_ss_add(clixon_handle h,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Delete event stream subscription to a stream given a callback and arg
|
/*! Delete event stream subscription
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] stream Name of stream or NULL for all streams
|
* @param[in] es Event stream
|
||||||
* @param[in] fn Callback when event occurs
|
* @param[in] ss Stream subscription
|
||||||
* @param[in] arg Argument to use with callback. Also handle when deleting
|
* @param[in] force 1: free ss
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
stream_ss_rm(clixon_handle h,
|
stream_ss_rm(clixon_handle h,
|
||||||
event_stream_t *es,
|
event_stream_t *es,
|
||||||
struct stream_subscription *ss,
|
struct stream_subscription *ss,
|
||||||
int force)
|
int force)
|
||||||
{
|
{
|
||||||
clixon_debug(CLIXON_DBG_STREAM, "");
|
clixon_debug(CLIXON_DBG_STREAM, "");
|
||||||
DELQ(ss, es->es_subscription, struct stream_subscription *);
|
DELQ(ss, es->es_subscription, struct stream_subscription *);
|
||||||
|
|
|
||||||
|
|
@ -960,7 +960,7 @@ yspec_new_shared(clixon_handle h,
|
||||||
yang_flag_set(yspec1, YANG_FLAG_SPEC_MOUNT);
|
yang_flag_set(yspec1, YANG_FLAG_SPEC_MOUNT);
|
||||||
clixon_debug(CLIXON_DBG_YANG, "new yang-spec: %p", yspec1);
|
clixon_debug(CLIXON_DBG_YANG, "new yang-spec: %p", yspec1);
|
||||||
}
|
}
|
||||||
if (yang_cvec_add(yspec1, CGV_STRING, xpath) < 0){
|
if (yang_cvec_add(yspec1, CGV_STRING, xpath) == NULL){
|
||||||
yspec1 = NULL;
|
yspec1 = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -1102,7 +1102,6 @@ ys_free1(yang_stmt *ys,
|
||||||
free(ys->ys_nscache);
|
free(ys->ys_nscache);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue