Skip to content

Commit 60eaa32

Browse files
committed
Networking (BSD): support TCP_FASTOPEN
1 parent 672d4ad commit 60eaa32

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/common/networking/networking_linux.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// Try to use TCP Fast Open to send data
1919
static const char* tryTcpFastOpen(FFNetworkingState* state)
2020
{
21-
#if !defined(MSG_FASTOPEN) || !defined(TCP_FASTOPEN)
21+
#if !defined(TCP_FASTOPEN) || (defined(__linux__) && !defined(MSG_FASTOPEN))
2222
FF_DEBUG("TCP Fast Open not supported on this system");
2323
FF_UNUSED(state);
2424
return "TCP Fast Open not supported";
@@ -34,14 +34,20 @@ static const char* tryTcpFastOpen(FFNetworkingState* state)
3434
}
3535

3636
// Try to send data using Fast Open
37+
#ifdef __APPLE__
38+
ssize_t sent = 0;
39+
#else
3740
FF_DEBUG("Using sendto() + MSG_FASTOPEN to send %u bytes of data", state->command.length);
3841
ssize_t sent = sendto(state->sockfd,
3942
state->command.chars,
4043
state->command.length,
41-
MSG_FASTOPEN | MSG_DONTWAIT,
44+
#ifdef MSG_FASTOPEN
45+
MSG_FASTOPEN |
46+
#endif
47+
MSG_DONTWAIT,
4248
state->addr->ai_addr,
4349
state->addr->ai_addrlen);
44-
50+
#endif
4551
if (sent >= 0 || (errno == EAGAIN || errno == EWOULDBLOCK))
4652
{
4753
FF_DEBUG("TCP Fast Open %s (sent=%zd, errno=%d: %s)", errno == 0 ? "succeeded" : "was in progress",

0 commit comments

Comments
 (0)