Fix previous: cached_stats() returning < 0 means that the file is not found,

not that it was found in the cache, and centralize reporting.
This commit is contained in:
christos 2018-07-12 18:03:31 +00:00
parent 38c2b03323
commit 3a280067df

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $ */
/* $NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $");
__RCSID("$NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $");
#endif
#endif /* not lint */
#endif
@ -289,6 +289,10 @@ cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
memset(st, 0, sizeof(*st));
st->st_mtime = cst->mtime;
st->st_mode = cst->mode;
if (DEBUG(DIR)) {
fprintf(debug_file, "Using cached time %s for %s\n",
Targ_FmtTime(st->st_mtime), pathname);
}
return 0;
}
@ -306,6 +310,10 @@ cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
cst = entry->clientPtr;
cst->mtime = st->st_mtime;
cst->mode = st->st_mode;
if (DEBUG(DIR)) {
fprintf(debug_file, " Caching %s for %s\n",
Targ_FmtTime(st->st_mtime), pathname);
}
return 0;
}
@ -986,14 +994,6 @@ DirLookupSubdir(Path *p, const char *name)
}
if (cached_stat(file, &stb) == 0) {
/*
* Save the modification time so if it's needed, we don't have
* to fetch it again.
*/
if (DEBUG(DIR)) {
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
file);
}
nearmisses += 1;
return (file);
}
@ -1386,17 +1386,13 @@ Dir_FindFile(const char *name, Lst path)
bigmisses += 1;
if (cached_stat(name, &stb) == 0) {
if (DEBUG(DIR)) {
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
name);
}
return (bmake_strdup(name));
} else {
if (DEBUG(DIR)) {
fprintf(debug_file, " failed. Returning NULL\n");
}
return NULL;
}
if (DEBUG(DIR)) {
fprintf(debug_file, " failed. Returning NULL\n");
}
return NULL;
#endif /* notdef */
}
@ -1553,10 +1549,6 @@ Dir_MTime(GNode *gn, Boolean recheck)
}
if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
if (DEBUG(DIR)) {
fprintf(debug_file, "Using cached time %s for %s\n",
Targ_FmtTime(stb.st_mtime), fullName);
}
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);