We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e6c0716 commit be198d0Copy full SHA for be198d0
msgq/impl_zmq.cc
@@ -7,10 +7,20 @@
7
8
#include "msgq/impl_zmq.h"
9
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
+
20
//FIXME: This is a hack to get the port number from the socket name, might have collisions
21
static int get_port(std::string endpoint) {
22
std::hash<std::string> hasher;
- size_t hash_value = hasher(endpoint);
23
+ size_t hash_value = fnv1a_hash(endpoint);
24
int start_port = 8023;
25
int max_port = 65535;
26
int port = start_port + (hash_value % (max_port - start_port));
0 commit comments