From 8597f3a880682b8a23be7eb9a27ca018e18ef492 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 7 Jan 2003 04:45:39 +0100 Subject: [PATCH] add a default cache size of 1G --- ccache.h | 5 +++++ stats.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ccache.h b/ccache.h index bcf3fddf2..4261cbc04 100644 --- a/ccache.h +++ b/ccache.h @@ -28,6 +28,11 @@ #define LIMIT_MULTIPLE 0.8 +/* default maximum cache size */ +#ifndef DEFAULT_MAXSIZE +#define DEFAULT_MAXSIZE (1000*1000) +#endif + enum stats { STATS_NONE=0, STATS_STDOUT, diff --git a/stats.c b/stats.c index 25860fbb5..b9a6f2c5f 100644 --- a/stats.c +++ b/stats.c @@ -93,6 +93,13 @@ static void write_stats(int fd, unsigned counters[STATS_END]) write(fd, buf, len); } + +/* fill in some default stats values */ +static void stats_default(unsigned counters[STATS_END]) +{ + counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16; +} + /* read in the stats from one dir and add to the counters */ static void stats_read_fd(int fd, unsigned counters[STATS_END]) { @@ -100,6 +107,7 @@ static void stats_read_fd(int fd, unsigned counters[STATS_END]) int len; len = read(fd, buf, sizeof(buf)-1); if (len <= 0) { + stats_default(counters); return; } buf[len] = 0; @@ -184,7 +192,10 @@ void stats_read(const char *stats_file, unsigned counters[STATS_END]) int fd; fd = open(stats_file, O_RDONLY); - if (fd == -1) return; + if (fd == -1) { + stats_default(counters); + return; + } lock_fd(fd); stats_read_fd(fd, counters); close(fd); -- 2.47.3