mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-22 06:53:46 +00:00
Merge pull request #71 from clowwindy/master
use runtime checking instead of compile-time checking for TCP_FASTOPEN
This commit is contained in:
@@ -211,6 +211,12 @@ 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");
|
||||
// just turn it off
|
||||
fast_open = 0;
|
||||
}
|
||||
close_and_free_remote(EV_A_ remote);
|
||||
close_and_free_server(EV_A_ server);
|
||||
return;
|
||||
|
||||
+12
-1
@@ -100,7 +100,18 @@ int create_and_bind(const char *host, const char *port)
|
||||
if (fast_open)
|
||||
{
|
||||
opt = 5;
|
||||
setsockopt(listen_sock, SOL_TCP, TCP_FASTOPEN, &opt, sizeof(opt));
|
||||
int r = setsockopt(listen_sock, IPPROTO_TCP, TCP_FASTOPEN, &opt, sizeof(opt));
|
||||
if (r == -1)
|
||||
{
|
||||
if (errno == EPROTONOSUPPORT || errno == ENOPROTOOPT)
|
||||
{
|
||||
LOGE("fast open is not supported on this platform");
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("setsockopt");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user