Browse Source

fix #122

pull/127/head
Max Lv 10 years ago
parent
commit
9360fb553f
1 changed files with 13 additions and 6 deletions
  1. 19
      src/local.c

19
src/local.c

@ -242,10 +242,18 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents)
if (!remote->send_ctx->connected)
{
remote->buf_idx = 0;
remote->buf_len = r;
if (!fast_open || remote->direct)
{
// connecting, wait until connected
connect(remote->fd, remote->addr_info->ai_addr, remote->addr_info->ai_addrlen);
// wait on remote connected event
ev_io_stop(EV_A_ &server_recv_ctx->io);
ev_io_start(EV_A_ &remote->send_ctx->io);
ev_timer_start(EV_A_ &remote->send_ctx->watcher);
}
else
{
@ -282,18 +290,17 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents)
remote->buf_len = r - s;
remote->buf_idx = s;
}
// Just connected
remote->send_ctx->connected = 1;
ev_timer_stop(EV_A_ &remote->send_ctx->watcher);
ev_io_start(EV_A_ &remote->recv_ctx->io);
#else
// if TCP_FASTOPEN is not defined, fast_open will always be 0
LOGE("can't come here");
exit(1);
#endif
}
// wait on remote connected event
remote->buf_idx = 0;
remote->buf_len = r;
ev_io_stop(EV_A_ &server_recv_ctx->io);
ev_io_start(EV_A_ &remote->send_ctx->io);
ev_timer_start(EV_A_ &remote->send_ctx->watcher);
}
else
{

Loading…
Cancel
Save