From 7fc0a136ec9fc1b8bad04d98c7af484011b67b91 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 4 Jan 2015 17:41:32 +0800 Subject: [PATCH] refine the connection close --- src/redir.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/redir.c b/src/redir.c index 10b5ce55..d8a775bd 100644 --- a/src/redir.c +++ b/src/redir.c @@ -164,10 +164,8 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) // connection closed remote->buf_len = 0; remote->buf_idx = 0; + close_and_free_remote(EV_A_ remote); close_and_free_server(EV_A_ server); - if (remote != NULL) { - ev_io_start(EV_A_ & remote->send_ctx->io); - } return; } else if (r < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) { @@ -425,13 +423,7 @@ static void remote_send_cb(EV_P_ ev_io *w, int revents) remote->buf_len = 0; remote->buf_idx = 0; ev_io_stop(EV_A_ & remote_send_ctx->io); - if (server != NULL) { - ev_io_start(EV_A_ & server->recv_ctx->io); - } else { - close_and_free_remote(EV_A_ remote); - close_and_free_server(EV_A_ server); - return; - } + ev_io_start(EV_A_ & server->recv_ctx->io); } }