costin 01/06/24 15:41:16
Modified: src/share/org/apache/tomcat/modules/server
PoolTcpConnector.java
Log:
Merged a fix from j-t-c, the isSameAddress is here to avoid Ajp13->Ajp12
deps.
Revision Changes Path
1.5 +33 -0
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/PoolTcpConnector.java
Index: PoolTcpConnector.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/PoolTcpConnector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PoolTcpConnector.java 2001/03/31 21:48:31 1.4
+++ PoolTcpConnector.java 2001/06/24 22:41:16 1.5
@@ -257,6 +257,39 @@
return (ServerSocketFactory)chC.newInstance();
}
+ /**
+ * Return <code>true</code> if the specified client and server addresses
+ * are the same. This method works around a bug in the IBM 1.1.8 JVM on
+ * Linux, where the address bytes are returned reversed in some
+ * circumstances.
+ *
+ * @param server The server's InetAddress
+ * @param client The client's InetAddress
+ */
+ public static boolean isSameAddress(InetAddress server, InetAddress client) {
+ // Compare the byte array versions of the two addresses
+ byte serverAddr[] = server.getAddress();
+ byte clientAddr[] = client.getAddress();
+ if (serverAddr.length != clientAddr.length)
+ return (false);
+ boolean match = true;
+ for (int i = 0; i < serverAddr.length; i++) {
+ if (serverAddr[i] != clientAddr[i]) {
+ match = false;
+ break;
+ }
+ }
+ if (match)
+ return (true);
+
+ // Compare the reversed form of the two addresses
+ for (int i = 0; i < serverAddr.length; i++) {
+ if (serverAddr[i] != clientAddr[(serverAddr.length-1)-i])
+ return (false);
+ }
+ return (true);
+ }
+
// public static String getExtension( String classN ) {
// int lidot=classN.lastIndexOf( "." );
// if( lidot >0 ) classN=classN.substring( lidot + 1 );