libeech

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

commit 15d5a438034b9722da96ae6264b34dbb9641f1ba
parent fe9bdcbb5f33ca30a4e78fd4bbd4942f846049b9
Author: z3bra <contactatz3bradotorg>
Date:   Sat Jun 30 01:26:03 +0200

Fix bugs due to binary operator precedence

Diffstat:
libeech.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -397,7 +397,7 @@ pwprecv(struct peer *p) while ((r = recv(p->fd, p->rxbuf, l - p->rxbufsz, 0)) > 0) p->rxbufsz += r; - if (r < 0) + if (r < 0 && errno != EAGAIN) return -1; return l - p->rxbufsz; @@ -457,7 +457,7 @@ pwptx(struct torrent *t, struct peer *p) p->state |= HANDSHAKESENT; } - if (p->state & LEECHING && !(p->state & AMINTERESTED)) { + if ((p->state & LEECHING) && !(p->state & AMINTERESTED)) { pwpchst(p, INTERESTED); p->state |= AMINTERESTED; } @@ -552,8 +552,8 @@ netloop(struct torrent *t, int timeout) pwprx(t, pfds.p[i]); /* peer is now ready to exchange data */ - if (pfds.p[i]->state & HANDSHAKESENT && pfds.p[i]->state & HANDSHAKERCVD) - pfds.p[i]->state |= CONNECTED|SEEDING|LEECHING|AMCHOKING; + if (pfds.p[i]->state == (HANDSHAKESENT|HANDSHAKERCVD)) + pfds.p[i]->state |= (CONNECTED|SEEDING|LEECHING|AMCHOKING); } return npeer;