packetSize = i;
}
-
+ public int getKeepAliveTimeout() {
+ return ep.getKeepAliveTimeout();
+ }
+
+
+ public void setKeepAliveTimeout( int i ) {
+ ep.setKeepAliveTimeout(i);
+ setAttribute("keepAliveTimeout", "" + i);
+ }
+
+
// -------------------------------------- AjpConnectionHandler Inner Class
public static final int DEFAULT_CONNECTION_LINGER = -1;
public static final int DEFAULT_CONNECTION_TIMEOUT = -1;
public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
+ public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000;
public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
public static final boolean DEFAULT_TCP_NO_DELAY = true;
public static final int DEFAULT_CONNECTION_LINGER = -1;
public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
+ public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000;
public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
public static final boolean DEFAULT_TCP_NO_DELAY = true;
*/
protected int maxKeepAliveRequests = -1;
+ /**
+ * The number of seconds Tomcat will wait for a subsequent request
+ * before closing the connection.
+ */
+ protected int keepAliveTimeout = 15000;
+
/**
* SSL enabled ?
return timeout;
}
+ /**
+ * Set the Keep-Alive timeout.
+ */
+ public void setKeepAliveTimeout(int timeout) {
+ keepAliveTimeout = timeout;
+ }
+
+ /**
+ * Return the number Keep-Alive timeout.
+ */
+ public int getKeepAliveTimeout() {
+ return keepAliveTimeout;
+ }
/**
* Set the server header name.
private int socketBuffer = 9000;
private Adapter adapter;
private Http11ConnectionHandler cHandler;
+ private int keepAliveTimeout = 15000; // 15 seconds as in Apache HTTPD server
/**
* Compression value.
setAttribute("maxKeepAliveRequests", "" + mkar);
}
+
/**
- * Return the Keep-Alive policy for the connection.
+ * The number of seconds Tomcat will wait for a subsequent request
+ * before closing the connection. The default is the same as for
+ * Apache HTTP Server (15 000 milliseconds).
*/
- public boolean getKeepAlive() {
- return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));
+ public int getKeepAliveTimeout()
+ {
+ return keepAliveTimeout;
+ }
+
+ public void setKeepAliveTimeout(int timeout)
+ {
+ keepAliveTimeout = timeout;
}
/**
*/
protected int maxKeepAliveRequests = -1;
+ /**
+ * The number of seconds Tomcat will wait for a subsequent request
+ * before closing the connection.
+ */
+ protected int keepAliveTimeout = 15000;
+
/**
* SSL information.
return maxKeepAliveRequests;
}
+ /**
+ * Set the Keep-Alive timeout.
+ */
+ public void setKeepAliveTimeout(int timeout) {
+ keepAliveTimeout = timeout;
+ }
+
+
+ /**
+ * Return the number Keep-Alive timeout.
+ */
+ public int getKeepAliveTimeout() {
+ return keepAliveTimeout;
+ }
+
/**
* Set the maximum size of a POST which will be buffered in SSL mode.
// Parsing the request header
try {
- if( !disableUploadTimeout && keptAlive && soTimeout > 0 ) {
- socket.setSoTimeout(soTimeout);
+ if (!disableUploadTimeout && keptAlive) {
+ if (keepAliveTimeout > 0) {
+ socket.setSoTimeout(keepAliveTimeout);
+ }
+ else if (soTimeout > 0) {
+ socket.setSoTimeout(soTimeout);
+ }
}
inputBuffer.parseRequestLine();
request.setStartTime(System.currentTimeMillis());
public Http11Protocol() {
setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
+ setKeepAliveTimeout(Constants.DEFAULT_KEEPALIVE_TIMEOUT);
//setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
}
public int getMaxKeepAliveRequests() { return maxKeepAliveRequests; }
public void setMaxKeepAliveRequests(int mkar) { maxKeepAliveRequests = mkar; }
+ // HTTP
+ /**
+ * The number of seconds Tomcat will wait for a subsequent request
+ * before closing the connection. The default is the same as for
+ * Apache HTTP Server (15 000 milliseconds).
+ */
+ protected int keepAliveTimeout = 15000;
+ public int getKeepAliveTimeout()
+ {
+ return keepAliveTimeout;
+ }
+
+ public void setKeepAliveTimeout(int timeout)
+ {
+ keepAliveTimeout = timeout;
+ }
// HTTP
/**
new Http11Processor(protocol.maxHttpHeaderSize, protocol.endpoint);
processor.setAdapter(protocol.adapter);
processor.setMaxKeepAliveRequests(protocol.maxKeepAliveRequests);
+ processor.setKeepAliveTimeout(protocol.keepAliveTimeout);
processor.setTimeout(protocol.timeout);
processor.setDisableUploadTimeout(protocol.disableUploadTimeout);
processor.setCompression(protocol.compression);
/**
+ * Keep-Alive timeout.
+ */
+ protected int keepAliveTimeout = 15000;
+ public int getKeepAliveTimeout()
+ {
+ return keepAliveTimeout;
+ }
+
+ public void setKeepAliveTimeout(int timeout)
+ {
+ keepAliveTimeout = timeout;
+ }
+
+
+ /**
* Timeout on first request read before going to the poller, in ms.
*/
protected int firstReadTimeout = -1;
protected void init() {
pool = Pool.create(serverSockPool);
int size = pollerSize / pollerThreadCount;
- int timeout = soTimeout;
+ int timeout = keepAliveTimeout;
if (comet) {
// FIXME: Find an appropriate timeout value, for now, "longer than usual"
// semms appropriate
- timeout = soTimeout * 50;
+ timeout = keepAliveTimeout * 50;
}
serverPollset = allocatePoller(size, pool, timeout);
if (serverPollset == 0 && size > 1024) {
protected void init() {
pool = Pool.create(serverSockPool);
int size = sendfileSize / sendfileThreadCount;
- sendfilePollset = allocatePoller(size, pool, soTimeout);
+ sendfilePollset = allocatePoller(size, pool, keepAliveTimeout);
if (sendfilePollset == 0 && size > 1024) {
size = 1024;
- sendfilePollset = allocatePoller(size, pool, soTimeout);
+ sendfilePollset = allocatePoller(size, pool, keepAliveTimeout);
}
if (sendfilePollset == 0) {
size = 62;
- sendfilePollset = allocatePoller(size, pool, soTimeout);
+ sendfilePollset = allocatePoller(size, pool, keepAliveTimeout);
}
desc = new long[size * 2];
sendfileData = new HashMap<Long, SendfileData>(size);
presented. The default value is infinite (i.e. no timeout).</p>
</attribute>
+ <attribute name="keepAliveTimeout" required="false">
+ <p>The number of milliseconds this <strong>Connector</strong> will wait,
+ subsequent request before closing the connection.
+ The default value is infinite (i.e. no timeout).</p>
+ </attribute>
+
<attribute name="minProcessors" required="false">
<strong>deprecated</strong>
<p>The minimum number of processors to start at initialization time.
presented. The default value is 60000 (i.e. 60 seconds).</p>
</attribute>
+ <attribute name="keepAliveTimeout" required="false">
+ <p>The number of milliseconds this <strong>Connector</strong> will wait,
+ subsequent request before closing the connection.
+ The default value is 15000 (i.e. 15 seconds).</p>
+ </attribute>
+
<attribute name="disableUploadTimeout" required="false">
<p>This flag allows the servlet container to use a different, longer
connection timeout while a servlet is being executed, which in the end