Browse Source

Refine TCP fastopen

pull/472/head
Max Lv 9 years ago
parent
commit
e7a1d1e333
2 changed files with 7 additions and 4 deletions
  1. 5
      src/local.c
  2. 6
      src/server.c

5
src/local.c

@ -324,8 +324,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
} else {
ERROR("sendto");
if (errno == ENOTCONN) {
LOGE(
"fast open is not supported on this platform");
LOGE( "fast open is not supported on this platform");
// just turn it off
fast_open = 0;
}
@ -333,7 +332,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
close_and_free_server(EV_A_ server);
return;
}
} else if (s < remote->buf->len) {
} else if (s <= remote->buf->len) {
remote->buf->len -= s;
remote->buf->idx = s;
}

6
src/server.c

@ -250,7 +250,11 @@ int setfastopen(int fd)
int s = 0;
#ifdef TCP_FASTOPEN
if (fast_open) {
#ifdef __APPLE__
int opt = 1;
#else
int opt = 5;
#endif
s = setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &opt, sizeof(opt));
if (s == -1) {
if (errno == EPROTONOSUPPORT || errno == ENOPROTOOPT) {
@ -760,7 +764,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
server->stage = 4;
// listen to remote connected event
// waiting on remote connected event
ev_io_stop(EV_A_ & server_recv_ctx->io);
ev_io_start(EV_A_ & remote->send_ctx->io);
}

Loading…
Cancel
Save