]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Turn lock_staleness_limit into a constant 543/head
authorThomas Otto <thomas.otto@pdv-fs.de>
Sun, 26 Jan 2020 20:34:34 +0000 (21:34 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Mon, 17 Feb 2020 21:31:02 +0000 (22:31 +0100)
Remove now-empty legacy_globals.cpp/hpp.

src/legacy_globals.cpp [deleted file]
src/legacy_globals.hpp [deleted file]
src/stats.cpp

diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp
deleted file mode 100644 (file)
index f1c23fc..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2020 Joel Rosdahl and other contributors
-//
-// See doc/AUTHORS.adoc for a complete list of contributors.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3 of the License, or (at your option)
-// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-// more details.
-//
-// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc., 51
-// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-#include "legacy_globals.hpp"
-
-// How long (in microseconds) to wait before breaking a stale lock.
-unsigned lock_staleness_limit = 2000000;
diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp
deleted file mode 100644 (file)
index 8dba783..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2020 Joel Rosdahl and other contributors
-//
-// See doc/AUTHORS.adoc for a complete list of contributors.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3 of the License, or (at your option)
-// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-// more details.
-//
-// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc., 51
-// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-#pragma once
-
-#include "system.hpp"
-
-#include "ccache.hpp"
-#include "hash.hpp"
-
-#include <string>
-#include <unordered_map>
-
-// variable descriptions are in the .cpp file
-
-extern unsigned lock_staleness_limit;
index 76682c05dafa1632f7c504a48b0b2f3091a4eded..b25cf12d138a1d28975db682cd447e7e23698f11 100644 (file)
@@ -41,7 +41,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-extern unsigned lock_staleness_limit;
+// How long (in microseconds) to wait before breaking a stale lock.
+constexpr unsigned k_lock_staleness_limit = 2000000;
 
 #define FLAG_NOZERO 1 // don't zero with the -z option
 #define FLAG_ALWAYS 2 // always show, even if zero
@@ -379,7 +380,7 @@ stats_flush_to_file(const Config& config,
       "{}/{:x}/stats", config.cache_dir(), hash_from_int(getpid()) % 16);
   }
 
-  if (!lockfile_acquire(sfile.c_str(), lock_staleness_limit)) {
+  if (!lockfile_acquire(sfile.c_str(), k_lock_staleness_limit)) {
     return;
   }
 
@@ -544,7 +545,7 @@ stats_zero(const Config& config)
       free(fname);
       continue;
     }
-    if (lockfile_acquire(fname, lock_staleness_limit)) {
+    if (lockfile_acquire(fname, k_lock_staleness_limit)) {
       stats_read(fname, counters);
       for (unsigned i = 0; stats_info[i].message; i++) {
         if (!(stats_info[i].flags & FLAG_NOZERO)) {
@@ -581,7 +582,7 @@ stats_set_sizes(const char* dir, unsigned num_files, uint64_t total_size)
 {
   struct counters* counters = counters_init(STATS_END);
   char* statsfile = format("%s/stats", dir);
-  if (lockfile_acquire(statsfile, lock_staleness_limit)) {
+  if (lockfile_acquire(statsfile, k_lock_staleness_limit)) {
     stats_read(statsfile, counters);
     counters->data[STATS_NUMFILES] = num_files;
     counters->data[STATS_TOTALSIZE] = total_size / 1024;
@@ -598,7 +599,7 @@ stats_add_cleanup(const char* dir, unsigned count)
 {
   struct counters* counters = counters_init(STATS_END);
   char* statsfile = format("%s/stats", dir);
-  if (lockfile_acquire(statsfile, lock_staleness_limit)) {
+  if (lockfile_acquire(statsfile, k_lock_staleness_limit)) {
     stats_read(statsfile, counters);
     counters->data[STATS_NUMCLEANUPS] += count;
     stats_write(statsfile, counters);