Browse Source

Merge pull request #71 from clowwindy/master

use runtime checking instead of compile-time checking for TCP_FASTOPEN
pull/77/head
Max Lv 10 years ago
parent
commit
cd85186dff
2 changed files with 18 additions and 1 deletions
  1. 6
      src/local.c
  2. 13
      src/server.c

6
src/local.c

@ -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;

13
src/server.c

@ -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

Loading…
Cancel
Save