int ret = 0;
int fd1;
int fd2;
- gzFile f1 = NULL;
gzFile f2 = NULL;
struct manifest *mf = NULL;
char *tmp_file = NULL;
/* New file. */
mf = create_empty_manifest();
} else {
- f1 = gzdopen(fd1, "rb");
+ gzFile f1 = gzdopen(fd1, "rb");
if (!f1) {
cc_log("Failed to gzdopen manifest file");
close(fd1);
goto out;
}
mf = read_manifest(f1);
+ gzclose(f1);
if (!mf) {
- cc_log("Failed to read manifest file");
- gzclose(f1);
- goto out;
+ cc_log("Failed to read manifest file; deleting it");
+ x_unlink(manifest_path);
+ mf = create_empty_manifest();
}
}
- if (f1) {
- gzclose(f1);
- } else {
- close(fd1);
- }
-
if (mf->n_objects > MAX_MANIFEST_ENTRIES) {
/*
* Normally, there shouldn't be many object entries in the manifest since
checkstat 'cache hit (preprocessed)' 0
checkstat 'cache miss' 0
+ ##################################################################
+ # Check that corrupt manifest files are handled and rewritten.
+ testname="corrupt manifest file"
+ $CCACHE -z >/dev/null
+ manifest_file=`find $CCACHE_DIR -name '*.manifest'`
+ rm $manifest_file
+ touch $manifest_file
+ $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 1
+ checkstat 'cache miss' 0
+ $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (direct)' 1
+ checkstat 'cache hit (preprocessed)' 1
+ checkstat 'cache miss' 0
+
##################################################################
# Compiling with CCACHE_NODIRECT set should generate a preprocessed hit.
testname="preprocessed hit"