summaryrefslogtreecommitdiff
path: root/absl/log/globals.cc
diff options
context:
space:
mode:
authorGravatar Andy Getzendanner <durandal@google.com>2023-04-18 00:29:00 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-04-18 00:30:06 -0700
commitf36183604eb90bb7a921721e445e6dacff9e25bb (patch)
tree79fce606f1a0ee903a57aebb0d09c4d0adcd5057 /absl/log/globals.cc
parent387e1bf58c714e15ecba87c4b4673512afecf158 (diff)
Add an API to clear the saved LogBacktraceAt location, and call it when setting an empty or invalid flag value.
PiperOrigin-RevId: 525065479 Change-Id: I3c0822db8301e0999b0669394b415df82edd445f
Diffstat (limited to 'absl/log/globals.cc')
-rw-r--r--absl/log/globals.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/absl/log/globals.cc b/absl/log/globals.cc
index 6dfe81f0..f7c2ec42 100644
--- a/absl/log/globals.cc
+++ b/absl/log/globals.cc
@@ -123,7 +123,7 @@ namespace log_internal {
bool ShouldLogBacktraceAt(absl::string_view file, int line) {
const size_t flag_hash =
- log_backtrace_at_hash.load(std::memory_order_acquire);
+ log_backtrace_at_hash.load(std::memory_order_relaxed);
return flag_hash != 0 && flag_hash == HashSiteForLogBacktraceAt(file, line);
}
@@ -132,7 +132,11 @@ bool ShouldLogBacktraceAt(absl::string_view file, int line) {
void SetLogBacktraceLocation(absl::string_view file, int line) {
log_backtrace_at_hash.store(HashSiteForLogBacktraceAt(file, line),
- std::memory_order_release);
+ std::memory_order_relaxed);
+}
+
+void ClearLogBacktraceLocation() {
+ log_backtrace_at_hash.store(0, std::memory_order_relaxed);
}
bool ShouldPrependLogPrefix() {