Commit 37503f01 authored by Walid Boudebouda's avatar Walid Boudebouda

VCC: ignore ENOENT on cleanup if vcc fails

When VCC is run, some temporary files are generated during the
process and are cleaned up at the end. The cleanup tries to remove
all the files that are supposed to be generated and displays a
"Could not delete 'vcl_...': No such file or directory" message if it
fails to find one of them. The error happens when VCC fails before
generating the file(s). This commit avoids the bogus messages by
ignoring ENOENT if VCC failed.

Fixes #3925
parent 2234ef9f
......@@ -157,7 +157,7 @@ void VJ_subproc(enum jail_subproc_e);
int VJ_make_workdir(const char *);
int VJ_make_subdir(const char *, const char *, struct vsb *);
void VJ_fix_fd(int, enum jail_fixfd_e);
void VJ_unlink(const char *);
void VJ_unlink(const char *, int);
void VJ_rmdir(const char *);
extern const struct jail_tech jail_tech_unix;
......
......@@ -199,12 +199,13 @@ VJ_make_subdir(const char *dname, const char *what, struct vsb *vsb)
}
void
VJ_unlink(const char *fname)
VJ_unlink(const char *fname, int ignore_enoent)
{
VJ_master(JAIL_MASTER_FILE);
if (unlink(fname)) {
fprintf(stderr, "Could not delete '%s': %s\n",
fname, strerror(errno));
if (errno != ENOENT || !ignore_enoent)
fprintf(stderr, "Could not delete '%s': %s\n",
fname, strerror(errno));
}
VJ_master(JAIL_MASTER_LOW);
}
......
......@@ -337,11 +337,13 @@ mgt_vcc_init_vp(struct vcc_priv *vp)
static void
mgt_vcc_fini_vp(struct vcc_priv *vp, enum vcc_fini_e vcc_status)
{
int ignore_enoent = (vcc_status == VCC_FAILED);
if (!MGT_DO_DEBUG(DBG_VCL_KEEP)) {
VJ_unlink(VSB_data(vp->csrcfile));
VJ_unlink(VSB_data(vp->symfile));
VJ_unlink(VSB_data(vp->csrcfile), ignore_enoent);
VJ_unlink(VSB_data(vp->symfile), ignore_enoent);
if (vcc_status != VCC_SUCCESS) {
VJ_unlink(VSB_data(vp->libfile));
VJ_unlink(VSB_data(vp->libfile), ignore_enoent);
VJ_rmdir(VSB_data(vp->dir));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment