summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-20 02:16:44 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-20 02:16:44 +0200
commit8c705b9cd4c7866227f09af2a859744e47602ba4 (patch)
tree9b75234454e0611c484265698011b5df832d893c /src/peer.c
parent0bf9268453d3af82bbd1257da547b1dd8f225ba2 (diff)
downloadfastd-8c705b9cd4c7866227f09af2a859744e47602ba4.tar
fastd-8c705b9cd4c7866227f09af2a859744e47602ba4.zip
Minimize poll interface to simplify implementation of alternative implementations
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/peer.c b/src/peer.c
index e7574ef..47b1370 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -48,16 +48,19 @@ static inline void free_socket(fastd_context_t *ctx, fastd_peer_t *peer) {
fastd_socket_close(ctx, peer->sock);
free(peer->sock);
+ peer->sock = NULL;
size_t i;
for (i = 0; i < VECTOR_LEN(ctx->peers); i++) {
if (VECTOR_INDEX(ctx->peers, i) == peer) {
- fastd_poll_set_fd_peer(ctx, -1, i);
+ fastd_poll_set_fd_peer(ctx, i);
break;
}
}
}
- peer->sock = NULL;
+ else {
+ peer->sock = NULL;
+ }
}
}
@@ -104,7 +107,7 @@ void fastd_peer_reset_socket(fastd_context_t *ctx, fastd_peer_t *peer) {
size_t i;
for (i = 0; i < VECTOR_LEN(ctx->peers); i++) {
if (VECTOR_INDEX(ctx->peers, i) == peer) {
- fastd_poll_set_fd_peer(ctx, peer->sock->fd, i);
+ fastd_poll_set_fd_peer(ctx, i);
break;
}
}