From: Alex Rousskov Date: Tue, 14 Feb 2023 14:23:33 +0000 (+0000) Subject: Fix --disable-optimizations build: Undefined RetryGapUsec (#1276) X-Git-Tag: SQUID_6_0_1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=974efa31125422523f1bb823e10c1d08e48afbe5;p=thirdparty%2Fsquid.git Fix --disable-optimizations build: Undefined RetryGapUsec (#1276) Since inception (2017 commit e99fa72), FileOpeningConfig::RetryGapUsec was declared but not defined in any translation unit (a bug). The build probably "worked" because compilers simply inlined the value of the constant data member when calling xusleep(). Commit 5eee0e4 removed code that passed RetryGapUsec to that external "C" function. Now, the same member is passed to a heavily-inlined and convoluted STL code, and at least some compilers (e.g., GCC v10-v12 on Ubuntu 22.04) stopped inlining RetryGapUsec unless optimization is enabled. Our CI tests passed because we do not test --disable-optimizations builds (yet). We do not need FileOpeningConfig::RetryGapUsec to be static, breaking builds, requiring extra code, and triggering questions. We do not even need it to be constant, but removing "const" is an arguably out-of-scope change, as is improving its type. File::InvalidHandle is missing a definition as well, except on Windows, but we are leaving that code "as is" for now, until we can test whether Windows is OK with removing that "static" keyword. --- diff --git a/src/base/File.cc b/src/base/File.cc index bd633338b0..68b9f717b7 100644 --- a/src/base/File.cc +++ b/src/base/File.cc @@ -332,7 +332,7 @@ File::lock(const FileOpeningConfig &cfg) " more time(s) after a failure: " << ex.what()); } Must(attemptsLeft); // the catch statement handles the last attempt - std::this_thread::sleep_for(std::chrono::microseconds(cfg.RetryGapUsec)); + std::this_thread::sleep_for(std::chrono::microseconds(cfg.retryGapUsec)); } debugs(54, 9, "disabled"); } diff --git a/src/base/File.h b/src/base/File.h index d0b801bf42..96be27ffa8 100644 --- a/src/base/File.h +++ b/src/base/File.h @@ -57,7 +57,7 @@ private: #else int flockMode = LOCK_UN; ///< 2nd flock(2) parameter #endif - static const unsigned int RetryGapUsec = 500000; /// pause before each lock retry + const unsigned int retryGapUsec = 500000; ///< pause before each lock retry unsigned int lockAttempts = 0; ///< how many times to try locking bool openByRoot = false; };