Chromium Code Reviews| Index: net/socket/tcp_socket_libevent.cc |
| diff --git a/net/socket/tcp_socket_libevent.cc b/net/socket/tcp_socket_libevent.cc |
| index c5d30e1d5b085ec3781c3ca74044f7402fbd5283..6f9ae23f862e11e29a9df2cab2a806561067a07d 100644 |
| --- a/net/socket/tcp_socket_libevent.cc |
| +++ b/net/socket/tcp_socket_libevent.cc |
| @@ -56,6 +56,7 @@ bool SetTCPNoDelay(int fd, bool no_delay) { |
| // SetTCPKeepAlive sets SO_KEEPALIVE. |
| bool SetTCPKeepAlive(int fd, bool enable, int delay) { |
| + // Enabling TCP keepalives is the same on all platforms. |
| int on = enable ? 1 : 0; |
| if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on))) { |
| PLOG(ERROR) << "Failed to set SO_KEEPALIVE on fd: " << fd; |
| @@ -66,6 +67,7 @@ bool SetTCPKeepAlive(int fd, bool enable, int delay) { |
| if (!enable) |
| return true; |
| +// Setting the keepalive interval varies by platform. |
|
mmenke
2015/04/07 15:28:06
Indent here is weird, but that's what git cl forma
ramant (doing other things)
2015/04/08 20:08:38
Is it possible to move the comment inside #ifdef t
mmenke
2015/04/08 21:22:19
Done.
|
| #if defined(OS_LINUX) || defined(OS_ANDROID) |
| // Set seconds until first TCP keep alive. |
| if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &delay, sizeof(delay))) { |
| @@ -77,6 +79,11 @@ bool SetTCPKeepAlive(int fd, bool enable, int delay) { |
| PLOG(ERROR) << "Failed to set TCP_KEEPINTVL on fd: " << fd; |
| return false; |
| } |
| +#elif defined(OS_MACOSX) || defined(OS_IOS) |
| + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay))) { |
| + PLOG(ERROR) << "Failed to set TCP_KEEPALIVE on fd: " << fd; |
| + return false; |
| + } |
| #endif |
| return true; |
| } |