/*
- * $Id: cache_cf.cc,v 1.538 2008/01/22 15:34:28 hno Exp $
+ * $Id: cache_cf.cc,v 1.539 2008/02/08 01:56:32 hno Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
self_destruct();
}
#endif
+ } else if (strcmp(token, "tcpkeepalive") == 0) {
+ s->tcp_keepalive.enabled = 1;
+ } else if (strncmp(token, "tcpkeepalive=", 13) == 0) {
+ char *t = token + 13;
+ s->tcp_keepalive.enabled = 1;
+ s->tcp_keepalive.idle = atoi(t);
+ t = strchr(t, ',');
+ if (t) {
+ t++;
+ s->tcp_keepalive.interval = atoi(t);
+ t = strchr(t, ',');
+ }
+ if (t) {
+ t++;
+ s->tcp_keepalive.timeout = atoi(t);
+ t = strchr(t, ',');
+ }
} else {
self_destruct();
}
storeAppendPrintf(e, " disable-pmtu-discovery=%s", pmtu);
}
+
+ if (s->tcp_keepalive.enabled) {
+ if (s->tcp_keepalive.idle || s->tcp_keepalive.interval || s->tcp_keepalive.timeout) {
+ storeAppendPrintf(e, " tcp_keepalive=%d,%d,%d", s->tcp_keepalive.idle, s->tcp_keepalive.interval, s->tcp_keepalive.timeout);
+ } else {
+ storeAppendPrintf(e, " tcp_keepalive");
+ }
+ }
}
static void
#
-# $Id: cf.data.pre,v 1.497 2008/02/06 06:54:14 amosjeffries Exp $
+# $Id: cf.data.pre,v 1.498 2008/02/08 01:56:32 hno Exp $
#
# SQUID Web Proxy Cache http://www.squid-cache.org/
# ----------------------------------------------------------
name= Specifies a internal name for the port. Defaults to
the port specification (port or addr:port)
+ keepalive[=idle,interval,timeout]
+ Enable TCP keepalive probes of idle connections
+ idle is the initial time before TCP starts probing
+ the connection, interval how often to probe, and
+ timeout the time before giving up.
+
If you run Squid on a dual-homed machine with an internal
and an external interface we recommend you to specify the
internal address:port in http_port. This way Squid will only be
/*
- * $Id: client_side.cc,v 1.773 2008/02/03 10:00:29 amosjeffries Exp $
+ * $Id: client_side.cc,v 1.774 2008/02/08 01:56:33 hno Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
#endif
+ if (s->tcp_keepalive.enabled) {
+ commSetTcpKeepalive(newfd, s->tcp_keepalive.idle, s->tcp_keepalive.interval, s->tcp_keepalive.timeout);
+ }
+
connState->readSomeData();
clientdbEstablished(details->peer, 1);
#endif
+ if (s->http.tcp_keepalive.enabled) {
+ commSetTcpKeepalive(newfd, s->http.tcp_keepalive.idle, s->http.tcp_keepalive.interval, s->http.tcp_keepalive.timeout);
+ }
+
commSetSelect(newfd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0);
clientdbEstablished(details->peer, 1);
/*
- * $Id: comm.cc,v 1.442 2008/01/19 07:11:35 amosjeffries Exp $
+ * $Id: comm.cc,v 1.443 2008/02/08 01:56:33 hno Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
#endif
+void
+commSetTcpKeepalive(int fd, int idle, int interval, int timeout)
+{
+ int on = 1;
+#ifdef TCP_KEEPCNT
+ if (timeout && interval) {
+ int count = (timeout + interval - 1) / interval;
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(on)) < 0)
+ debug(5, 1) ("commSetKeepalive: FD %d: %s\n", fd, xstrerror());
+ }
+#endif
+#ifdef TCP_KEEPIDLE
+ if (idle) {
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(on)) < 0)
+ debug(5, 1) ("commSetKeepalive: FD %d: %s\n", fd, xstrerror());
+ }
+#endif
+#ifdef TCP_KEEPINTVL
+ if (interval) {
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(on)) < 0)
+ debug(5, 1) ("commSetKeepalive: FD %d: %s\n", fd, xstrerror());
+ }
+#endif
+ if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)) < 0)
+ debug(5, 1) ("commSetKeepalive: FD %d: %s\n", fd, xstrerror());
+}
void
comm_init(void) {
SQUIDCEXTERN int commSetNonBlocking(int fd);
SQUIDCEXTERN int commUnsetNonBlocking(int fd);
SQUIDCEXTERN void commSetCloseOnExec(int fd);
+SQUIDCEXTERN void commSetTcpKeepalive(int fd, int idle, int interval, int timeout);
extern void _comm_close(int fd, char const *file, int line);
#define comm_close(fd) (_comm_close((fd), __FILE__, __LINE__))
SQUIDCEXTERN void comm_reset_close(int fd);
/*
- * $Id: structs.h,v 1.573 2008/01/19 07:15:30 amosjeffries Exp $
+ * $Id: structs.h,v 1.574 2008/02/08 01:56:33 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
unsigned int tproxy:
1; /* spoof client ip using tproxy */
#endif
+ struct {
+ unsigned int enabled;
+ unsigned int idle;
+ unsigned int interval;
+ unsigned int timeout;
+ } tcp_keepalive;
};