libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit 7e9e6a0571c4e55eaa9668eda0da0595ebce8931
parent dfdb0fe7098b4c2789baac70e528ec734cfe82b5
Author: z3bra <contactatz3bradotorg>
Date:   Fri Feb  9 22:44:37 +0100

Finer state change

Diffstat:
libeech.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -318,10 +318,9 @@ netloop(struct torrent *t, int timeout) } /* poll all peers for TCP events */ - if (!poll(fds, nfds, timeout)) { - printf("timeout!\n"); + if (!poll(fds, nfds, timeout)) return -1; - } + for (i = 0, p = t->peers; p; p = p->next) { if (fds[i].revents & POLLOUT) { /* send handshake */ @@ -333,8 +332,10 @@ netloop(struct torrent *t, int timeout) if (fds[i].revents & POLLIN) { /* receive and verify handshake */ if (!(p->state & HANDSHAKERCVD)) { - if (pwphsrecv(p) > 0 && !pwphsck(t, p->buf, p->buflen)) + if (pwphsrecv(p) >= 68) p->state |= HANDSHAKERCVD; + if (pwphsck(t, p->buf, p->buflen)) + p->state |= CONNECTED; } } }