diff options
author | June McEnroe <june@causal.agency> | 2020-05-15 10:07:14 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-05-18 14:30:21 -0400 |
commit | 1e52d207aca21c8fa39f99fdf3ce559af6370ae2 (patch) | |
tree | acee50a73d022e910ab1e622ed84988aaaeb0f16 /local.c | |
parent | Add server send queueing with time interval (diff) | |
download | pounce-1e52d207aca21c8fa39f99fdf3ce559af6370ae2.tar.gz pounce-1e52d207aca21c8fa39f99fdf3ce559af6370ae2.zip |
Enable TCP keepalive with half-hour idle
Since we swallow IRC PINGs, a client connection can go hours idle on a quiet network. On my home internet, at least, these connections seem to get silently dropped.
Diffstat (limited to '')
-rw-r--r-- | local.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/local.c b/local.c index 0a140e6..50e49d5 100644 --- a/local.c +++ b/local.c @@ -20,6 +20,7 @@ #include <limits.h> #include <netdb.h> #include <netinet/in.h> +#include <netinet/tcp.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -218,6 +219,13 @@ struct tls *localAccept(int *fd, int bind) { int error = setsockopt(*fd, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes)); if (error) err(EX_OSERR, "setsockopt"); + error = setsockopt(*fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes)); + if (error) err(EX_OSERR, "setsockopt"); + + int idle = 15 * 60; + error = setsockopt(*fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)); + if (error) err(EX_OSERR, "setsockopt"); + struct tls *client; error = tls_accept_socket(server, &client, *fd); if (error) errx(EX_SOFTWARE, "tls_accept_socket: %s", tls_error(server)); |