From 79b23768886c6a367b22774f98e7f42b7ef09ae9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Anders=20Bj=C3=B6rklund?= Date: Thu, 2 May 2019 21:28:38 +0200 Subject: [PATCH] Update the correct stats file for manifest (#405) There are global variables used for updating stats, and those were wrong for the manifest file update. So make sure to reset those variables, before adding the manifest (this means flushing the pending updates) --- src/ccache.c | 12 ++++++++++++ src/stats.c | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/ccache.c b/src/ccache.c index 251783acb..4a21821b6 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -236,6 +236,9 @@ static char *cpp_stderr; // belongs (//stats). char *stats_file = NULL; +// The stats_file to use for manifest +static char *manifest_stats; + // Whether the output is a precompiled header. bool output_is_precompiled_header = false; @@ -1340,6 +1343,11 @@ update_manifest_file(void) if (stat(manifest_path, &st) == 0) { old_size = file_size(&st); } + + char *old_stats_file = stats_file; + stats_flush(); + stats_file = manifest_stats; + MTR_BEGIN("manifest", "manifest_put"); if (manifest_put(manifest_path, cached_obj_hash, included_files)) { cc_log("Added object file hash to %s", manifest_path); @@ -1350,6 +1358,9 @@ update_manifest_file(void) cc_log("Failed to add object file hash to %s", manifest_path); } MTR_END("manifest", "manifest_put"); + + stats_flush(); + stats_file = old_stats_file; } static void @@ -2199,6 +2210,7 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode) char *manifest_name = hash_result(hash); manifest_path = get_path_in_cache(manifest_name, ".manifest"); + manifest_stats = format("%s/%c/stats", conf->cache_dir, manifest_name[0]); free(manifest_name); cc_log("Looking for object file hash in %s", manifest_path); diff --git a/src/stats.c b/src/stats.c index f221d7bac..0a0c7aab3 100644 --- a/src/stats.c +++ b/src/stats.c @@ -499,6 +499,9 @@ stats_flush(void) free(subdir); counters_free(counters); + + free(counter_updates); + counter_updates = NULL; } // Update a normal stat. -- 2.47.2