Skip to content
Snippets Groups Projects
Commit a47865fa authored by Andy Green's avatar Andy Green
Browse files

dont try set per socket keepalive timing on bsds

As per http://libwebsockets.org/trac/ticket/10


BSD doesn't support setting keepalive info per-socket

Signed-off-by: default avatarAndy Green <andy.green@linaro.org>
parent 9e4c917c
Branches
Tags
No related merge requests found
...@@ -184,3 +184,7 @@ stimulate a response from the peer without affecting link traffic. If the ...@@ -184,3 +184,7 @@ stimulate a response from the peer without affecting link traffic. If the
response is not coming, the socket will announce an error at poll() forcing response is not coming, the socket will announce an error at poll() forcing
a close. a close.
Note that BSDs don't support keepalive time / probes / inteveral per-socket
like Linux does. On those systems you can enable keepalive by a nonzero
value in ka_time, but the systemwide kernel settings for the time / probes/
interval are used, regardless of what nonzero value is in ka_time.
...@@ -10,10 +10,13 @@ User api additions ...@@ -10,10 +10,13 @@ User api additions
"1.1 9e7f737", representing the library version from configure.ac "1.1 9e7f737", representing the library version from configure.ac
and the git HEAD hash the library was built from and the git HEAD hash the library was built from
- TCP Keepalive can now optionally be applied to all lws sockets, with - TCP Keepalive can now optionally be applied to all lws sockets, on Linux
controllable timeout, number of probes and probe interval. This also with controllable timeout, number of probes and probe interval.
enables detection of idle connections which are logically okay, but (On BSD type OS, you can only use system default settings for the
are in fact dead, due to network connectivity issues at the server, timing and retries, although enabling it is supported by setting
ka_time to nonzero, the exact value has no meaning.)
This enables detection of idle connections which are logically okay,
but are in fact dead, due to network connectivity issues at the server,
client, or any intermediary. By default it's not enabled, but you client, or any intermediary. By default it's not enabled, but you
can enable it by setting a non-zero timeout (in seconds) at the new can enable it by setting a non-zero timeout (in seconds) at the new
ka_time member at context creation time. ka_time member at context creation time.
......
...@@ -537,6 +537,14 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd) ...@@ -537,6 +537,14 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
(const void *)&optval, optlen) < 0) (const void *)&optval, optlen) < 0)
return 1; return 1;
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
/*
* didn't find a way to set these per-socket, need to
* tune kernel systemwide values
*/
#else
/* set the keepalive conditions we want on it too */ /* set the keepalive conditions we want on it too */
optval = context->ka_time; optval = context->ka_time;
if (setsockopt(fd, IPPROTO_IP, TCP_KEEPIDLE, if (setsockopt(fd, IPPROTO_IP, TCP_KEEPIDLE,
...@@ -552,6 +560,7 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd) ...@@ -552,6 +560,7 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
if (setsockopt(fd, IPPROTO_IP, TCP_KEEPCNT, if (setsockopt(fd, IPPROTO_IP, TCP_KEEPCNT,
(const void *)&optval, optlen) < 0) (const void *)&optval, optlen) < 0)
return 1; return 1;
#endif
} }
/* Disable Nagle */ /* Disable Nagle */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment