You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/08/16 23:31:51 UTC

[GitHub] [trafficserver] moonchen commented on a diff in pull request #9040: ts::shared_mutex - Fix lock counting for debug

moonchen commented on code in PR #9040:
URL: https://github.com/apache/trafficserver/pull/9040#discussion_r947327349


##########
include/tscpp/util/TsSharedMutex.h:
##########
@@ -184,8 +186,8 @@ class shared_mutex
 
   // 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};)

Review Comment:
   According to this: https://en.cppreference.com/w/cpp/atomic/atomic/atomic
   
   > The default constructor is trivial: no initialization takes place other than [zero initialization](https://en.cppreference.com/w/cpp/language/zero_initialization) of static and thread-local objects. [std::atomic_init](https://en.cppreference.com/w/cpp/atomic/atomic_init) may be used to complete initialization.
   
   I also ran into an uninitialized value during local testing, which drove this change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org