Skip to content

Commit be198d0

Browse files
committed
fix endpoint
1 parent e6c0716 commit be198d0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

msgq/impl_zmq.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@
77

88
#include "msgq/impl_zmq.h"
99

10+
static size_t fnv1a_hash(const std::string &str) {
11+
const size_t fnv_prime = 0x100000001b3;
12+
size_t hash_value = 0xcbf29ce484222325;
13+
for (char c : str) {
14+
hash_value ^= (unsigned char)c;
15+
hash_value *= fnv_prime;
16+
}
17+
return hash_value;
18+
}
19+
1020
//FIXME: This is a hack to get the port number from the socket name, might have collisions
1121
static int get_port(std::string endpoint) {
1222
std::hash<std::string> hasher;
13-
size_t hash_value = hasher(endpoint);
23+
size_t hash_value = fnv1a_hash(endpoint);
1424
int start_port = 8023;
1525
int max_port = 65535;
1626
int port = start_port + (hash_value % (max_port - start_port));

0 commit comments

Comments
 (0)