We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e17f86 commit e621ce0Copy full SHA for e621ce0
msgq/impl_zmq.cc
@@ -7,10 +7,19 @@
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) {
- std::hash<std::string> hasher;
- size_t hash_value = hasher(endpoint);
22
+ size_t hash_value = fnv1a_hash(endpoint);
23
int start_port = 8023;
24
int max_port = 65535;
25
int port = start_port + (hash_value % (max_port - start_port));
0 commit comments