This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 2e31ef8a5 ts::shared_mutex - Fix lock counting for debug (#9040)
2e31ef8a5 is described below
commit 2e31ef8a5a0a4327a17084c2ae51c0325d1feb61
Author: Mo Chen <[email protected]>
AuthorDate: Tue Aug 16 19:18:13 2022 -0500
ts::shared_mutex - Fix lock counting for debug (#9040)
Lock count variable was left uninitialized, causing assertions to fail.
This change initializes the debug data so they work properly. Also add
a similar check to the locking side.
---
include/tscpp/util/TsSharedMutex.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/tscpp/util/TsSharedMutex.h
b/include/tscpp/util/TsSharedMutex.h
index df0fd2c23..92bd20f4f 100644
--- a/include/tscpp/util/TsSharedMutex.h
+++ b/include/tscpp/util/TsSharedMutex.h
@@ -107,7 +107,9 @@ public:
if (error != 0) {
_call_fatal("pthread_rwlock_rdlock", &_lock, error);
}
+ X(TSAssert(_shared >= 0);)
X(++_shared;)
+ X(TSAssert(_shared > 0);)
}
bool
@@ -184,8 +186,8 @@ private:
// In debug builds, make sure shared vs. exlusive locks and unlocks are
properly paired.
//
- X(std::atomic<bool> _exclusive;)
- X(std::atomic<int> _shared;)
+ X(std::atomic<bool> _exclusive{false};)
+ X(std::atomic<int> _shared{0};)
};
} // end namespace ts