libeech

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

commit ac6b3082a4dcd6694b7171658356d7bb917f1097
parent 4d2331780189dff51f9159dbaab0b972efd9b237
Author: z3bra <contactatz3bradotorg>
Date:   Wed Jul  4 08:52:38 +0200

Improve pwpsend() to send all data

Diffstat:
libeech.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libeech.c b/libeech.c @@ -439,7 +439,18 @@ pwprecv(struct peer *p) static ssize_t pwpsend(struct peer *p, char *m, size_t sz) { - return send(p->fd, m, sz, MSG_NOSIGNAL); + size_t s = 0; + ssize_t r = 0; + + while (s < sz) { + r = send(p->fd, m + s, sz - s, MSG_NOSIGNAL); + if (r < 0 && errno != EAGAIN) + return -1; + if (r > 0) + s += r; + } + + return s; } /*