From 2e715f6c73505b8721d3d48e7c93598448699075 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 22 Mar 2015 01:55:06 +0100 Subject: peer: remove free_socket_by_id() --- src/peer.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/peer.c') diff --git a/src/peer.c b/src/peer.c index efe554d..5ac517c 100644 --- a/src/peer.c +++ b/src/peer.c @@ -151,7 +151,6 @@ static size_t peer_index_find_by_id(uint64_t id) { exit_bug("peer_index_find_by_id: not found"); return ret - VECTOR_DATA(ctx.peers); - } /** Finds the index of a peer in the array \e ctx.peers */ @@ -170,10 +169,8 @@ fastd_peer_t * fastd_peer_find_by_id(uint64_t id) { } -/** Closes and frees the dynamic socket of the peer with a specified ID */ -static void free_socket_by_id(size_t i) { - fastd_peer_t *peer = VECTOR_INDEX(ctx.peers, i); - +/** Closes and frees a peer's dynamic socket */ +static inline void free_socket(fastd_peer_t *peer) { if (!peer->sock) return; @@ -188,11 +185,6 @@ static void free_socket_by_id(size_t i) { peer->sock = NULL; } -/** Closes and frees a peer's dynamic socket */ -static inline void free_socket(fastd_peer_t *peer) { - free_socket_by_id(peer_index(peer)); -} - /** Checks if a peer group has any contraints which might cause connection attempts to be rejected */ static inline bool has_group_config_constraints(const fastd_peer_group_t *group) { for (; group; group = group->parent) { @@ -210,10 +202,8 @@ static inline bool has_group_config_constraints(const fastd_peer_group_t *group) or a default socket is used. */ void fastd_peer_reset_socket(fastd_peer_t *peer) { - size_t i = peer_index(peer); - if (peer->address.sa.sa_family == AF_UNSPEC) { - free_socket_by_id(i); + free_socket(peer); return; } @@ -222,7 +212,7 @@ void fastd_peer_reset_socket(fastd_peer_t *peer) { pr_debug("resetting socket for peer %P", peer); - free_socket_by_id(i); + free_socket(peer); switch (peer->address.sa.sa_family) { case AF_INET: -- cgit v1.2.3