From 2825400936b607a877d2a25a8a873cbb75ac0b90 Mon Sep 17 00:00:00 2001 From: F5 Date: Sat, 8 Oct 2022 11:51:03 +0800 Subject: [PATCH] core: Make hash functions thread-safe --- src/core/model/hash.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/model/hash.h b/src/core/model/hash.h index 87b932de1..b45149efa 100644 --- a/src/core/model/hash.h +++ b/src/core/model/hash.h @@ -281,28 +281,44 @@ inline uint32_t Hash32 (const char * buffer, const std::size_t size) { +#ifdef NS3_MTP + return Hasher ().GetHash32 (buffer, size); +#else return GetStaticHash ().GetHash32 (buffer, size); +#endif } inline uint64_t Hash64 (const char * buffer, const std::size_t size) { +#ifdef NS3_MTP + return Hasher ().GetHash64 (buffer, size); +#else return GetStaticHash ().GetHash64 (buffer, size); +#endif } inline uint32_t Hash32 (const std::string s) { +#ifdef NS3_MTP + return Hasher ().GetHash32 (s); +#else return GetStaticHash ().GetHash32 (s); +#endif } inline uint64_t Hash64 (const std::string s) { +#ifdef NS3_MTP + return Hasher ().GetHash64 (s); +#else return GetStaticHash ().GetHash64 (s); +#endif }