summaryrefslogtreecommitdiffstats
path: root/src/receive.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-19 23:54:10 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-19 23:54:10 +0200
commit0bf9268453d3af82bbd1257da547b1dd8f225ba2 (patch)
treec543378f2af2311683c741ec3111e16effd0ef28 /src/receive.c
parent194e1c878aa383994fef0cbbb3449fdaa599b53a (diff)
downloadfastd-0bf9268453d3af82bbd1257da547b1dd8f225ba2.tar
fastd-0bf9268453d3af82bbd1257da547b1dd8f225ba2.zip
Keep peers in a hash table to allow fast address lookups
Diffstat (limited to 'src/receive.c')
-rw-r--r--src/receive.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/receive.c b/src/receive.c
index 5bbab23..32a1c39 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -27,6 +27,7 @@
#include "fastd.h"
#include "handshake.h"
#include "peer.h"
+#include "peer_hashtable.h"
static inline void handle_socket_control(struct msghdr *message, const fastd_socket_t *sock, fastd_peer_address_t *local_addr) {
@@ -163,13 +164,7 @@ static inline void handle_socket_receive(fastd_context_t *ctx, fastd_socket_t *s
peer = sock->peer;
}
else {
- size_t i;
- for (i = 0; i < VECTOR_LEN(ctx->peers); i++) {
- peer = VECTOR_INDEX(ctx->peers, i);
-
- if (fastd_peer_address_equal(&peer->address, remote_addr))
- break;
- }
+ peer = fastd_peer_hashtable_lookup(ctx, remote_addr);
}
if (peer) {