summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-22 01:55:06 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-22 01:55:06 +0100
commit2e715f6c73505b8721d3d48e7c93598448699075 (patch)
tree9c770600fc00fe735464abf59b2b29543599d211 /src
parent49be8b8c593ceb740fdaebdea3f15f2112d1cd1d (diff)
downloadfastd-2e715f6c73505b8721d3d48e7c93598448699075.tar
fastd-2e715f6c73505b8721d3d48e7c93598448699075.zip
peer: remove free_socket_by_id()
Diffstat (limited to 'src')
-rw-r--r--src/peer.c18
1 files changed, 4 insertions, 14 deletions
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: