kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 07079dc8c054b4617e3239788cc95a64e09e6698
parent 8b47863cd45cf4685b74f5390a800c1e28b721b9
Author: Joris Vink <joris@coders.se>
Date:   Tue, 15 Oct 2013 11:09:33 +0200

Do not kill a connection if nb->len is 0 when sending data.

Diffstat:
src/net.c | 43+++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/src/net.c b/src/net.c @@ -97,31 +97,30 @@ net_send(struct connection *c) while (!TAILQ_EMPTY(&(c->send_queue))) { nb = TAILQ_FIRST(&(c->send_queue)); - if (nb->len == 0) { - kore_debug("net_send(): len is 0"); - return (KORE_RESULT_ERROR); - } - - r = SSL_write(c->ssl, - (nb->buf + nb->offset), (nb->len - nb->offset)); - - kore_debug("net_send(%ld/%ld bytes), progress with %d", - nb->offset, nb->len, r); - - if (r <= 0) { - r = SSL_get_error(c->ssl, r); - switch (r) { - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_WRITE: - c->flags &= ~CONN_WRITE_POSSIBLE; - return (KORE_RESULT_OK); - default: - kore_debug("SSL_write(): %s", ssl_errno_s); - return (KORE_RESULT_ERROR); + if (nb->len != 0) { + r = SSL_write(c->ssl, + (nb->buf + nb->offset), (nb->len - nb->offset)); + + kore_debug("net_send(%ld/%ld bytes), progress with %d", + nb->offset, nb->len, r); + + if (r <= 0) { + r = SSL_get_error(c->ssl, r); + switch (r) { + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_WRITE: + c->flags &= ~CONN_WRITE_POSSIBLE; + return (KORE_RESULT_OK); + default: + kore_debug("SSL_write(): %s", + ssl_errno_s); + return (KORE_RESULT_ERROR); + } } + + nb->offset += (size_t)r; } - nb->offset += (size_t)r; if (nb->offset == nb->len) { TAILQ_REMOVE(&(c->send_queue), nb, list);