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