From 9716eede20c370bd1cb9f3ef448df9f3469e9179 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Mon, 13 Feb 2017 18:54:37 +0800 Subject: [PATCH] Fix server buffer #1245 --- src/server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server.c b/src/server.c index 142cb980..676be2a4 100644 --- a/src/server.c +++ b/src/server.c @@ -549,15 +549,17 @@ server_recv_cb(EV_P_ ev_io *w, int revents) remote_t *remote = NULL; buffer_t *buf = server->buf; + size_t len = server->buf->len; if (server->stage == STAGE_STREAM) { remote = server->remote; buf = remote->buf; + len = 0; ev_timer_again(EV_A_ & server->recv_ctx->watcher); } - ssize_t r = recv(server->fd, buf->data, BUF_SIZE, 0); + ssize_t r = recv(server->fd, buf->data + len, BUF_SIZE - len, 0); if (r == 0) { // connection closed @@ -581,7 +583,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) } tx += r; - buf->len = r; + buf->len += r; int err = crypto->decrypt(buf, server->d_ctx, BUF_SIZE);