tFiner state change - libeech - bittorrent library
(HTM) git clone git://z3bra.org/libeech.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 7e9e6a0571c4e55eaa9668eda0da0595ebce8931
(DIR) parent dfdb0fe7098b4c2789baac70e528ec734cfe82b5
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Fri, 9 Feb 2018 22:44:37 +0100
Finer state change
Diffstat:
M libeech.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/libeech.c b/libeech.c
t@@ -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 */
t@@ -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;
}
}
}