File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1111#include < chrono>
1212#include < sys/socket.h>
1313#include < sys/un.h>
14- #include < iostream >
14+ #include < Utilities/Util.h >
1515
1616#define LOCK_TIMEOUT 5 // 5 second timeout in case we wait for the lock (e.g PDA)
1717#define UNIX_SOCK_NAME_LENGTH 104 // 108 for most UNIXs, 104 for macOS
@@ -73,11 +73,8 @@ class Lock
7373 if (mSocketName .length () >= UNIX_SOCK_NAME_LENGTH) {
7474 std::string lockType = mSocketName .substr (0 , 17 ); // isolate the class that created the lock
7575 // Alice_O2_RoC_XYZ_*
76- std::cout << " mSocketName: " << mSocketName << std::endl;
77- std::cout << " cstr: " << mSocketName .c_str () << std::endl;
78- std::size_t lockNameHash = std::hash<std::string>{} (mSocketName .c_str ()); // hash the mutable part
76+ unsigned long lockNameHash = Utilities::hashDjb2 (mSocketName .c_str (), mSocketName .size ()); // hash the mutable part
7977 std::string safeLockName = lockType + std::to_string (lockNameHash) + " _lock" ; // return conformant name
80- std::cout << " lockNameHash: " << lockNameHash << std::endl;
8178 return safeLockName;
8279 } else {
8380 return mSocketName ;
Original file line number Diff line number Diff line change @@ -95,6 +95,14 @@ inline bool checkAlignment(void* address, uint64_t alignment)
9595 return (uint64_t (address) % alignment) == 0 ;
9696}
9797
98+ inline unsigned long hashDjb2 (const char *str, size_t length)
99+ {
100+ unsigned long hash = 5381 ;
101+ for (size_t i = 0 ; i < length; ++i)
102+ hash = 33 * hash + (unsigned char )str[i];
103+ return hash;
104+ }
105+
98106} // namespace Util
99107} // namespace roc
100108} // namespace AliceO2
You can’t perform that action at this time.
0 commit comments