mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
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: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
9e4c917c27
commit
a47865fa19
3 changed files with 20 additions and 4 deletions
|
@ -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
|
||||
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.
|
||||
|
|
11
changelog
11
changelog
|
@ -10,10 +10,13 @@ User api additions
|
|||
"1.1 9e7f737", representing the library version from configure.ac
|
||||
and the git HEAD hash the library was built from
|
||||
|
||||
- TCP Keepalive can now optionally be applied to all lws sockets, with
|
||||
controllable timeout, number of probes and probe interval. This
|
||||
enables detection of idle connections which are logically okay, but
|
||||
are in fact dead, due to network connectivity issues at the server,
|
||||
- TCP Keepalive can now optionally be applied to all lws sockets, on Linux
|
||||
also with controllable timeout, number of probes and probe interval.
|
||||
(On BSD type OS, you can only use system default settings for the
|
||||
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
|
||||
can enable it by setting a non-zero timeout (in seconds) at the new
|
||||
ka_time member at context creation time.
|
||||
|
|
|
@ -537,6 +537,14 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
|
|||
(const void *)&optval, optlen) < 0)
|
||||
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 */
|
||||
optval = context->ka_time;
|
||||
if (setsockopt(fd, IPPROTO_IP, TCP_KEEPIDLE,
|
||||
|
@ -552,6 +560,7 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
|
|||
if (setsockopt(fd, IPPROTO_IP, TCP_KEEPCNT,
|
||||
(const void *)&optval, optlen) < 0)
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Disable Nagle */
|
||||
|
|
Loading…
Add table
Reference in a new issue