From: Thomas Otto Date: Sun, 26 Jan 2020 20:34:34 +0000 (+0100) Subject: Turn lock_staleness_limit into a constant X-Git-Tag: v4.0~613^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F543%2Fhead;p=thirdparty%2Fccache.git Turn lock_staleness_limit into a constant Remove now-empty legacy_globals.cpp/hpp. --- diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp deleted file mode 100644 index f1c23fc29..000000000 --- a/src/legacy_globals.cpp +++ /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 index 8dba783bd..000000000 --- a/src/legacy_globals.hpp +++ /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 -#include - -// variable descriptions are in the .cpp file - -extern unsigned lock_staleness_limit; diff --git a/src/stats.cpp b/src/stats.cpp index 76682c05d..b25cf12d1 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -41,7 +41,8 @@ #include #include -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);