dovecot-2.2: lib-http: client: Improved hash function for peer a...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 22 18:18:23 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/b4a1e4d085e2
changeset: 19186:b4a1e4d085e2
user: Stephan Bosch <stephan at rename-it.nl>
date: Tue Sep 22 21:15:45 2015 +0300
description:
lib-http: client: Improved hash function for peer addresses.
diffstat:
src/lib-http/http-client-peer.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diffs (39 lines):
diff -r 8166cb1a32ba -r b4a1e4d085e2 src/lib-http/http-client-peer.c
--- a/src/lib-http/http-client-peer.c Tue Sep 22 16:40:58 2015 +0300
+++ b/src/lib-http/http-client-peer.c Tue Sep 22 21:15:45 2015 +0300
@@ -43,21 +43,25 @@
unsigned int http_client_peer_addr_hash
(const struct http_client_peer_addr *peer)
{
+ unsigned int hash = (unsigned int)peer->type;
+
switch (peer->type) {
- case HTTP_CLIENT_PEER_ADDR_RAW:
- return net_ip_hash(&peer->a.tcp.ip) + peer->a.tcp.port + 1;
- case HTTP_CLIENT_PEER_ADDR_HTTP:
- return net_ip_hash(&peer->a.tcp.ip) + peer->a.tcp.port;
case HTTP_CLIENT_PEER_ADDR_HTTPS:
case HTTP_CLIENT_PEER_ADDR_HTTPS_TUNNEL:
- return net_ip_hash(&peer->a.tcp.ip) + peer->a.tcp.port +
- (peer->a.tcp.https_name == NULL ?
- 0 : str_hash(peer->a.tcp.https_name));
+ if (peer->a.tcp.https_name != NULL)
+ hash += str_hash(peer->a.tcp.https_name);
+ /* fall through */
+ case HTTP_CLIENT_PEER_ADDR_RAW:
+ case HTTP_CLIENT_PEER_ADDR_HTTP:
+ hash += net_ip_hash(&peer->a.tcp.ip);
+ hash += peer->a.tcp.port;
+ break;
case HTTP_CLIENT_PEER_ADDR_UNIX:
- return str_hash(peer->a.un.path);
+ hash += str_hash(peer->a.un.path);
+ break;
}
- i_unreached();
- return 0;
+
+ return hash;
}
int http_client_peer_addr_cmp
More information about the dovecot-cvs
mailing list