From 0b1ed4f8f4259e63b7f2fe8dd7831ea2b4398977 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Wed, 17 Apr 2013 19:02:47 +0800 Subject: [PATCH] make sure index is set to zero --- src/local.c | 2 ++ src/redir.c | 2 ++ src/server.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/local.c b/src/local.c index 1722775c..e93662a2 100644 --- a/src/local.c +++ b/src/local.c @@ -132,6 +132,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send remote->buf_len = r; + remote->buf_idx = 0; ev_io_stop(EV_A_ &server_recv_ctx->io); ev_io_start(EV_A_ &remote->send_ctx->io); return; @@ -344,6 +345,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send server->buf_len = r; + server->buf_idx = 0; ev_io_stop(EV_A_ &remote_recv_ctx->io); ev_io_start(EV_A_ &server->send_ctx->io); return; diff --git a/src/redir.c b/src/redir.c index 30eaa221..9ebf916d 100644 --- a/src/redir.c +++ b/src/redir.c @@ -142,6 +142,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send remote->buf_len = r; + remote->buf_idx = 0; ev_io_stop(EV_A_ &server_recv_ctx->io); ev_io_start(EV_A_ &remote->send_ctx->io); return; @@ -261,6 +262,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send server->buf_len = r; + server->buf_idx = 0; ev_io_stop(EV_A_ &remote_recv_ctx->io); ev_io_start(EV_A_ &server->send_ctx->io); return; diff --git a/src/server.c b/src/server.c index 30a487c8..9d482368 100644 --- a/src/server.c +++ b/src/server.c @@ -163,6 +163,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send remote->buf_len = r; + remote->buf_idx = 0; ev_io_stop(EV_A_ &server_recv_ctx->io); ev_io_start(EV_A_ &remote->send_ctx->io); } else { @@ -469,6 +470,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send server->buf_len = r; + server->buf_idx = 0; ev_io_stop(EV_A_ &remote_recv_ctx->io); ev_io_start(EV_A_ &server->send_ctx->io); } else {