diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-20 02:16:44 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-20 02:16:44 +0200 |
commit | 8c705b9cd4c7866227f09af2a859744e47602ba4 (patch) | |
tree | 9b75234454e0611c484265698011b5df832d893c /src/peer.c | |
parent | 0bf9268453d3af82bbd1257da547b1dd8f225ba2 (diff) | |
download | fastd-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.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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; } } |