You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by hg...@apache.org on 2002/11/20 15:14:20 UTC
cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4 Ajp13Connector.java
hgomez 2002/11/20 06:14:20
Modified: jk/java/org/apache/ajp/tomcat4 Ajp13Connector.java
Log:
Add Linger support, and add some comments about IP settings for AJP13
Revision Changes Path
1.16 +64 -6 jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/Ajp13Connector.java
Index: Ajp13Connector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/Ajp13Connector.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Ajp13Connector.java 21 Apr 2002 23:17:48 -0000 1.15
+++ Ajp13Connector.java 20 Nov 2002 14:14:20 -0000 1.16
@@ -196,6 +196,13 @@
/**
+ * Linger value to be used on socket close.
+ * Note : a value of -1 means no linger used on close.
+ */
+ private int connectionLinger = -1;
+
+
+ /**
* The port number on which we listen for ajp13 requests.
*/
private int port = 8009;
@@ -309,7 +316,7 @@
/**
* Set the connection timeout for this Connector.
*
- * @param count The new connection timeout
+ * @param connectionTimeout The new connection timeout
*/
public void setConnectionTimeout(int connectionTimeout) {
@@ -317,6 +324,27 @@
}
+ /**
+ * Return the connection linger settings for this Connector.
+ */
+ public int getConnectionLinger() {
+
+ return (connectionLinger);
+
+ }
+
+
+ /**
+ * Set the connection linger for this Connector.
+ *
+ * @param connectionLinger The new connection linger
+ */
+ public void setConnectionLinger(int connectionLinger) {
+
+ this.connectionLinger = connectionLinger;
+
+ }
+
public void setSecret( String s ) {
secret=s;
}
@@ -844,9 +872,39 @@
logger.log("accepted socket, assigning to processor.");
}
- socket.setSoLinger(true, 100);
+ /* Warning :
+ *
+ * To be able to close more quickly a connection, it's recommanded
+ * to set linger to a small value.
+ *
+ * AJP13 connection SHOULD be closed under webserver responsability and
+ * in such case it's safe to close socket on Tomcat side without delay,
+ * which may be also the case for HTTP connectors.
+ *
+ * I (henri) recommand to set Linger to 0, making socket closed immediatly
+ * so the OS will free faster the underlying io descriptor and resources.
+ * It's very important under heavy load !
+ */
+
+ if (connectionLinger < 0)
+ socket.setSoLinger(false, 0);
+ else
+ socket.setSoLinger(true, connectionLinger);
+
socket.setKeepAlive(true);
+ /* Warning :
+ *
+ * AJP13 shouldn't use socket timeout on tomcat site since
+ * when Tomcat close a connection after a timeout is reached
+ * the socket stay in half-closed state until the webserver
+ * try to send a request to tomcat and detect the socket close
+ * when it will try to read the reply.
+ *
+ * On many Unix platforms the write() call didn't told
+ * webserver that the socket is closed.
+ */
+
if (connectionTimeout >= 0) {
socket.setSoTimeout(connectionTimeout);
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>