Refine TCP fastopen

This commit is contained in:
Max Lv
2015-12-07 12:47:28 +08:00
parent 4656a8f0b9
commit e7a1d1e333
2 changed files with 7 additions and 4 deletions
+2 -3
View File
@@ -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;
}
+5 -1
View File
@@ -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);
}