aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-01-09 14:30:58 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-20 08:10:43 +0100
commit8fe1571ea9bbd52140304206e340f30ead66d6ab (patch)
tree1b5d7e69b9835005ff3a52865d36e939823a5ed3
parent86dae84bed909ce075a70bfdba7000a1bf9b9bac (diff)
ipaccess: Make TCP keep-alive configurable
This patch changes the implementation to use the keep-alive configuration fields instead of constants. Ticket: OW#1060 Sponsored-by: On-Waves ehf
-rw-r--r--src/input/ipaccess.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 6b9d93e..4684520 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -608,6 +608,7 @@ struct e1inp_driver ipaccess_driver = {
.line_update = ipaccess_line_update,
.close = ipaccess_close,
.default_delay = 0,
+ .has_keepalive = 1,
};
static void update_fd_settings(struct e1inp_line *line, int fd)
@@ -615,7 +616,7 @@ static void update_fd_settings(struct e1inp_line *line, int fd)
int ret;
int val;
- if (DEFAULT_TCP_KEEPALIVE_RETRY_COUNT) {
+ if (line->keepalive_num_probes) {
/* Enable TCP keepalive to find out if the connection is gone */
val = 1;
ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
@@ -627,21 +628,27 @@ static void update_fd_settings(struct e1inp_line *line, int fd)
#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) && defined(TCP_KEEPCNT)
/* The following options are not portable! */
- val = DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT;
+ val = line->keepalive_idle_timeout > 0 ?
+ line->keepalive_idle_timeout :
+ DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT;
ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE,
&val, sizeof(val));
if (ret < 0)
LOGP(DLINP, LOGL_NOTICE,
"Failed to set keepalive idle time: %s\n",
strerror(errno));
- val = DEFAULT_TCP_KEEPALIVE_INTERVAL;
+ val = line->keepalive_probe_interval > -1 ?
+ line->keepalive_probe_interval :
+ DEFAULT_TCP_KEEPALIVE_INTERVAL;
ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL,
&val, sizeof(val));
if (ret < 0)
LOGP(DLINP, LOGL_NOTICE,
"Failed to set keepalive interval: %s\n",
strerror(errno));
- val = DEFAULT_TCP_KEEPALIVE_RETRY_COUNT;
+ val = line->keepalive_num_probes > 0 ?
+ line->keepalive_num_probes :
+ DEFAULT_TCP_KEEPALIVE_RETRY_COUNT;
ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT,
&val, sizeof(val));
if (ret < 0)