Various memory and file resource cleanup after valgrind tests
This commit is contained in:
parent
78cd42c15d
commit
c2841d6e40
7 changed files with 17 additions and 12 deletions
|
|
@ -202,6 +202,7 @@ backend_client_delete(clixon_handle h,
|
||||||
free(ce->ce_transport);
|
free(ce->ce_transport);
|
||||||
if (ce->ce_source_host)
|
if (ce->ce_source_host)
|
||||||
free(ce->ce_source_host);
|
free(ce->ce_source_host);
|
||||||
|
ce->ce_next = NULL;
|
||||||
free(ce);
|
free(ce);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,9 +220,7 @@ clixon_proc_socket(clixon_handle h,
|
||||||
clixon_err(OE_UNIX, EINVAL, "argv[0] is NULL");
|
clixon_err(OE_UNIX, EINVAL, "argv[0] is NULL");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_PROC, "%s...", argv[0]);
|
clixon_debug(CLIXON_DBG_PROC, "%s...", argv[0]);
|
||||||
|
|
||||||
for (argc = 0; argv[argc] != NULL; ++argc)
|
for (argc = 0; argv[argc] != NULL; ++argc)
|
||||||
;
|
;
|
||||||
if ((flattened = clicon_strjoin(argc, argv, "', '")) == NULL){
|
if ((flattened = clicon_strjoin(argc, argv, "', '")) == NULL){
|
||||||
|
|
@ -254,6 +252,7 @@ clixon_proc_socket(clixon_handle h,
|
||||||
signal(SIGTSTP, SIG_IGN);
|
signal(SIGTSTP, SIG_IGN);
|
||||||
|
|
||||||
close(sp[0]);
|
close(sp[0]);
|
||||||
|
close(sperr[0]);
|
||||||
close(0);
|
close(0);
|
||||||
if (dup2(sp[1], STDIN_FILENO) < 0){
|
if (dup2(sp[1], STDIN_FILENO) < 0){
|
||||||
clixon_err(OE_UNIX, errno, "dup2(STDIN)");
|
clixon_err(OE_UNIX, errno, "dup2(STDIN)");
|
||||||
|
|
@ -273,15 +272,17 @@ clixon_proc_socket(clixon_handle h,
|
||||||
}
|
}
|
||||||
close(sperr[1]);
|
close(sperr[1]);
|
||||||
}
|
}
|
||||||
|
close(sperr[1]);
|
||||||
if (execvp(argv[0], argv) < 0){
|
if (execvp(argv[0], argv) < 0){
|
||||||
clixon_err(OE_UNIX, errno, "execvp(%s)", argv[0]);
|
clixon_err(OE_UNIX, errno, "execvp(%s)", argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
exit(-1); /* Shouldnt reach here */
|
exit(-1); /* Shouldnt reach here */
|
||||||
}
|
}
|
||||||
clixon_debug(CLIXON_DBG_PROC | CLIXON_DBG_DETAIL, "child %u sock %d", child, sp[0]);
|
clixon_debug(CLIXON_DBG_PROC, "child %u sock %d", child, sp[0]);
|
||||||
/* Parent */
|
/* Parent */
|
||||||
close(sp[1]);
|
close(sp[1]);
|
||||||
|
close(sperr[1]);
|
||||||
*pid = child;
|
*pid = child;
|
||||||
*sock = sp[0];
|
*sock = sp[0];
|
||||||
if (sockerr)
|
if (sockerr)
|
||||||
|
|
@ -308,7 +309,6 @@ clixon_proc_socket_close(pid_t pid,
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_PROC, "pid %u sock %d", pid, sock);
|
clixon_debug(CLIXON_DBG_PROC, "pid %u sock %d", pid, sock);
|
||||||
|
|
||||||
if (sock != -1)
|
if (sock != -1)
|
||||||
close(sock); /* usually kills */
|
close(sock); /* usually kills */
|
||||||
kill(pid, SIGTERM);
|
kill(pid, SIGTERM);
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,9 @@ ctx2number(xp_ctx *xc,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Replace a nodeset of a XPath context with a new nodeset
|
/*! Replace a nodeset of a XPath context with a new nodeset
|
||||||
|
*
|
||||||
|
* @param[in] vec XML vector, is consumed
|
||||||
|
* @param[in] veclen
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ctx_nodeset_replace(xp_ctx *xc,
|
ctx_nodeset_replace(xp_ctx *xc,
|
||||||
|
|
|
||||||
|
|
@ -371,6 +371,8 @@ xp_eval_step(xp_ctx *xc0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx_nodeset_replace(xc, vec, veclen);
|
ctx_nodeset_replace(xc, vec, veclen);
|
||||||
|
if (vec)
|
||||||
|
vec = NULL;
|
||||||
break;
|
break;
|
||||||
case A_DESCENDANT_OR_SELF:
|
case A_DESCENDANT_OR_SELF:
|
||||||
for (i=0; i<xc->xc_size; i++){
|
for (i=0; i<xc->xc_size; i++){
|
||||||
|
|
@ -705,6 +707,7 @@ xp_numop(xp_ctx *xc1,
|
||||||
* Move to clixon_xml.c?
|
* Move to clixon_xml.c?
|
||||||
* As a side-effect sets the cache.
|
* As a side-effect sets the cache.
|
||||||
* Clear cache with xml_cv_set(x, NULL)
|
* Clear cache with xml_cv_set(x, NULL)
|
||||||
|
* @see xml_cv_cache.c duplicated function
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xml_cv_cache(cxobj *x,
|
xml_cv_cache(cxobj *x,
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,10 @@ xpath_optimize_check(xpath_tree *xs,
|
||||||
else if ((ret = xpath_list_optimize_fn(xs, xv, xvec)) < 0)
|
else if ((ret = xpath_list_optimize_fn(xs, xv, xvec)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
else if (ret == 1){
|
else if (ret == 1){
|
||||||
|
if (xvec0 && *xvec0){
|
||||||
|
free(*xvec0);
|
||||||
|
*xvec0 = NULL;
|
||||||
|
}
|
||||||
if (clixon_xvec_extract(xvec, xvec0, xlen0, NULL) < 0){
|
if (clixon_xvec_extract(xvec, xvec0, xlen0, NULL) < 0){
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -380,10 +380,7 @@ yang_ref_dec(yang_stmt *ys)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
if (ys->ys_ref <= 0){
|
if (ys->ys_ref > 0)
|
||||||
clixon_err(OE_YANG, 0, "reference count is %d cannot decrement", ys->ys_ref);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
ys->ys_ref--;
|
ys->ys_ref--;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
|
|
@ -257,10 +257,7 @@ yang_mount_set(yang_stmt *y,
|
||||||
if ((cvv = yang_cvec_get(y)) != NULL &&
|
if ((cvv = yang_cvec_get(y)) != NULL &&
|
||||||
(cv = cvec_find(cvv, xpath)) != NULL &&
|
(cv = cvec_find(cvv, xpath)) != NULL &&
|
||||||
(yspec0 = cv_void_get(cv)) != NULL){
|
(yspec0 = cv_void_get(cv)) != NULL){
|
||||||
#if 0 /* Problematic to free yang specs here, upper layers should handle it? */
|
|
||||||
ys_free(yspec0);
|
ys_free(yspec0);
|
||||||
#endif
|
|
||||||
yang_ref_dec(yspec0);
|
|
||||||
cv_void_set(cv, NULL);
|
cv_void_set(cv, NULL);
|
||||||
}
|
}
|
||||||
else if ((cv = yang_cvec_add(y, CGV_VOID, xpath)) == NULL)
|
else if ((cv = yang_cvec_add(y, CGV_VOID, xpath)) == NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue