mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-29 04:03:45 +00:00
Refine TCP fastopen
This commit is contained in:
+2
-3
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user