Browse Source

refine the connection close

pull/205/head
Max Lv 9 years ago
parent
commit
7fc0a136ec
1 changed files with 2 additions and 10 deletions
  1. 12
      src/redir.c

12
src/redir.c

@ -164,10 +164,8 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
// connection closed // connection closed
remote->buf_len = 0; remote->buf_len = 0;
remote->buf_idx = 0; remote->buf_idx = 0;
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server); close_and_free_server(EV_A_ server);
if (remote != NULL) {
ev_io_start(EV_A_ & remote->send_ctx->io);
}
return; return;
} else if (r < 0) { } else if (r < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { 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_len = 0;
remote->buf_idx = 0; remote->buf_idx = 0;
ev_io_stop(EV_A_ & remote_send_ctx->io); 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);
} }
} }

Loading…
Cancel
Save